Page 1 of 1

Zoom Custom Axis

Posted: Thu May 12, 2011 3:41 pm
by 16658473
I have read the link refering to zooming custom axes, but i need some help converting the Delphi code to AxtiveX.

My chart has custom left and bottom axes, because I need the relationship to be a 1:1 ratio since I am plotting a gear tooth profile.

I have written the following code, but do not know how to capture the cursor locations for SetMinMax.

Private Sub AxTChart1_OnZoom(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxTChart1.OnZoom
AxTChart1.Axis.Left.SetMinMax()
AxTChart1.Axis.Bottom.SetMinMax()
End Sub

Instead of using the code above, I have modified the routine as follows.

Private Sub AxTChart1_OnZoom(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxTChart1.OnZoom
Dim top As Double

top = AxTChart1.Axis.Left.Minimum + (AxTChart1.Axis.Bottom.Maximum - AxTChart1.Axis.Bottom.Minimum)

AxTChart1.Axis.Left.SetMaximum(top)
End Sub

The proper values are captured for the size of the zoom window, but when I execute it, nothing happens. I tried adding a Refresh to the routine, but that had no affect.

Zooming is allowed on the chart editor.

Thanks,
Mike

Re: Zoom Custom Axis

Posted: Fri May 13, 2011 3:23 pm
by 10050769
Hello MikeK,
Private Sub AxTChart1_OnZoom(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxTChart1.OnZoom
AxTChart1.Axis.Left.SetMinMax()
AxTChart1.Axis.Bottom.SetMinMax()
End Sub
To achieve cursor location you need use Mouse Events for example OnMouseClick or OnMouseDown or OnMouseMove etc.
Instead of using the code above, I have modified the routine as follows.

Private Sub AxTChart1_OnZoom(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxTChart1.OnZoom
Dim top As Double

top = AxTChart1.Axis.Left.Minimum + (AxTChart1.Axis.Bottom.Maximum - AxTChart1.Axis.Bottom.Minimum)

AxTChart1.Axis.Left.SetMaximum(top)
End Sub

The proper values are captured for the size of the zoom window, but when I execute it, nothing happens. I tried adding a Refresh to the routine, but that had no affect.
On the other hand, event OnZoom works fine for me. Please can you arrange a simple project because we can reproduce exactly your problem here?

Thanks,