Programmatically Switching XY Graph Scales

Updated Apr 24, 2024

Reported In

Software

  • LabVIEW

Issue Details

  • In my code, I am using an XY Graph to visualize data. Based on the data that is in the graph, I would like to be able to change the scale of the X or Y axis on the fly. How can I do this?
  • Is it possible to create new XY Graph scales programmatically?
  • How can I programmatically set the value of a scale to the value of another scale on an XY Graph?

Solution

In LabVIEW, it is not possible to dynamically create a scale. Rather, LabVIEW users will need to create all scales  that will be used ahead of time, and dynamically hide or show the required scales at runtime.

If you wish to assign the value of one scale to another scale on an XY Graph, the X Scale Range or Y Scale Range can be used.
 

Programmatically Hide XY Graph Scale

To switch the active scale, use a Property Node and alter the Active X Scale or Active Y Scale property of the XY Graph. This will change what scale is currently active. Then, you can use the X Scale Visible or Y Scale Visible property to change whether the active scale is visible or not. 

For example, if a user wants to switch between scale 0 and scale 1 being visible on the graph, they should first make the 0 scale active, then set X Scale Visible to false. Then, scale 1 can be made active, and X Scale Visible should be set to true.

 

Programmatically Switch XY Graph Scale Values

To assign the value of one scale to another scale, use a Property Node and set the Active X Scale or Active Y Scale property. This will change the currently active scale. Then, the X Scale Range or Y Scale Range property can be used to configure the minimum, maximum, increment, minor increment and start values for the scale.

In the picture below, Y Scale "1" is set to have the same range values as Y Scale "0".
Switch Scales.PNG