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:
// 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);
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: