SciChart Android 2D Charts API > ChartModifier API > Selection and Legends > Series Selection Modifier
Series Selection Modifier

SciChart features the SeriesSelectionModifier, which allows selection of the upmost RenderableSeries at a touch position:

SeriesSelectionModifier Usage

The SeriesSelectionModifier allows setting of SelectedSeriesStyle, which is applied to a RenderableSeries after it has been selected by the modifier. Internally, the modifier calls setIsSelected() method on the topmost RenderableSeries to make it selected and tries to apply the SelectedSeriesStyle calling the setSelectedSeriesStyle() method on it.

The SelectedSeriesStyle has to implement the ISeriesStyle interface:

Copy Code
public interface ISeriesStyle {
     * Applies this style to specified renderable series.
     * @param renderableSeries The target renderable series.
    void applyStyle(IRenderableSeries renderableSeries);
     * Discards this style on specified renderable series.
     * @param renderableSeries The target renderable series.
    void discardStyle(IRenderableSeries renderableSeries);
     * Gets the target renderable series type.
     * @return The target renderable series type.
    Class<? extends IRenderableSeries> getSeriesType();

In an implementation of the interface, you should provide the desired behavior for a RenderableSeries:

Method Description
applyStyle() In this method you have to make the desired changes to a RenderableSeries. It is called when a series gets selected.
discardStyle() In this method you have to discard all the changes made in the applyStyle() call.
getSeriesType() Returns the type of a RenderableSeries that this Style is to be applied to.

For more convenience, there is a basic implementation called SeriesStyleBase. Extending it, you will need to implement the applyStyleInternal() and discardStyleInternal() methods instead. Please find a code sample below.


If you need to be able to select multiple RenderableSeries of different types, you can return the IRenderableSeries as the RenderableSeries type, as it is shown in the code sample below. Alternatively, it is possible to have several SeriesSelectionModifiers with Styles for different RenderableSeries types and ReceiveHandledEvents set to True.

Adding a SeriesSelectionModifier 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 SeriesSelectionModifier
SeriesSelectionModifier seriesSelectionModifier = new SeriesSelectionModifier();

// Create an ISeriesStyle that will be applied when a Series gets selected.
ISeriesStyle selectedSeriesStyle = new SeriesStyleBase<IRenderableSeries>(IRenderableSeries.class) {
    private final PenStyle selectedStrokeStyle = sciChartBuilder.newPen().withColor(ColorUtil.White).withThickness(4f).build();
    private final IPointMarker selectedPointMarker = sciChartBuilder.newPointMarker(new EllipsePointMarker()).withSize(10, 10).withFill(0xFFFF00DC).withStroke(ColorUtil.White, 1f).build();
    private static final String STROKE = "Stroke";
    private static final String POINT_MARKER = "PointMarker";

    protected void applyStyleInternal(IRenderableSeries renderableSeriesToStyle) {
        putPropertyValue(renderableSeriesToStyle, STROKE, renderableSeriesToStyle.getStrokeStyle());
        putPropertyValue(renderableSeriesToStyle, POINT_MARKER, renderableSeriesToStyle.getPointMarker());
    protected void discardStyleInternal(IRenderableSeries renderableSeriesToStyle) {
        renderableSeriesToStyle.setStrokeStyle(getPropertyValue(renderableSeriesToStyle, STROKE, PenStyle.class));
        renderableSeriesToStyle.setPointMarker(getPropertyValue(renderableSeriesToStyle, POINT_MARKER, IPointMarker.class));

// Set a style which will be applied to a RenderableSeries when selected

// Add the modifier to the surface

Also a SeriesSelectionModifier can be created using Chart Builders. To learn more about features available, Please refer to the Common ChartModifiers Features article.

See Also