SciChart Android 2D Charts API > 2D Chart Types > The Impulse (Stem) Series Type
The Impulse (Stem) Series Type

Impulse Series can be created using the FastImpulseRenderableSeries type.

Examples for the Impulse Series can be found in the SciChart Android Examples Suite

Impulse Series Features

The Impulse Series is a hybrid of Column Series and Scatter Series. So all three have their most important features in common.

Like the XyScatterRenderableSeries type, FastImpulseRenderableSeries requires a shape to be specified for Point Markers. There are several shapes available out of the box, also it is possible to define custom shapes. Please refer to the  PointMarkers API article to learn more.

And similarly to the FastColumnRenderableSeries type, it is possible to specify the baseline position for series' bars. This can be done by setting ZeroLineY via the setZeroLineY() method. All data points that have Y value less than  will be drawn downwards, else - upwards:

Finally, the stem color can be changed setting StrokeStyle via the setStrokeStyle() method Please refer to the articles under the Styling and Theming section to learn more about Brushes and Pens used in SciChart.

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 setXAxisId(), setYAxisId() methods of the series.

 

Create an Impulse Series

To create an Impulse Series, use the following code:

// Assume a surface has been created and configured somewhere
ISciChartSurface surface;

// Create an Ellipse PointMarker
IPointMarker pointMarker = new EllipsePointMarker();
pointMarker.setSize(40,40);

// Create a PenStyle for Stroke
PenStyle strokeStyle = new SolidPenStyle(ColorUtil.Yellow, true, 2, null);
pointMarker.setStrokeStyle(strokeStyle);

// Create a BrushStyle for Fill
BrushStyle markerFillStyle = new SolidBrushStyle(ColorUtil.argb(0xFF, 0x00, 0x66, 0xFF));
pointMarker.setFillStyle(markerFillStyle);

// Apply the PointMarker to the Impulse Series
FastImpulseRenderableSeries impulseSeries = new FastImpulseRenderableSeries<>();
impulseSeries.setPointMarker(pointMarker);

// Apply the StrokeStyle
impulseSeries.setStrokeStyle(strokeStyle);

// Specify position of the baseline
impulseSeries.setZeroLineY(0.2);

// Create a DataSeries for the Scatter Series
IXyDataSeries<Double, Double> dataSeries = new XyDataSeries<>(Double.class, Double.class);

// Assume some data has been added to the dataSeries here
// dataSeries.append(X, Y);

// Assign the dataSeries to the RenderableSeries
impulseSeries.setDataSeries(dataSeries);

// Add the RenderableSeries to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), impulseSeries);

The code from above will result in the following chart:

The same can be achieved using Chart Builders:

// Assume a surface has been created and configured somewhere
ISciChartSurface surface;

// Create an Ellipse PointMarker
EllipsePointMarker pointMarker = sciChartBuilder.newPointMarker(new EllipsePointMarker())
        .withSize(40, 40)
        .withStroke(ColorUtil.Yellow, 2)
        .withFill(ColorUtil.argb(0xFF, 0x00, 0x66, 0xFF))
        .build();

// Create a DataSeries for the Scatter Series
IXyDataSeries<Double, Double> dataSeries = new XyDataSeries(Double.class, Double.class);
 // Assume some data has been added to the dataSeries here
 // dataSeries.append(...);

// Create and configure a Scatter Series
IRenderableSeries impulseSeries = sciChartBuilder.newImpulseSeries()
        .withDataSeries(dataSeries)
        .withPointMarker(pointMarker)
        .withStrokeStyle(ColorUtil.argb(0xFF, 0x00, 0x66, 0xFF))
        .build();

// Add the Scatter RenderableSeries to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), impulseSeries);

Specify Color for Individual Bars

This can be achieved with the PaletteProvider API. It allows to change the fill color of any bar within an Impulse Series. To do this, a custom PaletteProvider that implements IStrokePaletteProvider and IPointMarkerPaletteProvider has to be provided to the setPaletteProvider() method.  Please refer to the PaletteProvider API article for more info.

See Also