LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
altenbach

Make "active plot" property more agile

Status: New

A longstanding issue with the "active plot" property is that is throws an error if fewer plots currently exist. Conversely, if we wire data containing more plots, the graph automatically adapts to that.

 

The main problem with this is that the order of operations matters. We need to write the value first, followed by the active plot properties. Many times we already know what kind of plots we want (color, name, etc.), even if one of the plots is only added in a later step or the terminal is written a nanosecond later due to code scheduling. Workarounds mean excessive sequentialization because we need to enforce strict order: (1) write data (2) update plot properties.

 

The current behavior is annoying, and there are many forum examples where that was the cause of the problem (example).

 

Two suggestions can address this:

 

(1) if an active plot property is written, and that plot does not exist yet datawise, it should be created automatically and the node returns without error. (Of course all other missing plots up to that number need to be created too, they can have default properties).

 

(2) Maybe there should also be a property for "number of plots" than can be written to define the number of plots.

5 Comments
kegghead
Member

Regarding your second suggestion (number of plots), this can be done via the Legend: Number of Plots properties. Use this property to dynamically change the number of plots then cycle through them with the Active Plot property, thus you don't need to give the plot data first.

 

However I generally agree, I think the Active Plot property should coerce the number of plots automatically if supplied with an out of range value.

altenbach
Knight of NI

>this can be done via the Legend: Number of Plots properties

 

Thanks for the tip!

Are you sure about that? I wasn't aware that resizing the plot legend changes the actual number of valid plots. I thought it was similar to arrays, where resizing the container does not change the size of the array. (A lot of details changed over the years here, so I might be wrong. I do some tests).

PaulG.
Active Participant

Recently dinged. 3 plots worked just fine - without properties. The only way I could get it to work was to go to the graph itself, make the plot legend visible and pull it up to make the 3 plots visible on the legend. ????  I wasted a lot of time on this. It's quirky. And annoying. And it's a BUG. 

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
murchak
Active Participant

Hi Guys,

 

What is baffling me is why the code runs just fine as a stand-alone code, but only gives the error when it is called as a sub-vi in a different code.

 

As a stand-alone code, suppose I select 5 files. Then the arrays that index the for loop all have size 10 (2x5). First five define the properties of the curves, the second 5 define properties of the error bars.

Also, the LegNumRows = 5 (not 10). Then I get the correct number of legends that show up for the 5 curves and clearly I don't need additional legends for the error bars.


However, when I call the code as a sub-vi, the ONLY way to get it to work WITHOUT errors is to make LegNumRows = 10 as well. In which case I get no errors (e.g., the curves and error bars have the properties that I define) but my legend now has 10 entries, which then I have to manually resize to NOT show the additional 5 entries, which then defeats the ultimate purpose of me making my work more automated.

 

If this is indeed a bug, then I hope that NI can fix this. Last time when I was working with labVIEW 10, I had an issue of not being able to write data into an Oracle database using database connectivity toolkit, and it turned out to be a bug that got fixed in LabVIEW11 (here is the link to that discussion):

http://forums.ni.com/t5/LabVIEW/DB-Connectivity-Toolkit-Insert-Data-Error-2147352567/td-p/1633964/hi...

kegghead
Member

Are you sure about that? I wasn't aware that resizing the plot legend changes the actual number of valid plots. I thought it was similar to arrays, where resizing the container does not change the size of the array.

 

You are correct how the behavior of the legend is consistent with the behavior of the array when operating on non-executing VIs-- if you resize the legend it that doesn't change the number of plots the graph/chart expects. However for whatever reason, when the VI is running, altering the Number of Rows property via a node does affect the number of plots in the graph. Run this snippet on a default chart (configured as a 2D array type) and you'll see you don't get the error. Remove the first property node though and you will get the error because there's only one plot by default.

 

plots.png