SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


Dear all,

Actually in all chart demo the zoom is done by using the mouse and define the area to zoom in.

I would like to be able to have a button when I click on it it will zoom the view port area with a predifine zoom increment.

Question :
How can we control the zoom from a button click without specifying an area but use a zoom increment instead ?

thanks sample


  • You must to post comments

Sure you can, you can zoom programmatically with SciChart WPF.

Please see the article Programmatically Zoom, Scroll an Axis for more information


A simple example below shows how you can use Axis.Zoom() in combination with the ChartModifierBase API to create a simple custom modifier which handles KeyDown and zooms in and out on CTRL+ or CTRL- Key Presses.

Include this on your chart like any other modifier, by setting SciChartSurface.ChartModifier = new SimpleZoomInOutModifier();

/// <summary>
/// A single X-Y axis implementation of a Zooming In / Out on KeyDown (CTRL+, CTRL-), used to demonstrate the ChartModifierBase and Axis Interactivity APIs in SciChart
/// </summary>
public class SimpleZoomInOutModifier : ChartModifierBase
    public static readonly DependencyProperty ZoomFractionProperty = DependencyProperty.Register("ZoomFraction", typeof (double), typeof (SimpleZoomInOutModifier), new PropertyMetadata(0.1));

    public double ZoomFraction
        get { return (double) GetValue(ZoomFractionProperty); }
        set { SetValue(ZoomFractionProperty, value); }

    void SciChart_PreviewKeyDown(object sender, KeyEventArgs e)
        double factor = 0;

        if (e.Key == Key.Add && (Keyboard.Modifiers & ModifierKeys.Control) > 0)
            // On CTRL+, Zoom In
            factor = -ZoomFraction;
        if (e.Key == Key.Subtract && (Keyboard.Modifiers & ModifierKeys.Control) > 0)
            // On CTRL-, Zoom Out
            factor = ZoomFraction;

        using (ParentSurface.SuspendUpdates())
            // Zoom the XAxis by the required factor
            XAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Zoom the YAxis by the required factor
            YAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Note.. can be extended for multiple YAxis XAxis, just iterate over all axes on the parent surface

    public override void OnAttached()
        var scichart = ((SciChartSurface)ParentSurface);

        var mainWindow = FindLogicalParent<Window>(scichart);

        mainWindow.PreviewKeyDown -= SciChart_PreviewKeyDown;
        mainWindow.PreviewKeyDown += SciChart_PreviewKeyDown;

    private T FindLogicalParent<T>(SciChartSurface scichart) where T:class
        var parent = (FrameworkElement)scichart.Parent;
        while (parent != null)
            var candidate = parent as T;
            if (candidate != null) return candidate;

            parent = (FrameworkElement)parent.Parent;

        return null;

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.