10-01-2009 12:12 AM
I would like to have a SINGLE cursor snap to the closest data point to the mouse cursor on an XY graph when mouse:down.
The cursor action requires dragging. Any way to have the cursor snap to the closest data point (closeset in euclidian pixal units) to the mouse location without dragging?
I've tried to extract the mouse coordinates and then search through a list of XY graph coordinates converted to pixel coordinates. It seems like the mapping of graph coordinates to pixel coordinates is inconsistent with changes in text and other features outside the graph area.
Useful features
1. output XY coordinates of at least one corner of the graph (inside where the data is) area.
2. An index to the closest data point in the graph where the mouse is located.
3. An option for a cursor to snap to the closest data point where the mouse is located while mouse:down.
Any workarounds (example VIs) are greatly appreciated.
Solved! Go to Solution.
10-01-2009 01:08 AM
Just solved it. I was using a code snippit from someone, but it had incorrectly used the frame coordinates rather than graph. Now I can do exacly what I was looking for. I'll post the VI after cleaning a little more.
10-01-2009 01:09 AM
Hi there
Take a look at the "Map ccords to xy" method of the xy graph. this deliveres you the correct xy coordinates to a pixel inside the xy area.
10-01-2009 02:30 AM
Here is some code attached which is hopefully useful to others.
The incorrect graph coordinates I referred to earlier was in an NI example "Draw Graph with Events". Maybe NI can fix in the next release? (Not the best example of how to do things correctly....).
have fun.
10-01-2009 03:05 AM
Thanks!
I've updated the code with this method. Very nice indeed. I need to look into methods more. I just learned about queues and state machines in LV. A much cleaner way to implement complex systems. All sorts of things added in the last 15 years when I last used LV.