Using VisibleRangeLimit API
Posted by Admin - on 21 March 2014 11:20 AM

The VisibleRangeLimit property allows you to set a limit at VisibleRange. This will put a constrain at the VisibleRange and it will never exceed the VisibleRangeLimit range.

For example, consider an axis without any limits having VisibleRangeLimit is set to Null (default setting) and full X Data Range 0-100:

Actual data range = (0, 100) ; VisibleRange after ZoomExtents = (0, 100)

 

By setting VisibleRangeLimit to (10, 90) range, a limit is put at the X-Axis, so full VisibleRange is equal to VisibleRangeLimit now:

Actual data range = (0, 100) ; VisibleRange after ZoomExtents = (10, 90)

If actual VisibleRange is greater than VisibleRangeLimit, the VisibleRange will be clipped to the VisibleRangeLimit.

Setting VisibleRangeLimit

The VisibleRangeLimit can be set in code as follows: 

XAML

<s:NumericAxis VisibleRangeLimit="{Binding XLimit}" />


Cs

xAxis.VisibleRangeLimit = new DoubleRange(0.0, 100.0);

VisibleRangeLimitMode

Another property which can be used to change how the VisibleRangeLimit works is AxisBase.VisibleRangeLimitMode

Use this property to achieve desired constraining behavior. For instance:

<!-- Ensures VisibleRangeLimit of 0 is applied to the VisibleRange.Min -->
<!-- The VisibleRange.Max is unbounded -->
<s:NumericAxis VisibleRangeLimit="0,0" VisibleRangeLimitMode="Min"/>

Advanced VisibleRange Clipping and Manipulation

The VisibleRangeLimit is a useful API, but it will not prevent a user from scrolling outside of that range. There are other ways to ensure that a certain range is never exceeded.

Using ViewportManager

The ViewportManager API allows full control on chart ranges. Additionally, it is applicable in MVVM scenarios via SciChart MVVM API.

Using Events

Subscribing to AxisBase.VisibleRangeChanged allows to change the VisibleRange in any way:

axis.VisibleRangeChanged += (s, e) => 
{
   // e is VisibleRangeChangedEventArgs
   // Assuming axis is NumericAxis

   if (e.NewVisibleRange != null && e.NewVisibleRange.Min < 0)
   {
      // Force minimum visiblerange to zero always
      ((NumericAxis)sender).VisibleRange = new DoubleRange(0, e.NewVisibleRange.Max);
   }
};

In MVVM scenarios, EventToCommand can be used to propagate the VisibleRangeChanged event to a ViewModel or an AttachedBehavior

Further Reading

For further information about the Axis API in SciChart, please see the following documentation links:

(2 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