Knowledgebase
Setting Axis VisibleRange in Code or MVVM
Posted by Admin - on 13 February 2019 01:39 PM

Axis API in SciChart allows to change axes ranges via the VisibleRange property. However, to enable changing it manually the AutoRange property has to be set either to AutoRange.Once (by default) or AutoRange.Never.

You may set the VisibleRange either in code, in XAML or via a binding (MVVM), as it is shown below:

C#:

var axis = new NumericAxis() { VisibleRange = new DoubleRange(0, 10) };

  XAML (Set in XAML):

<s:NumericAxis VisibleRange="0, 10"/>

  XAML (Binding):

<!-- Assumes a ViewModel property called AxisVisibleRange -->
<!-- TwoWay Binding is required -->
<s:NumericAxis VisibleRange="{Binding AxisVisibleRange, Mode=TwoWay}"/>

Animating Axis VisibleRange in code or MVVM

As well as setting a VisibleRange (which triggers immediate update), you may animate a VisibleRange in code or XAML. To do so, please use the following code:

C#:

var axis = new NumericAxis() { AnimatedVisibleRange = new DoubleRange(0, 10) };

// OR

var axis = new NumericAxis();
axis.AnimateVisibleRangeTo(new DoubleRange(0, 10), TimeSpan.FromMilliseconds(300));

  XAML (Set in XAML):

<!-- Animates with duration of 500ms -->
<s:NumericAxis AnimatedVisibleRange="0, 10"/>

  XAML (Binding):

<!-- Assumes a ViewModel property called AxisVisibleRange -->
<!-- TwoWay Binding is required. Animates with duration of 500ms -->
<s:NumericAxis AnimatedVisibleRange="{Binding AxisVisibleRange, Mode=TwoWay}"/>

Further Reading

To learn more about Axis APIs, please see the following articles:

(11 vote(s))
Helpful
Not helpful

CONTACT US

Not sure where to start? Contact us, we are happy to help!


CONTACT US

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL. Email: Legal Company Number: 07430048, VAT Number: 101957725