Example Code

Programmatically change the units of a graph or chart

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

Download All

Overview 

This simply VI illustrates how we can easily implement code to change the units used on a graph or chart. The code uses property nodes of the chart to update both the minimum and maximum values and the axis title.

 

Description

A case structure is used to allow us to switch between the different units available. A Type Definition Enum allows us to select what units we want to be displayed. Within each case different scales and axis titles are defined. Additionally a conversion factor is applied to the data which corresponds to the conversion between the different units. The random number generator has been used simply to illustrate the example and has been multiplied by 5 to make the illustration clearer. The example could be expanded to change more features of the graph such as the units marker intervals. In this case the units of the y-axis are updated, but the code could be expanded to update the x-axis.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI.
  2. Select the units in Units Selector control. The y-axis of Waveform Chart change with your selection.
  3. Press Stop button to exit.

 

Additional Information or References 

VI Snippet

157.png

 

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

Aaron. E
Product Performance Engineer
Dyson

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