The Spline Band Series Type
Spline Band Series are provided by the SplineBandRenderableSeries type. This accepts data (X, Y, Y1
) from a XyyDataSeries<TX,TY> and renders two lines with a polygon, which changes color depending on whether Y > Y1
or vice versa.
Note
For more info about XyyDataSeries<TX,TY>, as well as other DataSeries types in SciChart, see the DataSeries API article.
The Spline Band Series can be used to render profit & loss (green / red above or below a zero line), shaded areas of interest, technical indicators such as MACD and Ichimoku, or to simply shade an area above or below a threshold.
Note
Examples for the Spline Band Series can be found in the SciChart Android Examples Suite as well as on GitHub:
The SplineBandRenderableSeries class allows to specify Fill, FillY1 brushes and Stroke, StrokeY1 pens via the following properties:
Note
To learn more about Pens and Brushes and how to utilize them, please refer to the PenStyle, BrushStyle and FontStyle article.
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 Spline Band Series
To create a Spline Band Series, use the following code:
@Override
protected void initExample(@NonNull SciChartSurface surface) {
final IXyyDataSeries<Double, Double> dataSeries = new XyyDataSeries<>(Double.class, Double.class);
dataSeries.append(0.0, 0.0, 1.0);
dataSeries.append(1.0, 1.0, 0.0);
dataSeries.append(2.0, 4.0, 0.0);
final SplineBandRenderableSeries splineBandSeries = new SplineBandRenderableSeries();
splineBandSeries.setDataSeries(dataSeries);
splineBandSeries.setStrokeStyle(new SolidPenStyle(Color.RED, true, 1f, null));
splineBandSeries.setStrokeY1Style(new SolidPenStyle(Color.BLUE, true, 1f, null));
splineBandSeries.setFillBrushStyle(new SolidBrushStyle(Color.CYAN));
splineBandSeries.setFillY1BrushStyle(new SolidBrushStyle(Color.YELLOW));
UpdateSuspender.using(surface, () -> {
Collections.addAll(surface.getXAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getYAxes(), new NumericAxis(requireContext()));
Collections.addAll(surface.getRenderableSeries(), splineBandSeries);
});
}
Spline Band Series Features
Spline Band Series also has some features similar to other series, such as:
Render a Gap in a Spline Band Series
It's possible to render a Gap in Spline Band series, by passing a data point with a NaN
as the Y and Y1
value. Please refer to the RenderableSeries APIs article for more details. The SplineBandRenderableSeries, 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 Band Series
Every data point of a Spline Band Series can be marked with a IPointMarker. To add Point Markers to a Spline Band Series use the pointMarker property. For more information and code examples, please refer to the PointMarkers API article.
Paint Spline Band Area Parts with Different Colors
In SciChart, you can draw Spline Band Series segments with different colors using the PaletteProvider API. To Use palette provider for Spline Band Series - a custom IFillPaletteProvider (or IStrokePaletteProvider) has to be provided to the paletteProvider property. Please refer to the PaletteProvider API article for more info.