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
Zoom events
The best way I can think of is creating your custom code to handle the zoom, using something like the following code :
Josep Lluis Jorge
http://support.steema.com
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
http://support.steema.com
How about using the following code ?
Josep Lluis Jorge
http://support.steema.com
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
http://support.steema.com