Page 1 of 1

Zoom events

Posted: Mon Dec 01, 2003 10:00 am
by 9079002
Hello !

I need to handle the zoom events myself, that is I want 1) zoom the chart on the selected region BUT using some limits. For example, if the rectangle starts at 31.2, I want to zoom to 30. 2) I want to refresh other charts to the same limits.

So what is the best way to handle this ?? Do I need to handle all mouse down, mouse up and mouse move events and display myself the 'zooming rectangle'. Or is it a way to know, before the chart is zoomed, the position of the rectangle then disable the automatic zooming and make my own zoom ??

Thanks

Posted: Mon Dec 01, 2003 11:38 am
by Pep
The best way I can think of is creating your custom code to handle the zoom, using something like the following code :

Code: Select all


Dim DownX, DownY, MoveX, MoveY, UpY, UpX, Go
Private Sub Form_Load()
With TChart1
    .AddSeries scLine
    .Series(0).FillSampleValues 100
    .Zoom.Enable = False
End With
End Sub

Private Sub TChart1_OnAfterDraw()
With TChart1
    If Go = True Then
        .Canvas.MoveTo DownX, DownY
        .Canvas.LineTo MoveX, DownY
        .Canvas.LineTo MoveX, MoveY
        .Canvas.LineTo DownX, MoveY
        .Canvas.LineTo DownX, DownY
    End If
End With
End Sub

 
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
DownX = X
DownY = Y
Go = True
End Sub

 
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
MoveX = X
MoveY = Y
TChart1.Repaint
End Sub

 

Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
With TChart1
    If Go = True Then
        UpX = X
        UpY = Y
        If DownY > UpY Then
            .Axis.Left.SetMinMax .Series(0).YScreenToValue(DownY), .Series(0).YScreenToValue(UpY)
        Else
            .Axis.Left.SetMinMax .Series(0).YScreenToValue(UpY), .Series(0).YScreenToValue(DownY)
        End If
        If DownX > UpX Then
            .Axis.Bottom.SetMinMax .Series(0).XScreenToValue(UpX), .Series(0).XScreenToValue(DownX)
        Else
            .Axis.Bottom.SetMinMax .Series(0).XScreenToValue(DownX), .Series(0).XScreenToValue(UpX)
        End If
        Go = False
    End If
End With
End Sub

Josep Lluis Jorge
http://support.steema.com

Posted: Mon Dec 01, 2003 12:12 pm
by 9079002
Ok, I will try this ;-)

Thanks

Posted: Mon Dec 01, 2003 1:36 pm
by 9079002
Ok, so that works fine :-) !

But I have a little question: I want my zooming rectangle to be clipped inside the plotting region (so I don't want to zoom on the legend for example, that make no sense :D ).

Any idea how to retrieve the coordinates of this region ??
Thanks

Posted: Mon Dec 01, 2003 11:15 pm
by Pep
How about using the following code ?

Code: Select all

Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
With TChart1
If .Series(0).XScreenToValue(X) > .Axis.Bottom.Minimum And .Series(0).XScreenToValue(X) < .Axis.Bottom.Maximum And _
.Series(0).YScreenToValue(Y) > .Axis.Left.Minimum And .Series(0).YScreenToValue(Y) < .Axis.Left.Maximum Then
    DownX = X
    DownY = Y
    Go = True
End If
End With
End Sub
Josep Lluis Jorge
http://support.steema.com

Posted: Tue Dec 02, 2003 9:01 am
by 9079002
That must be a possible solution :D ! I will try it !!

Thanks