SciChart Android 2D Charts API > 2D Chart Types > The Column Series Type
The Column Series Type

Column Series can be created using the FastColumnRenderableSeries type.

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

Column Series Features

The FastColumnRenderableSeries class allows to specify Fill brush, Stroke pen and relative DataPointWidth which will be applied to every column. The DataPointWidth specifies how much space a single column occupies, varying from 0 to 1 (when columns are conjoined). Please refer to the articles under the Styling and Theming section to learn more about Brushes and Pens used in SciChart.

Also, it is possible to set ZeroLineY to define the baseline position. All data points that have Y value less than ZeroLineY will be drawn downwards, else - upwards.

Those values can be assigned via the corresponding methods, setFillBrushStyle(), setStrokeStyle(), setDataPointWidth() and setZeroLineY().

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 a Column Series

To create a Column Series, use the following code:

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

// Create a PenStyle for Stroke
PenStyle strokeStyle = new SolidPenStyle(0xA99A8A, true, 2, null);

// Create a BrushStyle for Fill
BrushStyle fillStyle = new LinearGradientBrushStyle(0, 0, 0, 1, ColorUtil.LightSteelBlue, ColorUtil.SteelBlue, TileMode.CLAMP);

// Create and configure the Column Chart Series
FastColumnRenderableSeries columnSeries = new FastColumnRenderableSeries();
columnSeries.setStrokeStyle(strokeStyle);
columnSeries.setFillBrushStyle(fillStyle);

// Set relative width for columns
columnSeries.setDataPointWidth(0.8);

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

// Assign the dataSeries to the chart series
columnSeries.setDataSeries(dataSeries);

// Add the chart series to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), columnSeries); 

The same can be achieved using Chart Builders:

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

// Create a DataSeries for the chart 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 the Column Chart Series
final FastColumnRenderableSeries columnSeries = sciChartBuilder.newColumnSeries()
        .withStrokeStyle(0xA99A8A)
        .withDataPointWidth(1)
        .withLinearGradientColors(ColorUtil.LightSteelBlue, ColorUtil.SteelBlue)
        .withDataSeries(dataSeries)
        .build();

// Add the chart series to the RenderableSeriesCollection of the surface
Collections.addAll(surface.getRenderableSeries(), columnSeries);

Paint Columns With Different Colors

This can be achieved with the PaletteProvider API. It allows to change the color of any column within a Column Series. To do this, a custom IFillPaletteProvider  or IStrokePaletteProvider has to be provided to the setPaletteProvider() method:

Copy Code
// Create a PaletteProvider instance and assign it to the chart series
IPaletteProvider paletteProvider = new ColoredColumnsPaletteProvider();
columnSeries.setPaletteProvider(paletteProvider);

Please refer to the PaletteProvider API article for more info.

See Also