From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw line on graph

I want to draw a line on graph using mouse and shall be able to drag and drop anywhere in the graph and if two lines are intersects, I want to read XY values of intersection.
 
How to program it?
0 Kudos
Message 1 of 16
(10,429 Views)
Would a simple cursor do? No programming involved.
Message 2 of 16
(10,423 Views)

Occam would proud of you Dennis!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 16
(10,417 Views)
How cursors can be used?
0 Kudos
Message 4 of 16
(10,412 Views)

"How cursors can be used?"

See here.

Ben

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

Right click on the graph and select Visible Items>Cursor Legend. Right click in the cursor legend and select Create Cursor>Single Plot. The cursor will be locked to the plot and you can drag it whereever you want and the x/y coordinates of the plot will be in the cursor legend.

Ben,

KISS would also be applicable.

 

0 Kudos
Message 6 of 16
(10,395 Views)
with this I can draw only straight lines. I want to draw tangent lines.
0 Kudos
Message 7 of 16
(10,393 Views)

Well, you could have mentioned that in the first place.Smiley Wink

Offhand, I don't know an easy way to draw random lines and have the ability to drag them around. Will have to think about that for a while.

0 Kudos
Message 8 of 16
(10,381 Views)

I'll offer an outine that makes use of cursors just to KISS.

Add four cursors to your graph and label them such that a pair of cursors define a line.

When the cursors move, redraw the lines. (how to draw lines depends on data type of graph but generally this should be a seperate plot for each line).

After re-drawing the lines, do some basic algebra to compute the intersection then update an indicator (or use an anotation) with the new values.

Code as far as you can then post your code along with images of same and someone will give you a push to get you over the hurdle.

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 16
(10,377 Views)
Just use mouse down events, transform the mouse position to plot coordinates, and then draw whatever you want using the "plot images" overlay feature.
 
Here's an old example using an intensity graph, but it works with any other graph (xy, waveform) equally well.
 
 
 
Message 10 of 16
(10,353 Views)