From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clear plot legend on a Graph

I have a graph that I am using to display multiple TDMS file. If a user clicks on a file path in a tree then the TDMS file is loaded and the data is displayed. I know that I can clear previous data by setting Value to an empty array. If a user clicks on 10 different files then the graph legend get really junked up with old plot information.

 

Another solution is to reinitialize the graph. That does not clear the graph legend either.

 

Screenshot_5.png

 

How can I clear out the data for the plot legend and start over?

0 Kudos
Message 1 of 5
(2,386 Views)

You have full control over any plot legend via property nodes. Unfortunately, your description is not sufficient to really troubleshoot further. Please show us your VI so we can give more targeted advice.

 

Maybe, instead of filling stale plots with empty arrays and appending new ones at the bottom, you could replace a certain existing plot with new data&legend.

0 Kudos
Message 2 of 5
(2,381 Views)

I don't see any property that is an array of legend items -or- a method that allows one to delete legend items.

 

Follow observation - If I refill the existing legend elements with new data what about the case where I have 20 elements in the legend and my new data has one? Now I have nineteen empty legend elements to confuse the end user.

 

My use case. I need to fill data over and over in a graph. The data may have identical channel names or may have completely different set of channel names. Some of the data will come from functions like limit testing where the data is either exceeding the specified limit or inside specified limits. 

 

Here was my closest attempt. The "LegNumRows" controls how many rows are visible at one time. "LegPlotMin" acts more like a maximum. In the case below after setting LegPlotMin to one and then to four did not get rid of the data, the data in indices 1-3 was still there.

Screenshot_6.png

Images of the properties that I can see for legends:

 

Screenshot_7.png

 

I can see how to iterate legend elements but do not see a way to delete elements in a legend.

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

Your code images are completely useless to troubleshoot the problem, except that we can tell that the code quality is probably not great. (Sequence structure overuse, writing the same properties in almost instant succession with different values, value property nodes, three instances of the same reference, etc. etc. just don't make a lot of sense).

 

You are NOT rewriting the legends, just telling it how many legends you want to display and which legend should be visible on top (by scrolling the legend).

 

The datatype of the "value" is probably an array of clusters, one for each plot. Each plot has a name. Once you manipulate the array (add or remove plots in the desired positions) just iterate over the legends and rewrite those too accordingly. 

0 Kudos
Message 4 of 5
(2,340 Views)

@flycast wrote:

I don't see any property that is an array of legend items -or- a method that allows one to delete legend items.

.


Keep track of all legends in a shift register as an array of strings, manipulate this array according to the data change, then rewrite all legends (pad with empty string if needed).

 

altenbach_0-1607902247708.png

 

0 Kudos
Message 5 of 5
(2,336 Views)