Example Code

Creating a WaveformGraph with Multiple Y-Axes and Multiple Plots in Measurement Studio 2010

Code and Documents

Attachment

Overview
This example shows how to manually add multiple Y-axes to a WaveformGraph .NET component and how to programmatically assign a plot in a WaveformGraph to one of the added axes.

Description

This example is a modified version of an example shipped with Measurement Studio that is available at the following location: Start » All Programs » National Instruments » Measurement Studio 2010 » .NET Examples. Once in the Measurement Studio Examples directory navigate to the following location: <Measurement Studio Examples>\UI\WindowsForms\Graph\Plotting

 

Requirements

  • Visual Basic

 

Steps to Implement or Execute Code

  1. Open the MainForm of the attached completed example or the example mentioned above.
  2. Right click on the WaveformGraph component and select "Edit Yaxes..."
  3. In the YAxis Collection Editor window press the Add button to create an additional Y-Axis and then press OK.
  4. Add the following code to the end of the OnTimerTick function so the axes are dynamically assigned to the plots when the number of plots change

             /**

             * The following code determines how many plots should be assigned to the axes available. If there are more plots than axes the remainder

             * of the plots are left on the default axis.

             * After finding the number of Axes available, the plots associated with the WaveformGraph are iterated through and the plots Y-Axis is modified

             * to use one of the other Axes available.

             **/

            int plotIndexIter;

            for (plotIndexIter = 0; plotIndexIter < Math.Min(sampleWaveformGraph.Plots.Count, sampleWaveformGraph.YAxes.Count); plotIndexIter++)

                sampleWaveformGraph.Plots[plotIndexIter].YAxis = sampleWaveformGraph.YAxes[plotIndexIter];

  1. Run the application to see multiple plots each with their own Y-axis on one WaveformGraph

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

 


Milan

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

Comments
PureNI
Member
Member
on

What about describing how to do this by code?