Example Code

Programmatically Clear Waveform Chart in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
Programmatically clear a waveform chart in LabVIEW. This example clears the chart by wiring a Constant to the History Data Property Node for the Waveform Chart. Alternatively, a Reinitialize To Default Invoke Node can be used. Caution with the Reinitialize to Default as the 'Default' can be programmatically modified.

 
Description
The 'Programmatically Clear Wfm Chart.vi' has a while loop and event structure. When the 'Generate Data' button is selected, a for loop generates an array of random doubles. The array is plotted on the waveform chart. When the 'Clear Chart' button is pressed, then an empty array of doubles constant is wired to the History Data Property Node to clear the chart. To create the property node, right-click on the chart. Select Create > Property Node > History Data. Then right-click on the Property Node and select 'Change to Write'. Right-click on the property node and select 'Create Constant' to create the empty array of doubles to clear the chart. For more information, see the following  KnowledgeBase article: How to Clear a Chart or Graph Programmatically in LabVIEW.

 
Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Click Run.
  2. Click 'Generate Data' to generate and plot random doubles on the waveform chart.
  3. Click 'Clear Chart' to clear the chart.
  4. Click 'Stop' when finished.

 

Additional Information or References
VI Block Diagram

 1.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Taylor B.
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
labview_user123
Member
Member
on

Can this be done for a single plot rather than the whole chart? 

 

Say I want to give the user some checkboxes and controls to select which data they want to plot at runtime, so that while the chart is running they can add a new plot, or take one away.

 

So far the closest I can get is to visibly hide the plots at runtime, but this isn't exactly what I want. 

 

Thanks