LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY graph, can it return the plot under the mouse?

Hello All

How to get a plot number, which lies in the closness of the mouse cursor?

Lets assume we have three lines in the XY Graph numbered as Plot1, plot2 and plot3. When I press somewhere in their close vicinity, how to get information which line lies the closest.

thanks
Pawel
0 Kudos
Message 1 of 7
(3,195 Views)
One way to do it is to create a cursor for each plot and turn on "Snap to plot", but this requires you click, hold and drag the cursor.

Another way it to monitor the mouse movement, obtain the size of the drawing area and calculate the x position, and then index the values out from your data.
Check out the example VI: Draw Graph with Events.vi.

Joe
0 Kudos
Message 2 of 7
(3,195 Views)
Hi Joe
Snap to plot will not work, since you need to place the mose close to the cursor.
Getting the mouse position is also tricky, since the procedure must work also between two data points, which are automatically connected with the line by the graph itself. Then I need to do the interpolation, etc. I though there is a nice feature of XY graph.

thanks anyway.
Pawel
0 Kudos
Message 3 of 7
(3,195 Views)
Pawel,

Take a look at the attached VI that I created as a follow up to Joe's great posting.

In the VI I take advantage of the example and then I calculate which plot is closest to the mouse click. One caveat is that the SubVI "Scale Values.vi" uses some numeric constants that will change when you convert this VI over to use your graph. Therefore you may need to play with the values.

Evan
National Instruments
Message 4 of 7
(3,195 Views)
Hallo Evan

Thank you for the example. It works very nice.
I was thinking if that would be a good idea to implement this "close plot" as a standard feature of a Graph. It could be in place where you select a method for a cursor behaviour. One of them could be something like: "search for point", or "pick closest" :).

regards
Pawel
0 Kudos
Message 5 of 7
(3,195 Views)
Pawel,

I am glad the example helped.

I was going to submit the suggestion for you but I thought it may be more useful for everyone on the forums if I pointed out where customers can make suggestions direct to NI.

If you click on the "Contact NI" tab at the top of the web page and then select the "feedback" hyperlink you can submit Product Suggestions such as this.

Evan
National Instruments
0 Kudos
Message 6 of 7
(3,195 Views)
Hello Evan

Thanks for the info. I think I will do this.
Actually, I think that Ni should do something about XY Graph.

Maybe something like it is in Matlab. When you click on the graph you should get kind of handler to the object you have beneath. That works like this in matlab and frankly, for a user interaction is a perfect way. Because not only plots han be returned, but also text boxes, graphical (raster) objects, etc.

kind regards
Pawel
0 Kudos
Message 7 of 7
(3,195 Views)