From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically change Graph axis range C#

Solved!
Go to solution

I got mine to work but  just wanted to make sure I am doing it properly.  I'm only asking because I had to use casting and hardcoded element retrieval.

This is what works for me:

 

AxisDouble Yaxis = (AxisDouble)Graph.Axes.ElementAt(0);
Yaxis.Range = new Range<double>(-25000, 25000);

 

I also set Adjuster="None" in XAML.

 

Thank you.

0 Kudos
Message 1 of 3
(4,444 Views)
Solution
Accepted by topic author kirko7

Your approach is fine. Since you are declaring the axis in XAML, you could also use a name instead of referring to it by index location:

 

    <ni:AxisDouble x:Name="Yaxis" Adjuster="None" ... />

~ Paul H
0 Kudos
Message 2 of 3
(4,439 Views)

Much better.  Didn't think of that... 

Thank you

0 Kudos
Message 3 of 3
(4,436 Views)