Recent

Author Topic: Bottom axis marks  (Read 5710 times)

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Bottom axis marks
« on: September 27, 2016, 12:20:08 am »
I've never used TChart, so it is beginners question. I have datetime bottom axis filled with random values dispersed two minutes between two successive samples. When started, TChart presents about 20 marks at bottom axis with labels at every 20 minutes. How can I achieve to have marks at 30 minutes over bottom axis ? It is simple matter in Delphi TeeChart, however the two are pretty different.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Bottom axis marks
« Reply #1 on: September 27, 2016, 12:48:34 am »
Could you post a little demo? It is much easier for me to give you the correct answer if I know exactly what you need. Pack the lpi, lpr, pas and lfm files of the demo project into a single zip, and upload it here (use the "+ Attachments and other options" button below the edit field here).

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: Bottom axis marks
« Reply #2 on: September 27, 2016, 05:25:32 am »
It's very basic project- my first one using TChart.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Bottom axis marks
« Reply #3 on: September 27, 2016, 10:19:04 am »
Did you read what I wrote? "Pack the lpi, lpr, pas and lfm files ... into a ... zip" - but the lfm is missing, therefore I don't know which properties you modified. And you added the .lps, .ico and .res files which are not needed at all.

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: Bottom axis marks
« Reply #4 on: September 27, 2016, 11:39:36 am »
Sorry, I know lfm is needed, however mistakes happen (especially at early morning).

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Bottom axis marks
« Reply #5 on: September 27, 2016, 12:37:46 pm »
No problem.

For date/time axis labels you should use a TDateTimeIntervalChartSource, your "dtics". Assign it to the Marks.Source of the axis for which you want to use it. And set the Marks.Style to smsLabel to see the time labels. You can do this at designtime in the Object Inspector, or later at runtime.

The label intervals can be controled by the Params of the DateTimeIntervalChartSource. In most cases selecting aipUseCount, as you do, leads to ugly labels. Usually the default settings (aipUseMinLength, aipUseMaxLength, aipUseNiceSteps) lead to good results.

The MinLength determines the closest distance of axis grid lines, MaxLength the widest distance of grid lines, before the next unit is selected. Therefore you can control overlapping labels with these parameters - you have the labels vertically, and this is not so important.

The label values themselves are controlled by the NiceSteps parameter. This contains the values to be considered as intervals, the order of magnitude is selected automatically. '0.1|0.2|0.5' means that on the minute scale intervals of 1, 2, 5, 10, 20, 50 are considered (in principle also 0.1, 0.2, and 0.5 minutes, but before this happens the algorithm switches to the next display units (Steps)). This misses the 30 minutes that you require. Therefore, just add '0.3' to the list. And drop the 0.5 because 50 minutes intervals do not make much sense in this range: --> NiceSteps = '0.1|0.2|0.3', or '1|2|3' - it does not matter). Of course, this avoids 5-minute intervals, but with proper selection of MinLength/MaxLength this case will not happen.

All these values are considered only if the corresponding aipXXXX option is in effect.

When you add data and/or resize the chart probably different labels will be selected, not necessarily those that you require.

In FormCreate, you add data to the chart by calling
Code: Pascal  [Select][+][-]
  1.     cls1.AddXY(dt, random(20), FormatDateTime('dd/mm/yyyy', dt));  

Only the first two parameters are needed, the first one is the x, the second one the y value of the data point. The third parameter defines a data point label which is shown if you set Marks.Style of the series (not the axis) to smsLabel. It does not affect axis labels and is needed only if you want to draw data point labels inside the chart.

djdjdjole

  • Full Member
  • ***
  • Posts: 101
Re: Bottom axis marks
« Reply #6 on: September 27, 2016, 01:15:21 pm »
Perfect explanation- not only recipe for solution, but the internals also. Thank you "wp".

 

TinyPortal © 2005-2018