LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pick different chart labels based on a control?

Solved!
Go to solution

HI, this is a very basic question but I could use some help:

I have a multimeter which can read four things: voltage, current, resistance, and charge.

I have an instrument driver which can control this multimeter. It has a control on its front panel which selects an integer from 0-4. 0=voltage, 1=current, etc.

The driver then plots the result in a chart. However, due to an irritating bug, it won't clear the chart when it changes measurement types.

I would like to employ labels on my chart axes or chart title which specify what measurement function is being used. Alternatively, I could also display four charts, each referring to a specific measurement function and only plotting data from that one if it is active. For example, user selects 0, chart for voltage plots resulting data, other charts remain blank.

I tried using a property node to change the axes titles, but it had no effect on the front panel graph (see attached). I think this is because I'm not getting LabView to understand that when the user picks "Voltage" it needs to understand that the related 0 constant input corresponds to the label "Voltage" on the block diagram's control for the graph.

Can someone suggest a block diagram that can do this? Either the four charts or the one with changing labels? Or just how to make an array of numbers associated with an array of strings to pick from? Can't for the life of me find a function that does what I want/think it does.

Download All
0 Kudos
Message 1 of 18
(4,350 Views)

First of all, don't use numbers (0 = voltage, etc.).  Learn about Enums, a Data Type where you define the values (Voltage, Current, Resistance, Charge).  If you wire such an Enum up to a Case Statement, guess what the default Case would be (hint -- it is not 0, and it starts with the letter "V").

 

Do you know about Events and the Event Structure?  Suppose your Enum was named "MultiType".  You could have an Event "MultiType Value Changed?", and when you changed MultiType, you could go to your Chart, clear its History, set its Axes (use the value of MultiType to name the Y Axis, so if you change to Current, the Y Axis will say "Current"), change scales, etc.

 

Here's a Useful Trick -- there's a String function called "Format Into String".  Wire MultiType (which is an Enum) into the input, and the output will be a String reflecting the MultiType value (e.g. "Resistance"), perfect for a Y Axis Chart Label.

 

One Chart to Rule Them All, One Chart to Show Them.  An Enum to Set Them All, and In the VI Bind Them.  In LabVIEW, where Developers Dwell.

 

Bob Schor

Message 2 of 18
(4,331 Views)

Thanks, Bob_Schor, for your very helpful response.

 

I was able to use Enums with a Case Structure to pick different labels. Still not sure how to use Events or Event Structures, and as a result, can't get graph to reset when a new Enum is selected.

0 Kudos
Message 3 of 18
(3,779 Views)

Chart have a property named "History"

 

Create a property node and select the history (way at the bottom).

Pop-up and "Create constant"

Writing an empty history will clear the chart.

 

Ben

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

I can't find "history" on my list of properties. I think I may be using the wrong kind of chart. I need to rewrite my VI anyway, so I'll try to find a chart type that works and report back. Thanks again.

0 Kudos
Message 5 of 18
(3,728 Views)

There are only two types of Chart -- Waveform and Intensity.  Both have a Property listed at the very end of the Property List called "History Data", which displays as shown in this Snippet and "History".

Chart History Property.png

Bob Schor

0 Kudos
Message 6 of 18
(3,721 Views)

But your original VI does not have a chart, thus it does not have a history.  It is a graph!

Message 7 of 18
(3,716 Views)

Yeah, I tried to use XY Graph, which works to change axes labels but not clear history, far as I can tell.

0 Kudos
Message 8 of 18
(3,689 Views)

If you want to erase all of the data on a Graph, that's simple -- just wire an empty Array (or whatever data set you are plotting) to the input of the Chart.  Plotting "nothing" means no points are visible.

 

Bob Schor

Message 9 of 18
(3,678 Views)

@Bob_Schor wrote:

If you want to erase all of the data on a Graph, that's simple -- just wire an empty Array (or whatever data set you are plotting) to the input of the Chart.  Plotting "nothing" means no points are visible.

 

Bob Schor


If you want to erase all of the data on a Graph, that's simple -- just wire an empty Array (or whatever data set you are plotting) to the input of the Chart Graph.   Plotting "nothing" means no points are visible.

 

Sorry Bob, we've got to be specific on this one since the charts and graphs have distinct behaviors that matter in this thread.  But I think you are right.  It is hard to tell what the OP is doing exactly since he says what he is doing, but not really saying what he is not doing.  If changing the labels is the ONLY thing happening via property node, then of course the data that exists withing the graph indicator is still there, and he will need to wire an empty array (or whatever datatype is correct for that graph instance) to clear the value in the graph.

 

I think a summary is in order for the OP:

Charts, maintain history.  If you wire a value to the chart, it gets appended to the existing history.  To clear history, and thus the chart, you need to wire an empty array to the History property node."

 

Graphs to not have a history.  You need to create your own history when needed with other LabVIEW code.  Wire values to the graph replace the existing data in the graph.  To clear the graph, you need to wire an empty array to the graph's terminal or the Value property node.

 

 

Message 10 of 18
(3,667 Views)