Search Results for

    Show / Hide Table of Contents

    The PinchZoomModifier

    SciChart Android provides pinch zooming via the PinchZoomModifier, available out of the box.

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

    • setScaleFactor(float scaleFactor) - allows to set ScaleFactor to change zooming speed.
    • setDirection(Direction2D direction) - allows to restrict zooming to the horizontal or vertical direction only if needed.

    Adding a PinchZoomModifier to a Chart

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

    • Java
    • Java with Builders API
    • Kotlin
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    PinchZoomModifier pinchZoomModifier = new PinchZoomModifier();
    pinchZoomModifier.setDirection(Direction2D.XDirection);
    pinchZoomModifier.setScaleFactor(1.5f);
    
    // Add the modifier to the surface
    surface.getChartModifiers().add(pinchZoomModifier);
    
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    final ModifierGroup pinchZoomModifierGroup = sciChartBuilder
            .newModifierGroup()
            .withPinchZoomModifier()
            .withXyDirection(Direction2D.XDirection)
            .withScaleFactor(1.5f)
            .build()
            .build();
    
    // Add the modifier to the surface
    surface.getChartModifiers().add(pinchZoomModifierGroup);
    
    // Assume a surface has been created and configured somewhere
    // Create a Modifier
    val pinchZoomModifier = PinchZoomModifier()
    pinchZoomModifier.direction = Direction2D.XDirection
    pinchZoomModifier.scaleFactor = 1.5f
    
    // Add the modifier to the surface
    surface.chartModifiers.add(pinchZoomModifier)
    

    Including/Excluding Axes from PinchZoomModifier

    You can include or exclude specific axes from being affected by the PinchZoomModifier. This is done by using the includeXAxis or includeYAxis method. Below is an example of including/excluding axes from PinchZoomModifier.

    • Java
    • Java with Builders API
    • Kotlin
    // Assume a pinchZoomModifier has been created and configured somewhere
    
    // To include/exclude an X axis in the pinchZoomModifier (true = include, false = exclude)
    pinchZoomModifier.includeXAxis(xAxis, true);
    pinchZoomModifier.includeXAxis(xAxis, false);
    
    // To include/exclude an Y axis from the pinchZoomModifier (true = include, false = exclude)
    pinchZoomModifier.includeYAxis(yAxis, true);
    pinchZoomModifier.includeYAxis(yAxis, false);
    
    // To include all X and Y axes to the pinchZoomModifier
    pinchZoomModifier.includeAllAxes();
    
    // Assume a pinchZoomModifier has been created and configured somewhere
    
    // To include/exclude an X axis in the pinchZoomModifier (true = include, false = exclude)
    pinchZoomModifier.includeXAxis(xAxis, true);
    pinchZoomModifier.includeXAxis(xAxis, false);
    
    // To include/exclude an Y axis from the pinchZoomModifier (true = include, false = exclude)
    pinchZoomModifier.includeYAxis(yAxis, true);
    pinchZoomModifier.includeYAxis(yAxis, false);
    
    // To include all X and Y axes to the pinchZoomModifier
    pinchZoomModifier.includeAllAxes();
    
    Note

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

    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml