LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set cursor to a plotted point

Hi everybody,

here is what I wanted to do but I have no idea how to:
I have an XYGraph with a lot of data point inside (they all belong to one plot).
Now I want to click at one of the points to select it.

Of course, I have to use a cursor. All what I could do is dragging the cursor (snapped to the plot) around but I want to do this by a click and the cursor should
go to the point.
Is there no simple way?

Thanks for help.
Ronny
0 Kudos
Message 1 of 5
(3,059 Views)
Here is a solution :
- detect the click position using an event structure,
- calculate the corresponding coordinates (a "tricky" step, where you need to play with the X and Y scale positions...),
- move the cursor to the nearest graphed point (snap-to-point mode).
 
A better positionning can be obtained using the marker coordinates to get a better definition of the plot area origin, but this is not usually required.
 
Enjoy...
 
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 5
(3,052 Views)
Simple?  I can't think of a way.
But you COULD do it.

You would have to have an event structure with an event of MOUSE DOWN in the graph.
You would have to translate the X&Y mouse coordinates in the event to your scaled X and Y.
You would have to search through your plotted data to find the closest X and Y points.
You then set the cursor position (via properties) to that X and Y.

There are some UI issues, though.
The mouse coordinates you get are panel-referenced - you need to subtract the graph position from them to make them graph-referenced.
You'll need to figure out what "closest" really means.  If it's minimum distance, you'll have to figure the distance from your mouse X&Y to EACH point in your data [distance = sqrt((X1-X0)^2 + (Y1-Y0)^2) ]
You have to figure what happens if two points are in the same X-Y location?  That's possible in an X-Y graph.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

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


CoastalMaineBird a écrit:
...You would have to search through your plotted data to find the closest X and Y points...
...You'll need to figure out what "closest" really means.  If it's minimum distance, you'll have to figure the distance from your mouse X&Y to EACH point in your data [distance = sqrt((X1-X0)^2 + (Y1-Y0)^2)

Fortunately, this step is not required since the snap-to-point property do all the calculations for us.

So we can concentrate on the other difficulty that is to spot one of the corners of the graph plot area. In the example I attached, there is a problem when the X scale values are several digit wide.

Chilly Charly    (aka CC)
0 Kudos
Message 4 of 5
(3,050 Views)
Improved...
Chilly Charly    (aka CC)
0 Kudos
Message 5 of 5
(3,045 Views)