Search Results for

    Show / Hide Table of Contents

    The Scatter Series Type

    Scatter Series can be created using the XyScatterRenderableSeries type.

    Scatter Series Type

    Note

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

    • Native Example
    • Xamarin Example

    The Scatter Series requires a shape to be specified for Point Markers. SciChart provides several shapes out of the box:

    • CrossPointMarker;
    • EllipsePointMarker;
    • SquarePointMarker;
    • TrianglePointMarker;
    • SpritePointMarker.

    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:

    • 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, -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);
        });
    }
    
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build();
        dataSeries.append(0.0, -3.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 FastBandRenderableSeries scatterSeries = sciChartBuilder.newBandSeries()
                .withDataSeries(dataSeries)
                .withPointMarker(pointMarker)
                .build();
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), sciChartBuilder.newNumericAxis().build());
            Collections.addAll(surface.getYAxes(), sciChartBuilder.newNumericAxis().build());
    
            Collections.addAll(surface.getRenderableSeries(), scatterSeries);
        });
    }
    
    override fun initExample(surface: SciChartSurface) {
        val scatterSeries = XyScatterRenderableSeries().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)
            }
    
            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, 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.
    • Draw Series With Different Colors.

    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.

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