The Spline Line Series Type
Spline Line Series can be created using the SplineLineRenderableSeries type.
Note
Examples of the Spline Line Series can be found in the SciChart Android Examples Suite as well as on GitHub:
Create a Spline Line Series
To create a SplineLineRenderableSeries, 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, 0.0);
dataSeries.append(1.0, 1.0);
dataSeries.append(2.0, 4.0);
final SplineLineRenderableSeries splineLineSeries = new SplineLineRenderableSeries();
splineLineSeries.setDataSeries(dataSeries);
splineLineSeries.setStrokeStyle(new SolidPenStyle(Color.RED, true, 1f, null));
UpdateSuspender.using(surface, () -> {
Collections.addAll(surface.getXAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getYAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getRenderableSeries(), splineLineSeries);
});
}
In the code above, a Spline Line Series instance is created. It is assigned to draw the data that is provided by the IDataSeries<TX,TY> assigned to it. The line is drawn with a Pen provided by the PenStyle instance. Finally, the Spline Line Series is added to the renderableSeries property.
Spline Line Series Features
Spline Line Series also has some features similar to other series, such as:
Render a Gap in a Spline Line Series
It is possible to show a gap in a Spline Line Series by passing a data point with a NaN
as the Y value. Please refer to the RenderableSeries APIs article for more details. The SplineLineRenderableSeries, however, allows to specify how a gap should appear. You can treat NAN
values as gaps or close the line. That's defined by the drawNaNAs property (Please see LineDrawMode enumeration).
Note
Please note, even though Gaps via NaN values in spline series is supported, ClosedGaps feature, which is available in regular (non-spline) series, aren't supported with splines.
Add Point Markers onto a Spline Line Series
Every data point of a Spline Line Series can be marked with a IPointMarker. To add Point Markers to the Spline Line Series, 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, 0.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 SplineLineRenderableSeries splineLineSeries = new SplineLineRenderableSeries();
splineLineSeries.setDataSeries(dataSeries);
splineLineSeries.setStrokeStyle(new SolidPenStyle(Color.RED, true, 1f, null));
splineLineSeries.setPointMarker(pointMarker);
UpdateSuspender.using(surface, () -> {
Collections.addAll(surface.getXAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getYAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getRenderableSeries(), splineLineSeries);
});
}
To learn more about Point Markers, please refer to the PointMarkers API article.
Note
This feature can be used to create a Scatter Series, if strokeStyle contains a transparent Pen.
Paint Spline Line Segments With Different Colors
In SciChart, you can draw line segments with different colors using the PaletteProvider API. To Use palette provider for Spline Line Series - a custom IStrokePaletteProvider has to be provided to the paletteProvider property. For more information - please refer to the PaletteProvider API article.