Search Results for

    Show / Hide Table of Contents

    The Spline Line Series Type

    Spline Line Series can be created using the SplineLineRenderableSeries type.

    Spline Line Series Type

    Note

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

    • Native Example
    • Xamarin Example

    Create a Spline Line Series

    To create a SplineLineRenderableSeries, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    @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);
        });
    }
    
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build();
        dataSeries.append(0.0, 0.0);
        dataSeries.append(1.0, 1.0);
        dataSeries.append(2.0, 4.0);
    
        final SplineLineRenderableSeries splineLineSeries = sciChartBuilder.newSplineLineSeries()
                .withDataSeries(dataSeries)
                .withStrokeStyle(Color.RED, 1f, true)
                .build();
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), sciChartBuilder.newNumericAxis().build());
            Collections.addAll(surface.getYAxes(), sciChartBuilder.newNumericAxis().build());
    
            Collections.addAll(surface.getRenderableSeries(), splineLineSeries);
        });
    }
    
    override fun initExample(surface: SciChartSurface) {
        val splineLineSeries = SplineLineRenderableSeries().apply {
            dataSeries = XyDataSeries(Double::class.javaObjectType, Double::class.javaObjectType).apply {
                append(0.0, 0.0)
                append(1.0, 1.0)
                append(2.0, 4.0)
            }
    
            strokeStyle = SolidPenStyle(Color.RED, true, 1f, null)
        }
    
        UpdateSuspender.using(surface) {
            Collections.addAll(surface.xAxes, NumericAxis(context))
            Collections.addAll(surface.yAxes, NumericAxis(context))
    
            Collections.addAll(surface.renderableSeries, 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
    • Draw Point Markers
    • Draw Series With Different Colors

    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:

    Point Markers

    • Java
    • Java with Builders API
    • Kotlin
    @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);
        });
    }
    
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build();
        dataSeries.append(0.0, 0.0);
        dataSeries.append(1.0, 1.0);
        dataSeries.append(2.0, 4.0);
    
        final EllipsePointMarker pointMarker = sciChartBuilder.newPointMarker(new EllipsePointMarker())
                .withFill(Color.CYAN)
                .withSize(20)
                .build();
    
        final SplineLineRenderableSeries splineLineSeries = sciChartBuilder.newSplineLineSeries()
                .withDataSeries(dataSeries)
                .withStrokeStyle(Color.RED, 1f, true)
                .withPointMarker(pointMarker)
                .build();
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), sciChartBuilder.newNumericAxis().build());
            Collections.addAll(surface.getYAxes(), sciChartBuilder.newNumericAxis().build());
    
            Collections.addAll(surface.getRenderableSeries(), splineLineSeries);
        });
    }
    
    override fun initExample(surface: SciChartSurface) {
        val splineLineSeries = SplineLineRenderableSeries().apply {
            dataSeries = XyDataSeries(Double::class.javaObjectType, Double::class.javaObjectType).apply {
                append(0.0, 0.0)
                append(1.0, 1.0)
                append(2.0, 4.0)
            }
    
            strokeStyle = SolidPenStyle(Color.RED, true, 1f, null)
    
            pointMarker = EllipsePointMarker().apply {
                fillStyle = SolidBrushStyle(Color.CYAN)
                width = 20
                height = 20
            }
        }
    
        UpdateSuspender.using(surface) {
            Collections.addAll(surface.xAxes, NumericAxis(context))
            Collections.addAll(surface.yAxes, NumericAxis(context))
    
            Collections.addAll(surface.renderableSeries, 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.

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