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

For documentation please see the "Specifying a Minimum Zoom Level" section from the Axis Ranging - Clipping VisibleRange article.

Introduction

If you want to know how to constrain zoom depth in your application - this article is for you.

All Axis Types in SciChart have the MinimalZoomConstrain property. It allows you to constrain the minimal difference of axis VisibleRange (see VisibileRange.Diff). When you set MinimalZoomConstrain you define the minimal difference between Min and Max of VisibleRange and hence minimal possible zoom level.

Applying MinimalZoomConstrain

Lets create an example to show how to use this feature. Imagine that you need to show information within a period of time (e.g. a day, a week, etc) and want to constrain zoom at that level.

You can declare a SciChartSurface with a DateTimeAxis as follows:

<s:SciChartSurface Grid.Row="0" s:ThemeManager.Theme="ExpressionLight"> 
 ...
     
     <s:SciChartSurface.XAxis>
     <s:DateTimeAxis AxisTitle="{Binding ElementName=xSlider, Path=Value}" MinimalZoomConstrain="{Binding ElementName=xSlider, Path=Value, Converter={StaticResource DoubleToTimeSpanConverter}}" />
     </s:SciChartSurface.XAxis>
 
... 
</s:SciChartSurface>

Also lets add a Slider to change the Minimal Constrain value:

<Slider Name="xSlider" Grid.Row="1" IsSnapToTickEnabled="True" Maximum="20" Minimum="1" TickFrequency="1" />

Because the Slider value is of the Double type, lets use a Value Converter:

public class DoubleToDateTimeConverter : IValueConverter
{
   public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
   var ticks = TimeSpan.FromDays((double) value).Ticks;
   return new DateTime(ticks);
}

Note: For different axis types the MinimalZoomConstrain property expects a value of corresponding appropriate type: Double for NumericAxis, DateTime for DateTimeAxis, TimeSpan for TimeSpanAxis, Integer for CategoryDateTimeAxis).

As a result we get the following chart, which cannot be zoomed in further than range difference of 10 days:

Further Reading

For more info about Axis APIs please see the following documentation articles:

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