How to Clear a Chart or Graph Programatically in LabVIEW

Updated Nov 21, 2017

Reported In

Other

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?

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:
  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:

     To clear a graph programmatically, a Property Node or Invoke Node can be used.

Property Node:
  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.


Invoke Node:
  1. Make sure the graph is clear by right-clicking the graph and selecting Data Operations»Clear Graph.
  2. 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. Right-click the graph and select Create»Invoke Node»Reinitialize to Default.

WAS THIS ARTICLE HELPFUL?

Not Helpful