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: 

plotting on xy graph based on mouse coordinates

I am looking into plotting Mouse coordinates on XY Graph continuously based on where i move. My computer's resolution is 1200x800 and i would like it to plot based on where i move.,

Attached is my progress so far.

0 Kudos
Message 1 of 15
(4,526 Views)

The XY Graph has a method which converts coordinates to XY values. You can call it by right clicking the graph and selecting Create>>Invoke Node>>Map Coordinates to XY.

 

However, if you look at the help for it, you will see that the coordinates it expects are those of the pane the graph is in, and the coordinates you have are of the screen. You can convert your global coords to pane coords by getting the VI's Front Panel Window. Panel Bounds property, building two matching XY clusters from the data and subtracting them (assuming the VI only has one pane) or you can use another loop with an event structure and a Mouse Move event (which returns local data) on the graph and then transfer the position data to your loop (you could also use a single loop, but that might be more complicated because the event structure will process every move of the mouse as a new event).

 

You will also need to keep the data to place in the graph somewhere. If you open the context help window and hover over the graph's BD terminal, you will see the data types it expects and you will need to build one of those yourself. A shift register is something you might want to look into. There are also some examples showing working with graphs in the example finder (Help>>Find Examples).


___________________
Try to take over the world!
0 Kudos
Message 2 of 15
(4,519 Views)

Hi! Thanks for your reply. I'm not exactly very good at LabVIEW, don't really understand what you said, would you like to help me to do it. Attached is my VI.

0 Kudos
Message 3 of 15
(4,510 Views)

You're going about it completely the wrong way. You have to understand what the method does, what it expects and what each thing means, so that you know how to put them together. If you don't understand them properly, you will just keep having problems. A good place to start in order to understand something about the function is the context help for it and the detailed help. If that doesn't help, writing a small VI which calls the function and seeing how it behaves can help as well.

 

In this specific case, this is one thing you can do:

 

Coords_to_XY.png

 

The part that's before the loop is described in the previous post and is left as an exercise to you. So is the part of actually building the graph. You might also try looking at some of these tutorials.

 

 


___________________
Try to take over the world!
0 Kudos
Message 4 of 15
(4,493 Views)

I tried out the Front Panel panel board method but i do not know how start because i don't know where to extract/get the bound.

0 Kudos
Message 5 of 15
(4,486 Views)

The Application Control palette has a VI Server reference which defaults to the current VI, but you can also right click a property node to select a specific class from the class hierarchy. If you select the VI class, the property node will act on the VI it's in.


___________________
Try to take over the world!
0 Kudos
Message 6 of 15
(4,481 Views)

Still don't really know what you trying to say about the pane bound property

 

 

But i've tried making it like this but my axis got very very big with autoscale and unable to stop.

 

 

0 Kudos
Message 7 of 15
(4,459 Views)

Anyway, I got up the FP.Panel Bound. But i don't understand your after statement which is to create two seperate XY Cluster than subtracting off.

and how do you connect the panel bounds to the invoke node 's coord

0 Kudos
Message 8 of 15
(4,444 Views)

I think this is what you are referring to right?

0 Kudos
Message 9 of 15
(4,437 Views)

Since I don't have the time, here's the full code:

 

XY_coords.png

 

If you still don't understand the substraction, play with it. Move the window around and see how that affects it (and now that I say that, I see that the code actually has a bug which I will leave to you to find).

 

Working with the event structure would help with all that, because you won't have to do that, but the way you're doing it is wrong, because you will get only one event before the loop executes and you need multiple events.

 

I would suggest again that you go over some more tutorials and examples, because you will have to learn how to do these things yourself.


___________________
Try to take over the world!
0 Kudos
Message 10 of 15
(4,400 Views)