SciChart Android 2D Charts API > 2D Chart Types > The Scatter Series Type
The Scatter Series Type

Scatter Series can be created using the XyScatterRenderableSeries type.

Examples for the Scatter Series can be found in the SciChart Android Examples Suite

Scatter Series Features

The Scatter Series requires a shape to be specified for Point Markers. SciChart provides several shapes out of the box, also it is possible to define custom shapes. Please refer to the PointMarkers API article to learn more. The PaletteProvider API allows to override colors for Point Markers, up to coloring every one individually.

Note:

In multi axis scenarios, a series has to be assigned to particular X and Y axes. This can be done passing the axes IDs to the setXAxisId(), setYAxisId() methods of the series.

Create a Scatter Series

To create the Scatter Series, use the following code:

// Assume a surface has been created and configured somewhere
ISciChartSurface surface;

// Create an Ellipse PointMarker
 IPointMarker pointMarker = new EllipsePointMarker();
 pointMarker.setSize(40,40);

// Create a PenStyle for Stroke
 PenStyle strokeStyle = new SolidPenStyle(ColorUtil.Green, true, 2, null);
 pointMarker.setStrokeStyle(strokeStyle);

// Create a BrushStyle for Fill
 BrushStyle fillStyle = new SolidBrushStyle(ColorUtil.Red);
 pointMarker.setFillStyle(fillStyle);

// Apply the PointMarker to the Scatter Series
IRenderableSeries scatterSeries = new XyScatterRenderableSeries();
scatterSeries.setPointMarker(pointMarker);

// Create a DataSeries for the Scatter Series
IXyDataSeries<Double, Double> dataSeries = new XyDataSeries<>(Double.class, Double.class);
// Assume some data has been added to the dataSeries here
// dataSeries.append(...);

// Assign the dataSeries to the Line RenderableSeries
scatterSeries.setDataSeries(dataSeries);

// Add the Scatter RenderableSeries to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), scatterSeries);

The same can be achieved using Chart Builders:

// Assume a surface has been created and configured somewhere
ISciChartSurface surface;

// Create an Ellipse PointMarker
final EllipsePointMarker pointMarker = sciChartBuilder.newPointMarker(new EllipsePointMarker())
        .withSize(15, 15)
        .withStroke(ColorUtil.argb(255, 176, 196, 222), 2)
        .withFill(ColorUtil.argb(255, 70, 130, 180))
        .build();

// Create a DataSeries for the Scatter Series
IXyDataSeries<Double, Double> dataSeries = new XyDataSeries<>(Double.class, Double.class);
 // Assume some data has been added to the dataSeries here
 // dataSeries.append(...);

// Create and configure a Scatter Series
final IRenderableSeries scatterSeries = sciChartBuilder.newScatterSeries()
        .withDataSeries(dataSeries)
        .withPointMarker(pointMarker)
        .withStrokeStyle(ColorUtil.argb(0xFF, 0x27, 0x9B, 0x27))
        .withPaletteProvider(new HorizontalThresholdPaletteProvider(upperLimit, lowerLimit))
        .build();

// Add the Scatter RenderableSeries to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), scatterSeries);

Color Some Point Markers Differently

The PaletteProvider API allows to fill certain PointMarkers with a different color:

To do this, implement the IPointMarkerPaletteProvider interface and assign an instance of that type to XyScatterRenderableSeries via the setPaletteProvider() method. Please refer to the PaletteProvider API article for more info.

See Also