-
May 12th, 2005, 04:16 AM
#1
Getting mouse coordinates in MSChart scale
Hi all,
I have the following problem: I want to show the coordinats of the mouse pointer inside a the plot of an XY MSChart diagram, using its scale. I Used the following code
Code:
Private Sub chart_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xVal As String, yVal As String
With chart.Plot
If X - .LocationRect.min.X >= 0 And _
X - .LocationRect.max.X <= 0 And _
Y - .LocationRect.min.Y >= 0 And _
Y - .LocationRect.max.Y <= 0 Then
'ascissa ed ordinata interne all'area del grafico
xVal = (.Axis(VtChAxisIdX).ValueScale.Maximum - .Axis(VtChAxisIdX).ValueScale.Minimum) * _
(X - .LocationRect.min.X) / (.LocationRect.max.X - .LocationRect.min.X) _
+ .Axis(VtChAxisIdX).ValueScale.Minimum
yVal = (.Axis(VtChAxisIdY).ValueScale.Maximum - .Axis(VtChAxisIdY).ValueScale.Minimum) * _
(Y - .LocationRect.min.Y) / (-.LocationRect.max.Y + .LocationRect.min.Y) _
+ .Axis(VtChAxisIdY).ValueScale.Maximum
Else
xVal = "N.A."
yVal = "N.A."
End If
End With
End Sub
does not work properly, since it introduces approximations. Besides, it is not capable to recognize correctly the condition of mouse pointer out of plot (i.e.: the if clause is wrong). I think that the coordinates of plot area are not given by the LocationRect. Someone can help?
-
December 28th, 2016, 02:16 AM
#2
Re: Getting mouse coordinates in MSChart scale
Hi,
1. You have not accounted for axis area widths when using the plot area to calculate xVal, yVal.
2. You seem to be using yVal wrong. It would be 0 to max : top to bottom !
3. Could you say how to could get 1. above from Code !?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|