LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interactively changing Point Style on XY Chart

I do not understand exactly how the Property "ActPlot" works…  I have an XY chart that contains at any one time anywhere from 1 to 4 plots of data (amplitude versus time for each plot).  Each possible plot has a unique color (red, blue, green or yellow)…  And it can be that only, say for example, the green plot is on by itself.  Or perhaps the blue and the yellow are on at the same time but not the other two…  And if blue and yellow are on, it might be that blue came on first followed by yellow or it might be the other way around....  And so forth…  Sometimes two plots might be displaying exactly the same data such that one plot will be hidden beneath another…  For that reason, the customer wants to be able to push a button (T/F) on and off and on and off that will toggle the "Point Style" for any one of the plots just so a hidden plot would be able to be seen.  He does not want to do this point style toggling from the chart legend but instead wants to be able to do it with a button (one of four buttons, one for each possible colored plot).  

 

So I have four buttons that are each colored red, blue, green and yellow.  (But note that the button color is only intended to indicate that that particular button is used to go hunting for the similarly colored plot but that otherwise the button and the chart have no other knowledge of each other, ie., the button was not in any way derived from the XY chart).  I know precisely the digital number that represents the four plot colors.  What I want to have happen is that when I push a given button, that will trigger a front panel event that then goes to an event frame and changes a point style number going to a point style property node for a specific (same colored) chart.  But the question is how to determine which plot is the correct plot on which to change the point style???

 

 My approach was to do the following…  Since I know which button I pushed, say for example the green button, I know I am searching for the current plot that is the same color, green, and as I said, I know the digital number for that green plot.  So i wrote a FOR loop to run 4 times, each time putting first 0 and then 1 (and then 2 and then 3) into the "ActPlot" property to momentarily SET that plot as the Active Plot.  I then read back the Color of that same plot.  I am expecting to find at most one of the four possibilities actually being that green number and if that worked, I would then know which plot was green.  I could then again make that plot the Active Plot and this time change its Point Style property to see the plot's point style toggle while I pushed the button on and off…

 

But it doesn't work..  In one recent attempt, I had both a Blue and a Yellow plot displayed.  I then looked to see what the For Loop returned and it returned the GREEN color THREE times and the Yellow color once…  No blue at all…  When I set the ActPlot to 0, 1 or 3 querying the Color property gave GREEN each time and when I set the ActPlot to 2, the Color property gave Yellow…  

 

That tells me I just don't understand how ActPlot works…  This has been sort of a hard problem to describe so perhaps no one will understand what I'm saying but if you do and if you have any ideas, please toss them out…  But perhaps more important is to simply abandon the ActPlot idea and ask if anyone can suggest a method whereby I can use a button that is, in essence, unrelated to the XY chart to be able to toggle the point style of one, unique plot (out of four) on the XY chart itself…  And using the Chart Legend itself as a place from which to change a plots point style is NOT an option…  

 

Any ideas????  Any help would be much appreciated… thanks…  bob... 

0 Kudos
Message 1 of 5
(3,823 Views)

Paris,

 

Can you please post the code?  Thanks, Matt

0 Kudos
Message 2 of 5
(3,805 Views)

Hey Bob,

 

that was a long explanation, but I think I got a simple demo for you that will let you use boolean buttons to control appearance of multiple traces on the chart.  This demo changes line width, and of course, you can change any other properties of your choice the same way.

One thing you need to remember: if you want same data always appear  on the same trace, that data must be placed at the same index in 2D array. For instance, my demo has four 1D arrays feeding the 2D array and element at index 2 is a green trace. If I remove arrays 0 and 1, my green data will shift and appear white. To avoid this shift you would always need to have arrays at indexes 0 and 1 connected to 2D array and they need to be initialized to have at least one valid point.

Serge 

Message 3 of 5
(3,802 Views)

Wouldn't it be more simple to allow the user to choose which plots are seen and which are not? Something like this:

Plots.png

 

In this example the red and the green plots are indicating the same value, therefore the "user" has decided to set one of the plots he does not want to see as invisible. In this case it is the green plot.

 

Plots front.jpg

 

P.S. I have used Waveform Chart in this example, but using XY Graph would involve just the same Porperty Nodes, I believe.

 

Edit: The VI Snippet tool has "hiden" the numbers to set the active plots because of the WFChrt reference it has automatically added. But the red plot is the no. 0, green - no. 1, blue - no. 2 and yellow - no. 3. So you would have to wire these constants to their input terminals.

Message Edited by Giedrius.S on 02-05-2010 09:11 PM
Message Edited by Giedrius.S on 02-05-2010 09:13 PM
Message Edited by Giedrius.S on 02-05-2010 09:15 PM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
Message 4 of 5
(3,801 Views)

I do appreciate all the quick responses and help...  The idea I had which was to first use plot color to determine ActPlot number and then use ActPlot number to then change the point style settings for that particular plot actually does work...  I went back and examined my code more carefully and found I had made a simple coding error...  Once I fixed that, the approach I had started with worked just fine...  Again, thanks for the help and suggestions...

 

bob... 

0 Kudos
Message 5 of 5
(3,776 Views)