Zoom Extents Modifier 3D
SciChart Android 3D provides the ability to zoom-to-fit the entire 3D chart by double-tapping it via the ZoomExtentsModifier3D, available out of the box.
Besides common features which are inherited from the ChartModifierBase3D class, the ZoomExtentsModifier3D allows to control its specific features via the following properties:
- setResetTarget(Vector3 resetTarget) - defines the Vector3 target where the setTarget(Vector3 target) is moved on reset.
- setResetPosition(Vector3 resetPosition) - defines the Vector3 target where the setPosition(Vector3 position) is moved on reset.
- setExecuteOn(ExecuteOn executeOn) - allows to specify the trigger action for the modifier via the ExecuteOn enumeration.
- setAutoFitRadius(boolean autoFitRadius) - When
true
, attempts to auto-fit the camera radius to fit the scene. Whenfalse
- uses the setResetPosition(Vector3 resetPosition) and setResetTarget(Vector3 resetTarget) instead. - setAnimationDuration(long animationDuration) - defines the animation duration in
long
for any zoom operations.
Note
There are several modes defined by the ExecuteOn enumeration, such as Single Tap, Double Tap, Long Press, and Fling.
There are two modes of operation for the ZoomExtentsModifier3D - AutoFit and Manual:
Operation Mode | Description |
---|---|
autoFitRadius = true |
Tries to automatically fit the 3D scene into the viewport. getTarget() and getPosition() methods are ignored. |
autoFitRadius = false |
You should specify the precise coordinates in the setTarget(Vector3 target) and setPosition(Vector3 position) methods. |
Adding a ZoomExtentsModifier to a Chart
Any Chart Modifier 3D can be added to a SciChartSurface3D via the chartModifiers property and ZoomExtentsModifier3D is no difference:
// Assume a surface has been created and configured somewhere
// Create a Modifier
final ZoomExtentsModifier3D zoomExtentsModifier = new ZoomExtentsModifier3D();
zoomExtentsModifier.setExecuteOn(ExecuteOn.DoubleTap);
zoomExtentsModifier.setAutoFitRadius(false);
zoomExtentsModifier.setResetPosition(new Vector3(200, 200, 200));
zoomExtentsModifier.setResetTarget(new Vector3(0, 0, 0));
// Add the modifier to the surface
surface.getChartModifiers().add(zoomExtentsModifier);
Note
To learn more about features available, please visit the Chart Modifier 3D APIs article.
Programmatically Zoom to Extents
You can also run Zoom to Extents functionality programmatically without adding ZoomExtentsModifier3D. The Camera3D object which is associated with SciChartSurface3D provides the following methods which you can call whenever you need to zoom the chart to fit: