Search Results for

    Show / Hide Table of Contents

    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.

    Spline Band Series Type

    Note

    Examples for the Spline Band Series can be found in the SciChart Android Examples Suite as well as on GitHub:

    • Native Example
    • Xamarin Example

    The SplineBandRenderableSeries class allows to specify Fill, FillY1 brushes and Stroke, StrokeY1 pens via the following properties:

    • fillBrushStyle
    • fillY1BrushStyle
    • strokeStyle
    • strokeY1Style
    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:

    • Java
    • Java with Builders API
    • Kotlin
    @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);
        });
    }
    
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IXyyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyyDataSeries(Double.class, Double.class).build();
        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 = sciChartBuilder.newSplineBandSeries()
                .withDataSeries(dataSeries)
                .withStrokeStyle(Color.RED, 1f, true)
                .withStrokeY1Style(Color.BLUE, 1f, true)
                .withFillColor(Color.CYAN)
                .withFillY1Color(Color.YELLOW)
                .build();
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), sciChartBuilder.newNumericAxis().build());
            Collections.addAll(surface.getYAxes(), sciChartBuilder.newNumericAxis().build());
    
            Collections.addAll(surface.getRenderableSeries(), splineBandSeries);
        });
    }
    
    override fun initExample(surface: SciChartSurface) {
        val splineBandSeries = SplineBandRenderableSeries().apply {
            dataSeries = XyyDataSeries(Double::class.javaObjectType, Double::class.javaObjectType).apply {
                append(0.0, 0.0, 1.0)
                append(1.0, 1.0, 0.0)
                append(2.0, 4.0, 0.0)
            }
    
            strokeStyle = SolidPenStyle(Color.RED, true, 1f, null)
            strokeY1Style = SolidPenStyle(Color.BLUE, true, 1f, null)
    
            fillBrushStyle = SolidBrushStyle(Color.CYAN)
            fillY1BrushStyle = SolidBrushStyle(Color.YELLOW)
        }
    
        UpdateSuspender.using(surface) {
            Collections.addAll(surface.xAxes, NumericAxis(context))
            Collections.addAll(surface.yAxes, NumericAxis(context))
    
            Collections.addAll(surface.renderableSeries, splineBandSeries)
        }
    }
    

    Spline Band Series Features

    Spline Band Series also has some features similar to other series, such as:

    • Render a Gap
    • Draw Point Markers
    • Draw Series with Different Colors

    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.

    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml