Stacked Column Chart in React Chart component
14 Oct 202424 minutes to read
Stacked column
To render a stacked column series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
type
asStackingColumn
in your chart configuration. This indicates that the data should be represented as a stacked column chart, where each column consists of multiple segments stacked on top of each other. -
Inject the StackingColumnSeries module: Inject
StackingColumnSeries
module into theservices
. This step is essential, as it ensures that the necessary functionalities for rendering stacked column series are available in your chart.
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
The following properties can be used to customize the stacked column
series.
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 }
];
The fill property can be used to apply a gradient color to the stacked column series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
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 specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
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 }
];
Dash array
The dashArray property determines the pattern of dashes and gaps in 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'
};
const border = { width: 1.5, color: 'Blue'}
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' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border} dashArray='2.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'
};
const border: object = { width: 1.5, color: 'Blue'};
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' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border} dashArray='2.5'>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border} dashArray='2.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 customize the width and color of the series border.
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 border = { width: 1.5, color: 'Blue'}
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' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border}>
</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 border: object = { width: 1.5, color: 'Blue'};
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' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y1' name='Germany' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y2' name='France' type='StackingColumn' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stackColumndata} xName='x' yName='y3' name='Italy' type='StackingColumn' border={border}>
</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. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points 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 customize the fill color of empty points in 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'
};
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 width and color of the border 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 cylindrical stacked column chart, set the columnFacet
property to Cylinder
in the chart series. This property transforms the regular stacked columns into cylindrical shapes, enhancing the visual representation of the data.
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 columns and 100% stacked columns. Columns with the same group name are stacked on top of each other.
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 }
];
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
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 allows you to customize each data point before it is rendered on the chart.
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 }
];