Jump to content
Software FX Community

Mouse Position


Recommended Posts

Hey there,


I am trying to read mouse position relative to plot area (so X represents the value on the XAxis over which mouse is currently hovering over). I managed to get it right using histTest for MouseDown event like this:

HitTestResults hitTest = chart1.HitTest(e.GetPosition(chart1));if (!hitTest.IsInsidePlotArea) return null;

Axis xAxis = chart1.AxisX;Axis yAxis = chart1.AxisY;

double X = xAxis.PixelToValue(hitTest.PositionRelativeToPlotArea.X);double Y = yAxis.PixelToValue(hitTest.PositionRelativeToPlotArea.Y);

return new NumberDataPoint(X, Y);

But the above does not work for Mouse up event (values of X Y are just stupid). Any idea how I can get those values?

Link to comment
Share on other sites

Have you compared the point you are passing to the HitTest methods as well as the PositionRelativeToPlotArea value between the mouse down and mouse up position (assuming you are not dragging the mouse)?

If the chart has not changed I am not sure how subsequent calls with the same value would not return the same PositionRelativeToPlotArea and in turn the same X/Y values.

Have you tried also calling this (for testing purposes) on your MouseMove event?


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...