Forum > Packages and Libraries

TChart intervals nicesteps

(1/1)

eldonfsr:
Hi sorry for questions i am not expert  on tchart i still learning about this, my questions is on intervals on tchart there several values witch fr example count,maxlength, minlength, and nicesteps...

nicesteps show values 0.2|0.5|1.0 so this values must allways son 3 values for incremente if wanna to have increment of 5,10,15  or 1,2, 3 or just 5 can be possible or how to do that...

i tried 5,10,15 but doesn't work going like default values...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  begin    case CBAxisx.ItemIndex of    0: SelectIncrementX('0.2|0.5|1',0,50);    1: SelectIncrementX('5|10|15', 0, 100);    2: SelectIncrementX('2|4|8', 0, 200);    3: SelectIncrementX('3|6|9', 0, 300);    4: SelectIncrementX('4|8|16', 0, 400);    5: SelectIncrementX('5|10|15', 0, 500);    6: SelectIncrementX('6|12|18', 0, 600);  end;  

wp:
Axis labelling is one of the most difficult jobs that TAChart is doing. Because it has to fulfill several contradicting requirements for arbitrary chart sizes and arbitrary axis limits: nice labels, not too dense, not too distant, specific label count...

NiceSteps contains a sequence of increments from which multiples will be selected.

The calculation begins with the first value (not 100% sure - basically it could be any one from the Nicesteps).

At first this NiceStep value is multiplied/divided several times by 10 until the labels fit into the axis range (so, when the axis has ends at -100 and +100, the 0.1 of the NiceSteps is multiplied by 100 because the 100-fold of 0.1 gives labels between -100 and +100: -100, -90, -80, ..., 90, 100).

In the next step, the distance between adjacent label positions is calculated in pixels. When this distance is between MinLength and maxLength is this increment is selected.

But when it is larger than the MaxLength parameter the next smaller NiceStepValue is picked. This places the marks closer to each other, and maybe the MaxLength criterion is fulfilled now. If not, the next smaller NextStep is selected, etc.

And when the distance is smaller than the MinLength the next larger NiceStepvalue is picked. Now the marks are further away, and maybe the MinLength criterion can be met. Etc.

Buth MaxLength and MinLength criteria must be fulfilled. If this cannot be accomplished labels are placed at the positions calculated from the assumption that a constant number of ticks is required (Intervals.Count).

Not 100% sure whether this description exactly describes the algorithm, but it certainly gives the basic idea.

In total, it is difficult to predict the increment which will be used by the axis. If you - by all means - need specific axis labels which do not change the safest way is to add a TListChartSource to the form and assign it to the Axis.Marks.Source property. Add the axis label values to the ListChartSource (ideally for both x and y so that the chart can be rotated):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  INCREMENT: Double = 15;         // Axis mark positions must have this distance.var  x: Double;  ext: TDoubleRect;  axis: TChartAxis;begin  axis := Chart1.BottomAxis;  // This is the axis to which you want to assign the specific labels  ext := Chart1.LogicalExtent;  // ext.a.x is the miniumum, ext.b.x the maximum at the axis.  x := Floor(ext.a.x / INCREMENT) * INCREMENT;  // Rounds the axis minimum to a multiple of INCREMENT  while (x <= ext.b.x) do  begin    ListChartSource1.AddXY(x, x);    x := x + DISTANCE;  end;end; 
This strategy is fine as long as you do not zoom into the chart or change the chart size: Zooming in or increasing the chart size increases the pixel distance between the marks and the marks eventually will disappear. Zooming out or decreasing the chart size decreases the distance, and marks will overlap. This is because you turned off the automatic label finding algorithm.

BTW:
Put your questions into the "TAChart" board of the forum, because usually I do not search through the more crowded boards. One a post has flown out of the "Recent" list it can be easily overlooked then.

eldonfsr:
Ok Thanks your good point let me tried

Navigation

[0] Message Index

Go to full version