Page 1 of 1

Forcing automatic axis recalculation?

Posted: Tue Aug 19, 2008 11:00 am
by 9523571
Hi,
I am using an automatic left axis on a chart (IAxis.Automatic property is true), and adjusting the bottom axis with the IAxis.Minimum /Maximum properties.

When I first load the data, the left axis range is very good.

If I later shrink the range on the bottom axis and the range of visible y-values becomes smaller and I would like the left axis to rescale itself automatically to match the visible data.

Is there a way to force this recalculation, or is the left axis range determined by the data loaded, including that out of sight?

I still want to leave the full range of data in the chart, so the user can drag the chart back to a different range of x-values.

Many thanks
Roger

Posted: Wed Aug 20, 2008 8:09 am
by yeray
Hi Roger,

I think that you should use MinVisibleSeriesValue and MaxVisibleSeriesValue to calculate the new SetMinMax values for your Left axis.

Code: Select all

TChart1.Axis.Left.SetMinMax TChart1.Axis.Left.MinVisibleSeriesValue(True, 0), TChart1.Axis.Left.MaxVisibleSeriesValue(True, 0)
TChart1.Axis.Left.MinimumOffset = 10
TChart1.Axis.Left.MaximumOffset = 10

Almost there

Posted: Wed Aug 20, 2008 2:26 pm
by 9523571
Hi Yeray,
Thanks, that is clearly in the right direction, but I suspect it needs some sort of internal refresh or recalculation first.

What I am doing following your post is:
1. set the min/max of the bottom axis
2. calculating the visible min and max on the left axis
3. setting the min/max on the left axis

What it is doing in step 2 is giving me the vertical range that looks correct before step 1. So if I shrink the x-range, the y-range stays large and if I expand the x-range again, the y-range goes small.

Is there something I should be doing as step 1.5 to ensure that step 2 uses the updated x-range?

Many thanks
Roger

Posted: Thu Aug 21, 2008 8:11 am
by yeray
Hi Roger,

Yeah, maybe it lefts an InternalRepaint to force teechart to update internal variables:

Code: Select all

TChart1.Environment.InternalRepaint

Posted: Thu Aug 21, 2008 8:36 am
by 9523571
Yes, that worked a treat.
Thanks Yeray

Best regards
Roger