LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw a rectangle in a graph

Solved!
Go to solution

Hi I would like to programmatically draw a rectangle in an XY graph (Build XY Graph.vi) . I know where the 4 points are on the graph coordinate but I still can't draw it using the Draw Rectangle block. Would you please help me how can I draw a rectangle in a graph. I ahve attached the picture to this post

0 Kudos
Message 1 of 5
(8,498 Views)

What have you tried? I am assuming you're using the picture functions to draw a picture and write that picture to the one of the graph's PlotImages properties? There's an example that ships with LabVIEW that shows how to draw successive circles on a graph. It's called "Graph Plot Area Images". Have you looked at that?

0 Kudos
Message 2 of 5
(8,495 Views)
Solution
Accepted by topic author ethen99

Hiya Guys,

 

I thought this was an interesting questions - and, although I hadnt tried anything quite like this before, I thought I'd give it a whirl. 

 

Attached are 2 pieces of code. 

 

DrawRectangle on Graph.vi allows users to define the rectangle via front panel cluster.

 

Cluster defined.jpg

 

DrawRectangle on Graph (Events).vi allows the user to define the rectangle by clicking and dragging on the graph. Please note that the code requires you to start from the upper left hand corner of the rectangle, and drag to the bottom right hand corner. But, this is nothing some creative logic wouldnt solve - if you wanted the code a little more flexible.

 

User Defined.jpg

 

Please also be aware that I have not spent much time on the code, so it is not perfectly architected. But it should be food for thought!

 

Best wishes,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Download All
Message 3 of 5
(8,465 Views)

Thanks

0 Kudos
Message 4 of 5
(8,417 Views)

What's the purpose of the FOR loop?

0 Kudos
Message 5 of 5
(8,403 Views)