I am attempting to get the mouse coordinates on a MouseDown event. I want the coordinates to be in the same scale as the X and Y axis, so that if i have a graph from 0-1 in both X and Y, clicking the top right quadrant will result in a coordinate of roughly (0.75, 0.75).
How can I accomplish this?
Alternatively, I would like to get the screen coordinates of a single data point on the chart.
In the end, what I am trying to do is "Select" the nearest point to where a user clicks their mouse, but i need to know either where the point is drawn on the screen, or at least on the chart, or where the mouse is clicked with regards to the data values.
thanks in advance!
Hi,
This should help you, but you will have to adjust the axis types if you are using a scatter series, at it appears:
http://community.infragistics.com/forums/p/50226/264216.aspx#264216
-Graham
Any ideas on how to do the alternative? I realized that this works great as long as the X and Y axis are the same length, but if X is say 0-5 and Y is 0-500, then too much emphasis is put on Y. So it would be much better if i could get the screen location of a point in a ScatterSeries.
I thought your goal was to get the coordinates in terms of the axis values?
e.GetPosition is getting the position in terms of the position of the mouse over the chart. The calls to GetUnscaledValue are translating those coordinates into the values of the axes that would cause a point to be plotted at that location.
If you just want the relative position of the mouse over the chart you could just use e.GetPosition() and divide it by the total dimensions of the chart. But I'm not sure why you would rather this than the axis based coordinates?
What's your goal with this functionality? What kind of effect are you trying to produce?
I thought that was what i wanted, until i put it into my code and realized that it wasn't working quite how i wanted.
My final goal is i want to be able to click on a chart, and then change a property of the marker that is closest to where i clicked in screen coordinates, a property such as size, or visibility.
In this vain, what i need to be able to get is the screen coordinates of where a marker is drawn, so that i can figure out which marker is the closest to where i clicked on the screen.
The reason the first method doesn't work is because a lot of times the X and Y axis' aren't on the same scale, so one may be from 0-5, and the other will be from 0-500, meaning a change on the 0-5 axis isn't noticed in a distance (pythagoras) calculation.
Does this help?
http://community.infragistics.com/forums/p/49255/260628.aspx#260628
I believe that will work, it will take some finagling on my part to get it to do exactly what i want, but that's what i needed.
Thanks for your help Graham!!
Not a problem, let me know if you have any other questions.
for reference, i actually found a much simpler method, since i know the data values of my points, i can use xAxis.GetScaledValue in asimilar way to xAxis.GetUnscaledValue in order to go the opposite direction