Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

In Measurement Studio .NET (C#), how can Yaxis of a Waveformgraph be dynamically scaled each time a new point is plotted?

I want to recalculate the max & min of the axis periodically. However, if I read the documentation correctly, the Range class says I have to set a range when "the constructor is called". Does anyone have a brief example (in C# or VB.NET) of how to rescale a graph on the fly?
0 Kudos
Message 1 of 3
(4,966 Views)
Both the XAxis and YAxis have a Mode property that controls how they are scaled. By default, the Mode property on both the XAxis and YAxis is set to AxisMode.AutoScaleExact. With this mode, the axis automatically rescales such that all the data values are "in view".

If you would like to scale the axes yourself, you can set the Mode property to AxisMode.Fixed and do your own calculation to determine the minimum and maximum values. Once you have calculated these values, you can set the minumum and maximum for the axes like so:

[C#]

double xAxisMinimum = CalculateMinimum();
double xAxisMaximum = CalculateMaximum();

// Assuming your instance of WaveformGraph is
// named waveformGraph1 and you wanted to set
// the range on the first x-axis con
tained
// in the graph's x-axis collection.
waveformGraph1.XAxes[0].Range = new Range(xAxisMinimum, xAxisMaximum);

The range for the YAxis can be set in a similar fashion.

Abhishek Ghuwalewala
Measurement Studio
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 2 of 3
(4,966 Views)
The Minimum and Maximum properties on the Range class are readonly properties. You have to create a new Range object to change the Range's minimum or maximum values.
Assuming you have a YAxis instance called yAxis1.
In C#:
//Setting the Range so that Minimum = 20 and
//Maximum = 30
yAxis1.Range = new NationalInstruments.UI.Range(20,30);

In VB:
'Setting the Range so that Minimum = 20 and
'Maximum = 30
YAxis1.Range = New NationalInstruments.UI.Range(20, 30)
Message 3 of 3
(4,966 Views)