SciChart Android 2D Charts API > ChartModifier API > ChartModifier APIs > What is a ChartModifier
What is a ChartModifier

Within the SciChart SDK, ChartModifiers are the classes which can be added to a chart to give it a certain behaviour. For instance, all zooming, panning operations, tooltips, legends and even selection of points or lines are handled by ChartModifierBase derived classes in the SciChart codebase.

There are many different ChartModifiers provided by SciChart and each one deserves an article by itself! This article is concerned with simply giving an overview of the modifiers and where you can find the examples in our Examples Suite which demonstrate them.

There are also several individual articles on the ChartModifier's and how to configure them in the SciChart Android Documentation. Please find them at the bottom of this page.

Zoom, Pan Modifiers

The following modifiers can be used if you want to add scrolling or zooming behavior to a chart:

Modifier Name Description Demo Link
PinchZoomModifier Zooms a chart in and out via the pinch and spread gestures correspondingly. Available almost everywhere. For instance, see the Multiple X Axes example.
ZoomPanModifier Pans the chart in X, Y or both directions with inertia via finger sliding. Available almost everywhere. For instance, see the Multiple X Axes example.
XAxisDragModifier Scales or pans an X Axis via finger drag. Drag Axis to Scale a Chart
YAxisDragModifier Scales or pans an Y Axis via finger drag. Drag Axis to Scale a Chart
RubberBandXyZoomModifier Zooms a chart inside a rectangle or horizontal section that is drawn on the chart with a finger. Drag Area to Zoom
ZoomExtentsModifier Resets the zoom to the data extents via double-tapping. Available almost everywhere. For instance, see the Multiple X Axes example.

Interactivity, Tooltips, Cursor Modifiers

These modifiers allow to interact with chart series or inspect them:

Modifier Name Description Demo Link
SeriesSelectionModifier Provides selection of a series via tapping on it. Series Selection
TooltipModifier Provides a tooltip for the nearest point on a series under the finger. Using TooltipModifier Tooltips
RolloverModifier Provides a vertical slice cursor with tooltips and markers rolling over a series. Using RolloverModifier Tooltips
CursorModifier Provides a crosshairs with a tooltip and axis labels. Using CursorModifier Tooltips

Miscellaneous Modifiers

Modifiers below are used as helpers and can be a useful addition to a chart:

Modifier Name Description Demo Link
ModifierGroup Can be used to group chart modifiers together. This can useful in multi-chart scenarios, to unite ModifierGroups into one MotionEventGroup of modifiers. If a MotionEvent occurs on a chart, it will be propagated to modifiers from other charts that are in the same MotionEventGroup. Multi-Pane Stock Charts
LegendModifier Allows to creates and configure a Legend for a chart. Chart Legends API

 

To learn more about ChartModifiers API, please read the Common ChartModifiers Features article. To find out about a specific ChartModifier type, please refer to a corresponding article about this Modifier type.

Adding Chart Modifiers to a Chart

A ChartModifier can be added to a ChartModifiersCollection of a SciChartSurface via the getChartModifiers()setChartModifiers() methods. This can be done using the code below:

Copy Code
// Assume the surface has been created and configured earlier
ISciChartSurface surface;

// Create a LegendModifier
IChartModifier legendModifier = new LegendModifier(getActivity());

// Add the modifier to the surface
surface.getChartModifiers().add(legendModifier);

Also, it is possible to use Chart Builders to create and configure Chart Modifiers:

Copy Code
// Create a ModifierGroup with several modifiers
IChartModifier modifiers = sciChartBuilder
        .newModifierGroup()
        .withPinchZoomModifier().build()
        .withZoomPanModifier().withClipModex(ClipMode.StretchAtExtents).withXyDirection(XyDirection.XDirection).build()
        .withXAxisDragModifier().withClipModex(ClipMode.StretchAtExtents).withReceiveHandledEvents(true).build()
        .withRolloverModifier().withReceiveHandledEvents(true).build()
        .withZoomExtentsModifier().build()
        .build();

// Add the modifiers to the surface
surface.getChartModifiers().add(modifiers);

For convenience, the most commonly used modifiers available in a bunch via the SciChartBuilder.newModifierGroupWithDefaultModifiers(). The method returns a ModifierGroup with the PinchZoomModifierZoomPanModifier and ZoomExtentsModifier:

Copy Code
// Create a ModifierGroup with the PinchZoomModifier, ZoomPanModifier and ZoomExtentsModifier
IChartModifier modifiers = sciChartBuilder.newModifierGroupWithDefaultModifiers().build();

// Add the modifiers to the surface
surface.getChartModifiers().add(modifiers);

 

See Also