Search Results for

    Show / Hide Table of Contents

    The ZoomExtentsModifier

    SciChart Android provides the ability to zoom-to-fit the entire chart double-tapping it via the ZoomExtentsModifier, available out of the box.

    Besides common features which are inherited from the ChartModifierBase class, the ZoomExtentsModifier allows to control its specific features via the following properties:

    • setDirection(Direction2D direction) - allows to restrict zooming to the horizontal or vertical direction only if needed.
    • setIsAnimated(boolean isAnimated) - allows to switch on/off the animation on zoom out.
    • setExecuteOn(ExecuteOn executeOn) - allows to specify the trigger action for the modifier via the ExecuteOn enumeration.
    Note

    There are several modes defined by the ExecuteOn enumeration, such as Single Tap, Double Tap, Long Press, and Fling.

    Adding a ZoomExtentsModifier to a Chart

    Any Chart Modifier can be added to a SciChartSurface via the chartModifiers property and ZoomExtentsModifier is no difference:

    • Java
    • Java with Builders API
    • Kotlin
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    final ZoomExtentsModifier zoomExtentsModifier = new ZoomExtentsModifier();
    zoomExtentsModifier.setDirection(Direction2D.XDirection);
    zoomExtentsModifier.setExecuteOn(ExecuteOn.DoubleTap);
    zoomExtentsModifier.setIsAnimated(true);
    
    // Add the modifier to the surface
    surface.getChartModifiers().add(zoomExtentsModifier);
    
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    ModifierGroup zoomExtentsModifierGroup = sciChartBuilder.newModifierGroup()
            .withZoomExtentsModifier()
            .withXyDirection(Direction2D.XDirection)
            .withExecuteOn(ExecuteOn.DoubleTap)
            .withIsAnimated(true)
            .build()
            .build();
    
    // Add the modifier to the surface
    surface.getChartModifiers().add(zoomExtentsModifierGroup);
    
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    val zoomExtentsModifier = ZoomExtentsModifier()
    zoomExtentsModifier.direction = Direction2D.XDirection
    zoomExtentsModifier.executeOn = ExecuteOn.DoubleTap
    zoomExtentsModifier.isAnimated = true
    
    // Add the modifier to the surface
    surface.chartModifiers.add(zoomExtentsModifier)
    
    Note

    To learn more about features available, please visit the Chart Modifier APIs article.

    Programmatically Zoom to Extents

    You can also run Zoom to Extents functionality programmatically without adding ZoomExtentsModifier. SciChartSurface supports the following methods which you can call whenever you need to zoom the chart to fit:

    • zoomExtents()
    • animateZoomExtents(long duration)
    • zoomExtentsY()
    • animateZoomExtentsY(long duration)
    • zoomExtentsX()
    • animateZoomExtentsX(long duration)
    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml