This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

How to Clear a Chart or Graph Programatically in LabVIEW

Updated Sep 30, 2019

Reported In

Software

  • LabVIEW

Issue Details

  • I have a chart and a graph on my front panel in LabVIEW, but the only way I can find to clear it is to right-click the chart or graph and choose Data Operations»Clear Chart or Data Operations»Clear Graph from the shortcut menu.  Is there a way to clear the chart or graph programmatically?
  • How can I clear my graph programmatically each time after it runs?

Solution

The method used to clear a chart or graph changes depending on the exact front panel object used. Below covers the options for clearing these objects.   

Waveform Chart

You can clear a chart programmatically by writing an empty array to its History Data buffer:
 
  1. Right-click the chart and select Create»Property Node»History Data.
  2. Right-click History Data and select Change to Write.
  3. Right-click the History Data Terminal and select Create Constant.
This writes an empty array of data to the chart, which will clear the history when this code is executed.

Waveform Graph

You can clear a graph programmatically by writing an empty array to its Value property:
 
  1. Make sure the graph is clear by right-clicking the graph and choosing Data Operations»Clear Graph.
  2. Right-click the graph and select Create»Property Node»Value.
  3. Right-click Value and select Change to Write.
  4. Right-click the Value Terminal and select Create Constant. 
This writes empty data to the graph which will clear the graph when this code is executed.

You can also use the Reinitialize to Default method if you ensure that the default value for your graph is an empty array:
 
  1. Make sure the graph is clear by right-clicking the graph and selecting Data Operations»Clear Graph.
  2. Set this empty state as default by right-clicking the graph and selecting Data Operations»Make Current Value Default.
  3. Right-click the graph and select Create»Invoke Node»Reinitialize to Default.
 

Additional Information

In LabVIEW releases prior to 8.0, you cannot create a constant if waveform data is being written to the chart.  Instead, use one of the methods described below.

Waveform Chart and Graph (Property Node):
  1. Right-click the property and select Create»Control.
  2. Go to the Front Panel and right-click the newly created control.  Select Advanced»Hide Control.


Waveform Graph (Invoke  Node):
  1. Make sure the graph is clear by right-clicking and select Data Operations»Clear Graph.
  2. Set this empty state as default by right-clicking the graph and selecting Data Operations»Make Current Value Default.
  3. Right-click the graph and select Create»Invoke Node»Reinitialize to Default.

Note: If a graph is utilizing clusters you will need to use Create>>Invoke Node>>History

WAS THIS ARTICLE HELPFUL?

Not Helpful