Clear a Chart or Graph in LabVIEW

Updated Dec 1, 2023

Environment

Software

  • LabVIEW

Data displayed in a Chart or Graph - LabVIEW Help 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 which contains a Waveform Graph or Chart object.
  2. On the Front Panel, right-click the Graph and select Data Operations >> Clear Graph/Chart.
 

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 and 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 is an empty array:
  1. Make sure the graph is clear by right-clicking the object in the front panel select Data Operations >> Clear Graph.
  2. Set this empty state as default by right-clicking the graph select Data Operations >> Make Current Value Default.
  3. On the block diagram, right-click the graph and select Create >> Invoke Node >> Reinitialize to Default.
This method returns the front panel object to its default state.

Note: This method cannot be used to clear a chart because the chart maintains a history of data, or buffer, from previous updates. To clear a waveform chart, you need to clear its history data rather than reinitialize it to a default value. To do this manually, you can right-click on a Waveform Chart and select Data Operations >> Clear Chart. To do it programmatically, you need to write an empty array to its History Data buffer.

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.