From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Checking if a graph scale has any active plots

Solved!
Go to solution

I'm setting up an asynchronous VI to display 'popup' XY Graphs and want to allow the use of a second Y scale, although by default it will be hidden.

 

Displaying the second scale is not too difficult - I have an Event Structure which checks the "Plot Attribute Change" event and if New.YScaleIdx != Old.YScaleIndex, I make the New scale visible, and autoscale as necessary.

Second section unclear... when to set it not visible?Second section unclear... when to set it not visible?

 

However, I'm not sure how I can check if the "old" scale has any remaining plots using it, and if not, hide it.

Is there some sensible method to do this?

 

I think it should be possible to iterate through the Active Plot -> YScaleIdx -> If Index == oldIdx, stop and return true, else, iterate, -> return false (are there any plots using this index scale), but

  • this seems a bit circuitous
  • I'm not sure how to generically find the number of plots in the graph
    • the graph VI has this information from the array size of the value
    • I could check this via the Value property node but it could lead to a copy of a lot of data for a poor reason imo if there's an alternative
    • I can also get the number of plots by autoscaling the legend (I'm already doing this, when I have legend values specified) and checking the Number of Rows, but I'm not sure I can force this to remain in sync with the number of plots (although that can't change - maybe the legend size could be altered leading to invalid number of plots if I assume they're the same).

 

How should I solve this?


GCentral
0 Kudos
Message 1 of 3
(2,057 Views)
Solution
Accepted by topic author cbutcher

AFAIK, iterating the plots is the only way.

 

Of course if you manage the plots, you can buffer the information.

 

Finding the number of plots is a bit of a mystery. IIRC, adding them is easy, deleting them is hard. Somehow the graphs grow the nr. of plots but don't shrink them...

 

I also had huge cosmetic problems with dynamically showing\hiding scales. They seem to remember position or something, and when shown they can popup on their old location. So scale 5 can appear before scale 2 under the correct (wrong) circumstances. This was in a dynamically scaling graph, that might make a difference.

 

My way out was to DIY everything, as you can set the positions of the scales. It was (and still is) hell! Just a heads up, YMMV. If you run into these symptoms, consider not supporting this.

 

Message 2 of 3
(2,020 Views)

wiebe@CARYA wrote:

AFAIK, iterating the plots is the only way.


That's too bad, but good to know I didn't miss something obvious. At least now I know a LabVIEW Champion also missed it if it does exist 😉

 


wiebe@CARYA wrote:

Of course if you manage the plots, you can buffer the information.

 

Finding the number of plots is a bit of a mystery. IIRC, adding them is easy, deleting them is hard. Somehow the graphs grow the nr. of plots but don't shrink them...


I considered this, but I'm just trying to do something simple/quick - one of my colleages likes to throw up a bunch of graphs with MATLAB and so I thought perhaps a way to quickly display a graph (with a snapshot of data - I don't have any communication method to update the data after launch) in a new window might be useful - sometimes you want to display something when it is calculated, but you don't want to take up front panel space all the time.

 

I've also got some memories of the number of plots never decreasing, or at least being a pain to manipulate. I'm hoping the short-lived nature of my graphs will make this not such an issue for me...

 


wiebe@CARYA wrote:

I also had huge cosmetic problems with dynamically showing\hiding scales. They seem to remember position or something, and when shown they can popup on their old location. So scale 5 can appear before scale 2 under the correct (wrong) circumstances. This was in a dynamically scaling graph, that might make a difference.

 

My way out was to DIY everything, as you can set the positions of the scales. It was (and still is) hell! Just a heads up, YMMV. If you run into these symptoms, consider not supporting this.

 


I'm thinking I'll just not allow more than 2 scales, and the front panel essentially only has a graph on it (everything else is hidden) so resizing is done with the built-in scaling (and a little minor repositioning/resizing for the legend). If anything gets too complicated, I think not supporting it will be my first choice for this tiny chunk of code (2 VIs and a VIM to allow rearrangement of the accepted datatypes of an XY Graph).


GCentral
0 Kudos
Message 3 of 3
(1,975 Views)