The ZoomPanModifier
Chart Android provides an inertial scrolling / panning behavior via the ZoomPanModifier, available out of the box.
Besides common features which are inherited from the ChartModifierBase class, the ZoomPanModifier 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.
- setZoomExtentsY(boolean zoomExtentsY) - allows to to keep series' peeks always in viewport.
- setClipModeX(ClipMode clipModeX) - allows to specify the behavior when scrolling reaches data extents in X direction via the ClipMode enumeration.
There are several modes defined by the ClipMode enumeration:
- None - Means you can pan right off the edge of the data into uncharted space.
- StretchAtExtents - Causes a zooming (stretch) action when you reach the edge of the data.
- ClipAtMin - Forces the panning operation to stop suddenly at the minimum of the data, but expand at the maximum.
- ClipAtMax - Forces the panning operation to stop suddenly at the maximum of the data, but expand at the minimum.
- ClipAtExtents - Forces the panning operation to stop suddenly at the extents of the data.
Adding a ZoomPanModifier to a Chart
Any Chart Modifier can be added to a SciChartSurface via the chartModifiers property and ZoomPanModifier is no difference:
// Assume a surface has been created and configured somewhere
// Create a Modifier
final ZoomPanModifier zoomPanModifier = new ZoomPanModifier();
zoomPanModifier.setDirection(Direction2D.XDirection);
zoomPanModifier.setClipModeX(ClipMode.StretchAtExtents);
zoomPanModifier.setClipModeY(ClipMode.None);
zoomPanModifier.setZoomExtentsY(true);
// Add the modifier to the surface
surface.getChartModifiers().add(zoomPanModifier);
Note
To learn more about features available, please visit the Chart Modifier APIs article.