LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enable/disable plots on a chart when application is running

Solved!
Go to solution

Hi,

 

I am trying to figure out how to make a chart which allows the user to select which items are plotted while the application is running.  I would like all of the data to be displayed on the same chart with the same x and y axes and maybe some checked boxes or something to easily allow which items are being displayed.

 

Thanks,

Gary 

0 Kudos
Message 1 of 5
(5,251 Views)

In my case, I have a max of 6 plots.

I show the plot legend, which shows the colors and styles of each plot.

 Next to the legend I have a cluster of 6 checkboxes, arranged to line up with the legend.

I have an event structure set to respond to the checkbox cluster when its VALUE CHANGED.

 When the event fires, I turn the cluster into an array of 6 BOOLEANS (use CLUSTER TO ARRAY function).

Then for each element in that array:

   Set the ACTPLOT property of the chart to i (the loop index counter), and

   Set the PLOT VISIBLE property of the chart to the value of the checkbox.

 

The ACTPLOT (Active Plot) property tells the property node that the next item(s) will refer to a particular plot. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 5
(5,244 Views)

Thank you for the suggestions.  I made a new VI to try to implement your suggestions and I cannot figure the appropriate timeout needed for the event structure.  If I set the timeout to 1000 ms, the graphing portion is delayed too much.  If I set the timeout to 250 ms, the event change does not seem to be detected.  Also I  do not know if I have the property nodes configured properly.  When the event changes for 1 of the 2 checked boxes, it was disabling both of the plots. 

 

Attached is the VI that I made to implement your suggestions.  If you could look at it and tell me how to improve it, that would be great.

 

Thanks,

Gary 

0 Kudos
Message 3 of 5
(5,228 Views)
Solution
Accepted by topic author glstill

1... Don't use two separate property nodes for setting ACT PLOT and PLOT VISIBLE.  If you do that, you don't know which will execute first - they're unrelated.  Use a single property node (stretch it to include two properties).  The top property should be ACTPLOT, the 2nd one should be PLOT VISIBLE.  That way, it's guaranteed to execute in the order you need.

 

2... You are reading the checkbox cluster ONCE at the start of the program, and using that same value every time.  You want to read the cluster WHEN THE CHANGE EVENT occurs, i.e., within the EVENT case.  You can read the terminal, or read the NEW VALUE property of the event, either way is OK.  But you have to read the new value, not the old one.

 

3... You are also reading your knobs ONCE at the start of the program, and re-plotting the same value every time you plot. You need to figure out when you should plot them, THEN read them and drive the chart.

 

4... If you set the timeout to, say, 100 mSec, and in the TIMEOUT event, read the knobs, and drive the chart, then you will have a live chart that updates roughly every 100 mSec.  Implement #1 and #2, and you can turn the plots on and off.

 

I say "Roughly" because of the way the timeout works - if you wait 99 mSec and then click a checkbox, the checkbox handler wins, and the 100mSec timer STARTS OVER when you get to the next iteration.

 

If you want the chart to update exactly every 100 mSec then use a separate WHILE loop, with a WAIT TIL NEXT MSEC MULTIPLE.  Do the wait, read the knobs, drive the chart, and repeat.  A separate loop will not be disturbed by events in the UI loop.

Message Edited by CoastalMaineBird on 08-15-2008 09:18 AM
Message Edited by CoastalMaineBird on 08-15-2008 09:21 AM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 4 of 5
(5,223 Views)

It works great!  Thank you very much.

 

Sincerely,

Gary 

0 Kudos
Message 5 of 5
(5,213 Views)