Stacked Column Chart in React Chart
17 Aug 202624 minutes to read
Stacked column
Follow these steps to render a stacked column series, which stacks multiple column series vertically within each category to compare segment contributions across categories. To display proportional totals (100%), use StackingColumn100 with the same configuration.
-
Set the series type: Set the series
typetoStackingColumnin the series configuration. -
Inject the StackingColumnSeries module: Add
StackingColumnSeriesto theservicesarray of theInjectcomponent insideChartComponent. This registers the functionality required to render a stacked column series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Binding data with series
You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName and yName properties.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Series customization
Customize the stacked column series appearance with the following properties. Defaults are taken from the standard Series model.
| Property | Type | Default | Description |
|---|---|---|---|
fill |
string | null |
Color applied to the series. Accepts a CSS color or a gradient reference. |
opacity |
number | 1 |
Transparency of the fill (0 to 1). |
border |
BorderModel |
null |
Border settings: width, color, and dashArray. |
cornerRadius |
CornerRadiusModel |
null |
Per-corner radius for the stacked column segments (topLeft, topRight, bottomLeft, bottomRight). |
Solid fill
The fill property determines the color applied to the series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' fill='yellow'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' fill='green'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' fill='blue'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' fill='red'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' fill='yellow'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' fill='green'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' fill='blue'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' fill='red'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Gradient fill
The fill property can be set to a CSS gradient reference such as url(#gradient) to apply a gradient color that transitions across the series. Define the gradient in an SVG <defs> block and reference it from the fill prop.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' fill='url(#gradient1)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' fill='url(#gradient2)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' fill='url(#gradient3)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' fill='url(#gradient4)'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' fill='url(#gradient1)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' fill='url(#gradient2)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' fill='url(#gradient3)'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' fill='url(#gradient4)'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Opacity
The opacity property controls the transparency of the fill (0 to 1) and affects how the series blends with background or overlapping series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Border
Use the border property to configure the border width, color, and dashArray of the stacked column series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = {
title: 'Years',
interval: 1,
valueType: 'Category'
};
const primaryyAxis = {
title: 'Sales in Billions',
minimum: 0,
maximum: 700,
interval: 100,
labelFormat: '{value}B'
};
const border = { width: 2, color: '#ff4251', dashArray: '5,5' };
const border1 = { width: 2, color: '#66BDB7', dashArray: '5,5' };
const border2 = { width: 2, color: '#794F1B', dashArray: '5,5' };
const border3 = { width: 2, color: '#1a9a6f', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border2}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border3}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, AxisModel, BorderModel, Legend, Category, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = {
title: 'Years',
interval: 1,
valueType: 'Category'
};
const primaryyAxis: AxisModel = {
title: 'Sales in Billions',
minimum: 0,
maximum: 700,
interval: 100,
labelFormat: '{value}B'
};
const border: BorderModel = { width: 2, color: '#ff4251', dashArray: '5,5' };
const border1: BorderModel = { width: 2, color: '#66BDB7', dashArray: '5,5' };
const border2: BorderModel = { width: 2, color: '#794F1B', dashArray: '5,5' };
const border3: BorderModel = { width: 2, color: '#1a9a6f', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border2}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border3}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Empty points
Data points with null or undefined values are considered empty. By default (mode: 'Gap'), empty points leave a gap in the stack; the mode property on emptyPointSettings lets you change how they are handled.
Mode
Use the mode property to control handling of empty points. Available modes: Gap, Drop, Zero, Average. The default mode is Gap.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average'};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average'};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Fill
Use the fill property to set the fill color for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average', fill: 'red'};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average', fill: 'red'};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Border
Use the border property to customize the border width and color for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average', fill: 'red', border: {width: 2, color: 'Green'}};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average', border: {width: 2, color: 'Green'}};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: null, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: null, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Cylindrical stacked column chart
To render a stacked column with cylindrical (rounded) ends instead of a flat shape, set the columnFacet property to Cylinder on the chart series. The default value is Rect.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection
}
from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' columnFacet='Cylinder'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Stacking group
Use the stackingGroup property to group stacked column series. Series sharing the same group name are stacked together within a category; series in different groups are rendered as separate stacks side-by-side. The property accepts any string value.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' stackingGroup="UKAndGermany">
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' stackingGroup="UKAndGermany">
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' stackingGroup= 'FranceAndItaly'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' stackingGroup= 'FranceAndItaly'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' stackingGroup="UKAndGermany">
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' stackingGroup="UKAndGermany">
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' stackingGroup= 'FranceAndItaly'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' stackingGroup= 'FranceAndItaly'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Stack labels
The stack labels in stacked charts display cumulative total values for stack segments as inline data labels. If a stacked point has negative values, the stack labels are displayed below the point. Stack labels are independent of the dataLabel settings within each series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'
stackLabels={{ visible: true }}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'
stackLabels={{ visible: true }}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Stack labels customization
Stack labels have various properties for customization to enhance the visual based on your requirements:
| Property | Type | Default | Description |
|---|---|---|---|
visible |
boolean | false |
Specifies whether stack labels are visible. Setting to true displays the labels. |
fill |
string | transparent |
Background color of the stack labels. Accepts valid CSS color strings (hex, RGBA, etc.). |
format |
string | null |
Format string for the label text. Supports placeholders such as {value}. |
angle |
number | 0 |
Rotation angle for stack labels in degrees. |
rx |
number | 5 |
Rounded corner radius along the X-axis for the stack label background. |
ry |
number | 5 |
Rounded corner radius along the Y-axis for the stack label background. |
margin |
MarginModel |
null |
Margin around the stack label (left, right, top, bottom). |
border |
BorderModel |
null |
Border appearance of the stack label. |
font |
StackLabelsFontModel |
null |
Font customization (size, color, fontStyle, fontWeight, fontFamily). |
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'
stackLabels={{ visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } }}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country'
stackLabels={{ visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } }}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Corner radius
The cornerRadius property on the chart series is used to round the corners of stacked column segments. Each corner can be customized individually using topLeft, topRight, bottomLeft, and bottomRight; values are in pixels.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' cornerRadius = {{topRight: 10 , topLeft: 10}}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' cornerRadius = {{topRight: 10 , topLeft: 10}} >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args: IPointRenderEventArgs) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn' cornerRadius = {{topRight: 10 , topLeft: 10}}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' cornerRadius = {{topRight: 10 , topLeft: 10}}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: -111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: -127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: -143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: -159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: -175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: -189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: -202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: -111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: -127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: -143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: -159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: -175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: -189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: -202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Point corner radius
You can override the corner radius for individual stacked column points by using the pointRender event and setting the cornerRadius property on the event-args object. Use this to apply conditional rounding (for example, larger radius on the topmost segment of each stack).
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args) => {
if (args.point.index === 0 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 3 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 4 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 6 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.index === 0 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 3 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 4 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
if (args.point.index === 6 && args.point.series.index === 3) {
args.cornerRadius = { topLeft: 10, bottomLeft: 0, topRight: 10, bottomRight: 0 };
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Events
Series render
The seriesRender event fires before each series is rendered and lets you modify series properties such as data, fill, or name. For a stacked column series, use it to vary per-series fill or stackingGroup between renders.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const seriesRender = (args) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country' seriesRender={seriesRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, ISeriesRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const seriesRender = (args: ISeriesRenderEventArgs) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country' seriesRender={seriesRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];Point render
The pointRender event fires before each data point is drawn, letting you customize per-point marker shape, border, fill, or corner radius. For a stacked column series, use it to apply conditional formatting on individual column segments.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StackingColumnSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stackColumndata } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = {
title: 'Sales in Billions', minimum: 0, maximum: 700, interval: 100,
labelFormat: '{value}B'
};
const pointRender = (args: IPointRenderEventArgs) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Mobile Game Market by Country' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y' name='UK' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' >
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stackColumndata = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];export let stackColumndata: Object[] = [
{ x: '2014', y: 111.1, y1: 76.9, y2: 66.1, y3: 34.1 },
{ x: '2015', y: 127.3, y1: 99.5, y2: 79.3, y3: 38.2 },
{ x: '2016', y: 143.4, y1: 121.7, y2: 91.3, y3: 44.0 },
{ x: '2017', y: 159.9, y1: 142.5, y2: 102.4, y3: 51.6 },
{ x: '2018', y: 175.4, y1: 166.7, y2: 112.9, y3: 61.9 },
{ x: '2019', y: 189.0, y1: 182.9, y2: 122.4, y3: 71.5 },
{ x: '2020', y: 202.7, y1: 197.3, y2: 120.9, y3: 82.0 }
];