LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get closest data point on graph with mouse click event

I would like to use an XY graph to plot data.  Then when the user clicks on one of the data points be able to bring data up about the point using the mouse up event.  Has anyone ever tried this?

 

John

0 Kudos
Message 1 of 6
(5,715 Views)

Not exactly the same be here is what I did to place a cursor at the mouse click position (xvalue) in an xy graph.

 

place cursor.PNG

 

 

I first compare the mouse click coordinates with the graph plot bound area the validate that the mouse click is in the plot area of the graph (the false case is empty). The substractions and division are used to convert the mouse click coordinates into graph plot coordinates. Once you have this you can convert these plot coordinates into xy coordinates using proportions and the x and y scales max and min values. When you have the mouse click xy value you just have to measure the distance between this point and all data points to find the closest one.

 

Hope this help.

 

Ben64

Message 2 of 6
(5,703 Views)

Sorry, I wasn't attentive when I read your post so my reply don't really answer your question (but it shows how to get the closest data point).

 

What do you mean exactly by "Bring data up about the point" ?

 

Ben64

0 Kudos
Message 3 of 6
(5,698 Views)

Alot less code to use the plot method map coordinates to XY and then find closedt point, this is a very nice method and saved all the math that had to be done in the past.  You could also lock a cursor to the graph and move the cursor.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 4 of 6
(5,689 Views)

As for the data up about the point, cursor locked to the graph is nice you can change the text of the cursor on mouse move and change the cursor name, format the point info to a string.  There are many other ways to do this.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 5 of 6
(5,688 Views)

@falkpl wrote:

As for the data up about the point, cursor locked to the graph is nice you can change the text of the cursor on mouse move and change the cursor name, format the point info to a string.  There are many other ways to do this.


Smiley Surprised

After those two posts, I am speachless.

 

Spoiler

Not because I am shocked but that was I would have said. Smiley Wink

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(5,684 Views)