LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Automatically have Legend Names Match Variable names

Hello,

I would like to graph approximately 19 local variables with respect to time, and have the legend on the chart/graph correspond to the local variable names. In other words (referring to the attached pictures), I would like the legend entries to read "T_Cf_out 1 [C], T_Cf_out 2 [C].... etc." instead of "Plot 0, Plot 1, Plot 3,... etc." I know that I can manually type in new plot names, but I would like the plot names to change with the local variable names. In other words, if I change the name of a local variable that is plotted on the chart/graph, I would like the legend entry corresponding to that plot to change. 

 

Can anyone help me program this?

Download All
0 Kudos
Message 1 of 12
(3,611 Views)

Use Untitled.png to get the name of the control and update the name of the corresponding plot with a plot property node.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 12
(3,602 Views)

For extra credit:

 

Google "labview abuse of local variables" and "labview abuse of dynamic data" and learn from the results.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 12
(3,597 Views)

Local variables don't have names, they just point to the label of their associated control or indicator. Labels are fixed at compile time, so you might as well hard-wire them or set them manually. Only control/indicator legends can be changed at run time.

 

If you have an array of strings for example that corresponds to the desired legends, you can iterate over it using property node in a loop. Set the active plot to [i], set plot name, wash, rinse, repeat. Do that only whenever the plot names change, and not with every iteration of the loop, of course.

 

There is absolutely no need for dynamic data here. You could build a cluster instead. (dynamic data carries a lot of extra baggage that is completely irrelevant here)

0 Kudos
Message 4 of 12
(3,595 Views)

Good answers that beat me while I was making a VI.  Here is one option that reads the labels from the controls (because it is carried on the wire).  You can get these names and then set the plot names to these.  However more often people don't change what the labels are, and so you can just type them in on the front panel and they won't change.  If you do want them to change as the program is running I show how to get them from the wires (only getting them on first run) and I have a control that when changed will change the labels.

 

Plot Naming Test.png

0 Kudos
Message 5 of 12
(3,587 Views)

@Hooovahh wrote:

Good answers that beat me while I was making a VI.  Here is one option that reads the labels from the controls (because it is carried on the wire). 


IMHO barely OK for four controls, but unacceptable for 19 controls as in the original request. 😮 Maybe if we would carry the 19 values as a single cluster of 19 controls, we could iterate over the references of the cluster elements to get the names.

 

Somehow, this entire question smells of trying to find a fake solution to a non-problem. If architected and designed differently, this question would probably not even come up. Maybe we should have a look at the actual entire code of the OP to find a better solution from the ground up.

Message 6 of 12
(3,574 Views)

@altenbach wrote:

@Hooovahh wrote:

Good answers that beat me while I was making a VI.  Here is one option that reads the labels from the controls (because it is carried on the wire). 


IMHO barely OK for four controls, but unacceptable for 19 controls as in the original request. 😮 Maybe if we would carry the 19 values as a single cluster of 19 controls, we could iterate over the references of the cluster elements to get the names.

 


So sorry, in my haste to get an example I didn't realize there were that many.  Still one could use some VI Server to automatically get the control labels if they follow some convention.  Like every control starts with a number which is the index to be on the UI, and the UI just showed the captions.  Then get a list of all controls that start with a number and set the plot based on that.  Slightly better but again if this isn't something that is going to change then just set it once and forget about it.

0 Kudos
Message 7 of 12
(3,563 Views)

@Hooovahh wrote:

@altenbach wrote:

@Hooovahh wrote:

Good answers that beat me while I was making a VI.  Here is one option that reads the labels from the controls (because it is carried on the wire). 


IMHO barely OK for four controls, but unacceptable for 19 controls as in the original request. 😮 Maybe if we would carry the 19 values as a single cluster of 19 controls, we could iterate over the references of the cluster elements to get the names.

 


So sorry, in my haste to get an example I didn't realize there were that many.  Still one could use some VI Server to automatically get the control labels if they follow some convention.  Like every control starts with a number which is the index to be on the UI, and the UI just showed the captions.  Then get a list of all controls that start with a number and set the plot based on that.  Slightly better but again if this isn't something that is going to change then just set it once and forget about it.


Or put the controls in a cluster (make the border invisible if you like), and order them as desired.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 12
(3,545 Views)

 

 


@paul_cardinale wrote:

@Hooovahh wrote:

@altenbach wrote:

@Hooovahh wrote:

Good answers that beat me while I was making a VI.  Here is one option that reads the labels from the controls (because it is carried on the wire). 


IMHO barely OK for four controls, but unacceptable for 19 controls as in the original request. 😮 Maybe if we would carry the 19 values as a single cluster of 19 controls, we could iterate over the references of the cluster elements to get the names.

 


So sorry, in my haste to get an example I didn't realize there were that many.  Still one could use some VI Server to automatically get the control labels if they follow some convention.  Like every control starts with a number which is the index to be on the UI, and the UI just showed the captions.  Then get a list of all controls that start with a number and set the plot based on that.  Slightly better but again if this isn't something that is going to change then just set it once and forget about it.


Or put the controls in a cluster (make the border invisible if you like), and order them as desired.


Couldn't have said it better 😄

 

0 Kudos
Message 9 of 12
(3,538 Views)

@altenbach wrote:

Local variables don't have names, they just point to the label of their associated control or indicator. Labels are fixed at compile time, so you might as well hard-wire them or set them manually. Only control/indicator legends can be changed at run time.

 

If you have an array of strings for example that corresponds to the desired legends, you can iterate over it using property node in a loop. Set the active plot to [i], set plot name, wash, rinse, repeat. Do that only whenever the plot names change, and not with every iteration of the loop, of course.

 

There is absolutely no need for dynamic data here. You could build a cluster instead. (dynamic data carries a lot of extra baggage that is completely irrelevant here)


Before I posted about the Data Type Parsing solution, I made sure it worked on locals, too.  I was half afraid it wouldn't.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 12
(3,537 Views)