LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove a plot and resize the plot legend in LV 8.6 as in this link to a LV 7.0 example

Solved!
Go to solution

This VI ( ftp://ftp.ni.com/pub/devzone/epd/201150.vi ) works exactly as I want an 8.6 application to - but the property node used in the example is no longer supported.

I can add/remove plots and resize the plot legend with 8.6 using the "LegNumRows" property however this property does not appear to behave the same way.

It seems this should be straight forward but I must be missing something.

 

 

0 Kudos
Message 1 of 13
(4,901 Views)

Calvus wrote:

... however this property does not appear to behave the same way.


 

 Could you explain in what way "LegNumRows" does not behave like "LegPlots"?

0 Kudos
Message 2 of 13
(4,888 Views)

Thank you for your reply.

The example in the link shows the legend resize to contain only the plots selected by the front panel control. For example, the user selects all three waveforms using the boolean controls and all three waveforms are displayed in the legend.

If the user then deselects plot 1 in the middle position the legend will resize and to show plot 0 in its original position and bumps plot 2 to the position previously occupied by plot 1 and the legend resizes to show 2 rows.

The "LegNumRows" properties does not appear to do this, instead it just changes the number of rows and continues to display plot 0 and the original plot 1 while plot 2 is simply hidden from view with no "shuffling" of the plot order.

Also, I am trying to implement this behavior on a an XY graph after the data has been calculated and displayed - instead of a chart capturing live data.

 

Reagrds

0 Kudos
Message 3 of 13
(4,870 Views)

Calvus wrote:

The "LegNumRows" properties does not appear to do this, instead it just changes the number of rows and continues to display plot 0 and the original plot 1 while plot 2 is simply hidden from view with no "shuffling" of the plot order.


I have tried in 8.6 and here both properties act the same and exactly as you expect. Strange....

0 Kudos
Message 4 of 13
(4,858 Views)

Hi,

I have attached the original example VI (201150.vi) as well as a modified version of the same VI that uses a multi-plot XY graph (201150 - mod.vi)

The modified VI behaves as desired in regards to its behavior when adding and removing plots from the graph however the legend does not behave as desired.

I want the legend to contain the names of the plots displayed on the graph as in the original, instead it appears to simply remove the last plot name from the legend.

 

Regards

Download All
0 Kudos
Message 5 of 13
(4,831 Views)

The difference has to do with the fact that the original VI uses dynamic data and thus knows the name of each dataset that is graphed. You are using plain clusters, so LabVIEW cannot know the names of the signals. You need to write the plot names whenever the number of plots changes.

 

(btw, the property node is shared between twe two cases of the case structure and thus belongs outside. (actually, it should go in a seperate case that only activates when the inputs change so you're not constantly writing the same properties over and over with every iteration of the loop.)

Message 6 of 13
(4,826 Views)
Solution
Accepted by topic author Calvus

Thanks for confirming that this property does not function the same way as the example does when used with an XY graph with clusters and non-dynamic data.

I left the property node in the case structure (just as it was in the original example) so as not to muddy the waters too much when you went to compare the two examples - my application does not do this for the reasons you have stated.

I will implement a legend handler to keep track of the plots in the legend.

 

Thanks for the sanity check!

 

0 Kudos
Message 7 of 13
(4,811 Views)

So, in summary, "LegNumRows" and "LegPlots" behave identically. The difference originated elsewhere. 😄

 

Here's a simple rewrite how you could handle the names. (Of course, it only shows the mechanics. You should probably handle it in a parallel event loop so it only happens whe things actually change).

 

 

0 Kudos
Message 8 of 13
(4,802 Views)

Hi again!

I have implemented a method to shuffle the plots in the legend and was satisfied with one exception- the plot colors. This application allows the user to add or delete plots from the graph, adding a plot is easy as the new plot name gets appended to the next place on the legend and the number of rows grows by one. Deleting a plot is also quite easy but this action brought up a usability issue in that the existing plots that were shuffled on the legend would also shift their colorsaccordingly. To eliminate possible confusion I want to keep the correlation between existing plots and their assigned colors so I tried to use the plot color property to change the plot color programmatically with unexpected results.

 

Programmatically changing a color from the "Plot Colors" array does not change the color of that plot if it is set to any of the "Common Plots" wih the exception of "Common Plot 0" - i.e. this doesn't seem to work for Bar Plots which is what I am using.

I have attached a demo VI to illustrate this behavior - there are detailed free labels on the front panel which describe this in more detail.

 

Regards and thank's in advance!

 

0 Kudos
Message 9 of 13
(4,655 Views)

For the other types of plots in XY 2 (Plots 0, 1, and 2) it looks like you should be writing to the plot.fill/point color property as opposed to the plot.color property.

 

I'm still not sure why XY graph1 behaves differently.

0 Kudos
Message 10 of 13
(4,644 Views)