Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

changing scattergraph range

I have a question:
I want to change in my program the x and y axes range.
So I decided to go this way:

Deklaration in the constructor:
this.gui_graphMessung = new NationalInstruments.UI.WindowsForms.ScatterGraph();

my changing:
this.gui_graphMessung.XAxes[0].Range.Maximum=0;

It doesn't work, but I made a Scattergraph with the XAxe index zero.
The compiler always tells me, that this is not allowed to assign, because it is write protected.

How can I change in my program the xaxes?
If I change it in the windows form, it works, but I want to change it in my program.

Yours,
Klaus
0 Kudos
Message 1 of 2
(3,866 Views)
The problem is not the index of the XAxes collection. The reason you are not able to assign to the Maximum property of the Range is because, as the compiler said, it is read-only. This is how you would change the range of the first x-axis in the XAxes collection:

// Assuming that you want to set minimum to -10 and maximum to 0.
this.gui_graphMessung.XAxes[0].Range = new Range(-10, 0);

The reason for this is to prevent you from accidentally setting the minimum to be greater than the maximum. If the Maximum and Minimum properties were writable, then in order to ensure that the Minimum value was less than the Maximum value, you would have to set the Minimum value first before you set the Maximum value. For example, if the Range is currently 1,
10 and you wanted to change this to -10, 0, then you would have to set the Minimum value to -10 before you set the Maximum value to 0. Otherwise, if you tried to set the Maximum value 0 before the Minimum value, then the Range would become 1, 0 and this would violate the minimum must always be less than the maximum rule. To prevent this we require that to set the Range of the axis, you create a new instance of Range and specify both the minimum and maximum value at the same time.

Abhishek Ghuwalewala
Measurement Studio R & D
National Instruments
Abhishek Ghuwalewala | Measurement Studio | National Instruments
Message 2 of 2
(3,866 Views)