LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing entries from an XY Graph Legend

I'm working on a program for plotting data after it's been acquired.  I'm allowing up to 4 plots on the same screen (see screenshot 1) and don't want to have a legend attached to each plot. 

 

My solution is basically what DIAdem does: double click on a graph and it will bring up the legend for that plot  (screenshot 2).  I implemented this by having an XY graph in a subvi, then grabbing the "Plot Attribute Change" event and updating the original graph.

 

My issue comes when I have a large number of plots on one graph and a small number on another.  The moment I "copy" the legend from the original plot to the legend plot, it creates a large number of plots.  When I then go back to an original plot that has a single waveform on it, the number of entries in the legend plot is still big.  It will only expand and I can't find a way to actually remove entries.

 

To my knowledge there is no way to do this.  I'm hoping someone will have a "hackey" workaround or something.  It isn't mandatory and I can do things like set all of the Plot.Name to empty string, and Plot.Visible to False for unused plots, but I'd like a way to actually shrink that array.

 

Forgive the unfinished GUI.  It's still a work in progress and pretty early in it 🙂

image.pngimage.png

 

0 Kudos
Message 1 of 11
(3,692 Views)

Hi Bowen,

 

why do you rely on reading properties of some frontpanel elements instead of keeping that information in a storage of your own (like a FGV)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,684 Views)

@GerdW wrote:

Hi Bowen,

 

why do you rely on reading properties of some frontpanel elements instead of keeping that information in a storage of your own (like a FGV)?


I assume you are saying "Store all of your properties in a FGV and then use that instead of the Plot Legend".

 

The biggest issue with that is it is time consuming.  Not writing the FGV - that part is easy.  But designing a GUI to replicate all of the functionality of the plot legend is cumbersome...  especially since one already exists.  Given the choice between trying to design a GUI that is as clean as what the legend offers and just dealing with the idiosyncrasies of the plot legend, I'll chose to just just deal with the legend as it stands.

 


 

On the other hand if you are saying "why read the properties every time instead of store the properties in a FGV" the answer is:  storing them in an FGV buys me nothing.  If I was reading the properties constantly in a loop or something - yes storing them separate might make sense.  But the overhead associated with the read is trivial since it is occurring rarely.  And even then I'd need to write them all back to the UI element at the end anyway.  Now I'm duplicating all of the properties in memory: once on the actual control, and once in the FGV.

0 Kudos
Message 3 of 11
(3,668 Views)

I'm not 100% sure I'm following you but I'll make a stab at it. Are you saying that the subVI's plot "retains" the number of elements when you're looking at big plots instead of little ones?

 

If so, could you dynamically launch the subVI each time it's called, such that it doesn't maintain state between calls? You might be able to try running calling the "Reinit Values to Default" property node on the block diagram before displaying the screen.

 

Just so I understand what you're doing, you have (say) 20 data sources and 4 plots, and you can plot any 4 of those 100 on each of the 4 plots. Is that right? Or does each of the 4 plots have its own "pool" of data sources it's able to plot from?

 

Edit: I just noticed the dropdown box in the popup to select a graph. Is the issue happening when you change the dropdown or when you close/reopen the popup subVI? If it's happening in the dropdown, you could still use multiple subVI's called independently and just have the dropdown switch which plot window is displayed in a subpanel under the dropdown.

0 Kudos
Message 4 of 11
(3,656 Views)

"I'm not 100% sure I'm following you but I'll make a stab at it. Are you saying that the subVI's plot "retains" the number of elements when you're looking at big plots instead of little ones?"


Yes.

 

"If so, could you dynamically launch the subVI each time it's called, such that it doesn't maintain state between calls? "

 

Theoretically, I could set the subVI to be preallocated clone execution mode.  I haven't tested it, but I suspect because the clone is preallocated and I only want to have one instance running ever that it would have the same problem.  Also if you look at the screenshot, you'll notice I have the ability to change graphs from that GUI.  Finally, it would only solve half of the problem!  If my user looks at 60 plots on "Graph 1", then clears it ... graph 1 now thinks it has 60 plots.  So each time the subVI was launched it would have the same problem.

 

"You might be able to try running calling the "Reinit Values to Default" property node on the block diagram before displaying the screen."

 

There is no combination of property or method calls I could find that would do what I need.  This includes "reinitialize to default value" method.

 

Edit:  Forgot to respond to your last question.

 

"Just so I understand what you're doing, you have (say) 20 data sources and 4 plots, and you can plot any 4 of those 100 on each of the 4 plots. Is that right? Or does each of the 4 plots have its own "pool" of data sources it's able to plot from?"

 

Plots share a pool. This is so the user can group "like" plots together on a single graph to generate reports and analyze the data.  For example, Graph 1 could be all temperature, Graph 2 could be all pressures, etc.  There will be the option to save/load templates as well.  The total project is expected to have ~300 waveforms that can be viewed.

0 Kudos
Message 5 of 11
(3,651 Views)

Yeah I noticed your dropdown after I posted and edited my reply. I see how my original thought wouldn't work.

 

Could you do a similar trick with multiple clones being launched, then swapped in and out in a subpanel on your popup window? You could auto-launch a bunch of clones every time you popped up the window. (By the way, MGI's Panel Manager might be helpful for you to look at, it can make some of this swapping in and out easier but it's not 100% necessary).

 

Another, potentially even more janky workaround- could you make your subVI reentrant, then re-launch itself each time the selector box value changes? There might be a flicker as the old one closes and the new one opens, and you may have to keep track of window positions.

0 Kudos
Message 6 of 11
(3,647 Views)

You can set the number of rows in a plot legend using a property node.

Message 7 of 11
(3,640 Views)

Just passing through...

 

Property >>> Legend >>> Number of rows

 

Would that help?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 11
(3,637 Views)

@johntrich1971 wrote:

You can set the number of rows in a plot legend using a property node.


That just sets the number of rows visible, not the number of plots the graph thinks it has.  It is fine if you've only got 10-15 plots, but when you get 60+ you run out of room on your screen.  That's why I have the vertical scrollbar enabled on my plot legend.

0 Kudos
Message 9 of 11
(3,631 Views)

@Ben wrote:

Just passing through...

 

Property >>> Legend >>> Number of rows

 

Would that help?

 

Ben


This property sets the height of the legend window- set it to 3, and you can see 3 rows, but the scrollbar is still tiny and the user can still scroll way past the small number of actual elements.

 




Plots share a pool. This is so the user can group "like" plots together on a single graph to generate reports and analyze the data. For example, Graph 1 could be all temperature, Graph 2 could be all pressures, etc. There will be the option to save/load templates as well. The total project is expected to have ~300 waveforms that can be viewed.


If the plots share a pool, doesn't that mean each one will have the same number of elements in the list of your popup? (Your explanation makes it sound like the popup shows all of the potential plots that can be plotted for a graph, am I mistaken?)

 

Any chance you could post your code to mess around with?

0 Kudos
Message 10 of 11
(3,629 Views)