The Scatter Series Type
Scatter Series can be created using the XyScatterRenderableSeries type.
Note
Examples for the Scatter Series can be found in the SciChart Android Examples Suite as well as on GitHub:
The Scatter Series requires a shape to be specified for Point Markers. SciChart provides several shapes out of the box:
It is also possible to define custom shapes of the Point Markers. Please refer to the PointMarkers API article to learn more. You can also override colors of the Point Markers individually using PaletteProvider API.
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 xAxisId, yAxisId properties.
Create a Scatter Series
To create a XyScatterRenderableSeries, use the following code:
@Override
protected void initExample(@NonNull SciChartSurface surface) {
final IXyDataSeries<Double, Double> dataSeries = new XyDataSeries<>(Double.class, Double.class);
dataSeries.append(0.0, -3.0);
dataSeries.append(1.0, 1.0);
dataSeries.append(2.0, 4.0);
final EllipsePointMarker pointMarker = new EllipsePointMarker();
pointMarker.setFillStyle(new SolidBrushStyle(Color.CYAN));
pointMarker.setSize(20,20);
final XyScatterRenderableSeries scatterSeries = new XyScatterRenderableSeries();
scatterSeries.setDataSeries(dataSeries);
scatterSeries.setPointMarker(pointMarker);
UpdateSuspender.using(surface, () -> {
Collections.addAll(surface.getXAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getYAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getRenderableSeries(), scatterSeries);
});
}
In the code above, a Scatter Series instance is created. It is assigned to draw the data that is provided by the IDataSeries<TX,TY> assigned to it. The Scatters are drawn with a PointMarker provided by the EllipsePointMarker instance. Finally, the Scatter Series is added to the renderableSeries property.
Scatter Series Features
Scatter Series also has some features similar to other series, such as:
Render a Gap in a Scatter Series
It's possible to render a Gap in Scatter series, by passing a data point with a NaN
as the Y
value. Please refer to the RenderableSeries APIs article for more details.
Paint Scatters With Different Colors
In SciChart, you can draw each scatter of the Scatter Series with different colors using the PaletteProvider API. To Use palette provider for scatters - a custom IPointMarkerPaletteProvider has to be provided to the paletteProvider property. Please refer to the PaletteProvider API article for more info.