Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings

Thread: Tchart - How to adjust Left Axis scale during runtime ?

Replies: 3 - Last Post: Oct 18, 2017 3:36 AM Last Post By: Yeray Alonso Threads: [ Previous | Next ]
 Posts: 20 Registered: 11/1/11
 Tchart - How to adjust Left Axis scale during runtime ? Posted: Oct 16, 2017 7:26 AM Hi guys , I need some help to solve an issue with Tchart Left Axis scale. I'm using Delphi Tokyo 10.2 , Update 1 , with Tchart component. I plot a Tline series points based on values returned by a running procedure, which can be of very different magnitude. As an example, for the first 12 "X"-axis elements , the Y-axis values returned are between 1,000 and 900.00 (thousands) , but for next X elemensts its is possible to get values that gos to 1,000,000 - 10,000,000 or even over thos values (millions) . HOW TO adjust the scale of Left Axis (Y-values) during runtime , considering that the first 12 values will need to be readjusted in the new scale ?? I do appreciate your help and suggestions on this issue. Thank you in advance. JRG Edited by: Jose Silva on Oct 16, 2017 7:26 AM Edited by: Jose Silva on Oct 16, 2017 9:52 AM
 Posts: 75 Registered: 6/12/11
Re: Tchart - How to adjust Left Axis scale during runtime ?
Posted: Oct 16, 2017 11:59 PM   in response to: Jose Silva
Hello Jose,

Jose Silva wrote:
I'm using Delphi Tokyo 10.2 , Update 1 , with Tchart component. I plot a Tline series points based on values returned by a running procedure, which can be of very different magnitude.

As an example, for the first 12 "X"-axis elements , the Y-axis values returned are between 1,000 and 900.00 (thousands) , but for next X elemensts its is possible to get values that gos to 1,000,000 - 10,000,000 or even over thos values (millions) . HOW TO adjust the scale of Left Axis (Y-values) during runtime , considering that the first 12 values will need to be readjusted in the new scale ??

By default, TeeChart Axes are Automatic. When an Axis is Automatic, its scale (Minimum and Maximum) is automatically set considering all the values in all the series assigned to that axis.
Ie, in a new blank chart, if you add 12 values between 900 and 1000, both the bottom and the left axes scale to fit all the values and everything looks correct:

Chart1.View3D:=False;
Chart1.Legend.Visible:=False;

for i:=0 to 11 do

[img]https://i.imgur.com/S4Qfky9.png[/img]

If you add more values in a different range, ie between 1M and 10M, the axes are rescaled to fit all the points. The result is still correct. You can't see the differences between the first 12 values but that's something to expect:

var i: Integer;
begin
Chart1.View3D:=False;
Chart1.Legend.Visible:=False;

for i:=0 to 11 do

for i:=0 to 11 do

[img]https://i.imgur.com/IU0Fzxy.png[/img]

Now, having those values in the chart, if you want to focus the view to the first 12 points, you have to manually set both the bottom and the left axes scales. Ie:

Chart1.Axes.Left.SetMinMax(900, 1000);
Chart1.Axes.Bottom.SetMinMax(-0.25, 11.25);

Or, you can focus the view to the other 12 (high) points:

Chart1.Axes.Left.SetMinMax(1000000, 10000000);
Chart1.Axes.Bottom.SetMinMax(11.75, Chart1[0].Count-0.75);

Then, if you want to set the axes back to automatically set the scales, you can set the Automatic property:

Chart1.Axes.Left.Automatic:=True;
Chart1.Axes.Bottom.Automatic:=True;

--
Best Regards,

Yeray Alonso
Steema Software