LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cursor movement with snap to nearest data

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(3,366 Views)
Solution
Accepted by topic author onrb

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.

0 Kudos
Message 2 of 5
(3,354 Views)

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.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 3 of 5
(3,353 Views)

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.

 

Download All
0 Kudos
Message 4 of 5
(3,348 Views)

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.

0 Kudos
Message 5 of 5
(3,338 Views)