After zoom, how to get max/min values of the axis ?

TeeChart for ActiveX, COM and ASP
Post Reply
Angelo
Newbie
Newbie
Posts: 14
Joined: Wed Mar 04, 2009 12:00 am

After zoom, how to get max/min values of the axis ?

Post by Angelo » Mon Feb 28, 2011 9:22 pm

I have a graph and I would like to know the values of the MaxXValue, MinXValue, MaxYValue and MinYValue after the zoom. I have noticed that after the zoom these properties still have the previous values of the original graph prior the applied zoom.


The main problem is that I set :
TChart1.Axis.Bottom.Automatic = False
TChart1.Axis.Left.Automatic = False



and I perform the calculations for the max/min and the increment for the axis. Example: the increment is calculated to have the Y axis divided in 4 equal parts, which I have done with:

increment=(TChart1.Axis.Left.Maximum-TChart1.Axis.Left.Minimum)/2
TChart1.Axis.Left.Maximum=TChart1.Axis.Left.Maximum+increment
TChart1.Axis.Left.Minimum=TChart1.Axis.Left.Minimum-increment
TChart1.Axis.Left.Increment=increment

If I zoom the graph, by using the mouse to draw a rectangle, I would like to run the code above in order again in order to have the graph divided in 4 equal parts. Here the problem is that all events is fired before the method responsible to redraw the chart, and the Maximum e Minimum properties are not updated yet. If I use afterdraw event I always get in trouble with recursive call.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: After zoom, how to get max/min values of the axis ?

Post by Yeray » Tue Mar 01, 2011 2:46 pm

Hi Angelo,

I think you could use that code in OnZoom event. The following code seems to work fine for me here:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  
  TChart1.AddSeries scFastLine
  TChart1.Series(0).FillSampleValues 100
End Sub

Private Sub TChart1_OnZoom()
  RecalcAxis
End Sub

Private Sub RecalcAxis()
  Increment = (TChart1.Axis.Left.Maximum - TChart1.Axis.Left.Minimum) / 2
  TChart1.Axis.Left.Maximum = TChart1.Axis.Left.Maximum + Increment
  TChart1.Axis.Left.Minimum = TChart1.Axis.Left.Minimum - Increment
  TChart1.Axis.Left.Increment = Increment
End Sub
If that's not what you want, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply