Clear a Chart or Graph in LabVIEW

Updated Nov 17, 2020

Data displayed in a Chart or Graph in LabVIEW can be cleared before or after running your code, manually or programmatically. This tutorial walks users through multiple ways to clear data from a chart or graph in LabVIEW.

Manually Clear Data

This method can be used on Charts or Graphs. For simplicity, the term Graph is used below.
  1. Open your LabVIEW VI that contains a Waveform Graph object.
  2. On the front panel, right-click the Graph >> select Data Operations >> Clear Graph.
 

Programmatically Clear Data

There are multiple methods to programmatically clear data from a chart or graph. You can clear the front panel object using specific property nodes depending on whether a Waveform Chart or Waveform Graph is used.  For either data type, you can use the Reinitialize to Default property node.

Chart

You can clear a chart programmatically by writing an empty array to its History Data buffer:
  1. On the block diagram, right-click the chart icon >> select Create»Property Node»History Data .
    • Note that the color at the top bar of the property node is determined by the data type used in the chart.
  2. Right-click the History Data property node 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. 

 

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.

Reinitialize to Default

You can also use the Reinitialize to Default method if you ensure that the default value for your graph or chart is an empty array:
  1. Make sure the graph/chart is clear by right-clicking the object in the front panel >> select Data Operations >> Clear Graph or Clear Chart.
  2. Set this empty state as default by right-clicking the graph/chart >> select Data Operations >> Make Current Value Default.
  3. On the block diagram, right-click the graph/chart and select Create >> Invoke Node >> Reinitialize to Default.
This method returns the front panel object to its default state.

Additional Information

Refer to the Clearing Waveform Charts VI in the labview\examples\Controls and Indicators\Graphs and Charts\Waveform Graphs and Charts directory for an example of clearing graphs and charts programmatically.