Zoom events

TeeChart for ActiveX, COM and ASP
Post Reply
Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Zoom events

Post by Ced » Mon Dec 01, 2003 10:00 am

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

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 01, 2003 11:38 am

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

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Mon Dec 01, 2003 12:12 pm

Ok, I will try this ;-)

Thanks

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Mon Dec 01, 2003 1:36 pm

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

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 01, 2003 11:15 pm

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

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Tue Dec 02, 2003 9:01 am

That must be a possible solution :D ! I will try it !!

Thanks

Post Reply