Coordinate of the mouse pointer in chart object client coordinates

Hello, I am writing the code in order to be able to zoom on chart. It is supposed to change axis scales in order to display only selected area.

So the aim is to get new X and Y axes min and max coordinates. But the coordinates don't make sense. I think it is because the chart object client coordinates units are not points. So please do you have any ideas

this is the code:

Private Sub Chart_MouseDown(ByVal Button As Long, _
ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)

If Shift = 2 And Button = 1 Then
ActiveChart.Deselect
firstX = X
firstY = Y
End If
End Sub

Private Sub Chart_MouseUp(ByVal Button As Long, _
ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)

If Shift = 2 And Button = 1 Then
lastX = X
lastY = Y
ActiveChart.Deselect

intOldMinX = ActiveChart.Axes(xlCategory).MinimumScale
intOldMaxX = ActiveChart.Axes(xlCategory).MaximumScale

intOldMinY = ActiveChart.Axes(xlValue).MinimumScale
intOldMaxY = ActiveChart.Axes(xlValue).MaximumScale

intFirstXAxis = Int((intOldMaxX - intOldMinX) * (firstX - ActiveChart.Axes(xlCategory).Left) / ActiveChart.Axes(xlCategory).Width)
intLastXAxis = Int((intOldMaxX - intOldMinX) * (lastX - ActiveChart.Axes(xlCategory).Left) / ActiveChart.Axes(xlCategory).Width)

intFirstYAxis = Int((intOldMaxY - intOldMinY) * (1 - (firstY - ActiveChart.Axes(xlValue).Top) / ActiveChart.Axes(xlValue).Height))
intLastYAxis = Int((intOldMaxY - intOldMinY) * (1 - (lastY - ActiveChart.Axes(xlValue).Top) / ActiveChart.Axes(xlValue).Height))
End If

End Sub



Answer this question

Coordinate of the mouse pointer in chart object client coordinates