12-20-2011 08:24 AM
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
Solved! Go to Solution.
12-20-2011 08:32 AM
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?
12-21-2011 07:48 AM - edited 12-21-2011 07:50 AM
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. smercurio_fc's suggestion was excellent - I located the referenced code in LV Example finder, in the fundermentals > charts & Graphs > plot images folder.
Attached are 2 pieces of code.
DrawRectangle on Graph.vi allows users to define the rectangle via front panel cluster.
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.
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,
12-23-2011 09:46 AM
Thanks smercurio_fc and RichI
I used smercurio_fc suggestion and part of Rich code to design somthing for my application
I have attached teh Print screen of that part of my code to this post
Many thanks for your help
12-23-2011 01:47 PM
What's the purpose of the FOR loop?