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

If you want to constrain zoom depth in your application - this API is just for you. All SciChart’s axis types have MinimalZoomConstrain property which allows you to constrain changing of axis VisibleRangeif its Diff value is too small. So when you use MinimalZoomConstain you define minimal difference between Min and Max of VisibleRange and if Diff MinimalZoomConstrain then VisibleRange won’t change. This gives you chance to show some minimal data span which we can’t zoom.

Lets create example to show how to use this feature. For example we need to show information about some period of time (e.g. days, weeks etc) and we don’t want to allow users zoom deeper after some point. In our example we’re going to show how to do this.

First we need to create some chart with data, modifiers etc:


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

Also we’ll add slider to change constrain value:

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

Because slider value has double value we need also to create 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);

As a result we get next - on screenshot we created chart where we have RubberBandXyZoomModifier, XAxisDragModifier, ZoomPanModifier etc, but in this example we can’t zoom when X axis displays time span less than 10 days:

Result of using API (MinimalZoomConstrain = 10 days) NOTE: For different axis types type of MinimalZoomConstrain value is different – it depends on type of axis VisibleRange(for NumericAxis type of MinimalZoomConstrain values should be double; DateTimeAxis – DateTime; TimeSpanAxis – TimeSpan; CategoryDateTimeAxis – int).

(1 vote(s))
Not helpful


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


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