100% Stacked Column Chart in React Chart
100% stacked column
Follow these steps to render a 100% stacked column series, which stacks multiple column series within each category and normalizes them to a percentage of the total. Use this when comparing proportional contributions across categories; for absolute totals, use StackingColumn instead.
-
Set the series type: Set the series
typetoStackingColumn100in the series configuration. -
Inject the StackingColumnSeries module: Add
StackingColumnSeriesto theservicesarray of theInjectcomponent insideChartComponent. This registers the functionality required to render a 100% 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];Series customization
Customize the 100% 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 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' fill='red'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' fill='yellow'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' fill='green'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' fill='blue'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' fill='red'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' fill='yellow'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' fill='blue'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' fill='green'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' fill='url(#gradient1)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' fill='url(#gradient2)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' fill='url(#gradient3)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' 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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' fill='url(#gradient1)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' fill='url(#gradient2)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' fill='url(#gradient3)'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' fill='url(#gradient4)'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' 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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 880, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 135, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];Border
Use the border property to configure the border width, color, and dashArray of the 100% stacked column series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, DateTime, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { columnperData } from './datasource';
function App() {
const primaryxAxis = {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
};
const primaryyAxis = {
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%'
};
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='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, DateTime]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' border={border2}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' 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, DateTime, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
};
const primaryyAxis: AxisModel = {
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%'
};
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='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, DateTime]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' border={border2}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' border={border3}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: new Date(2006, 0, 1), y: 900, y1: 190, y2: 250, y3: 150 },
{ x: new Date(2007, 0, 1), y: 544, y1: 226, y2: 145, y3: 120 },
{ x: new Date(2008, 0, 1), y: 880, y1: 194, y2: 190, y3: 115 },
{ x: new Date(2009, 0, 1), y: 675, y1: 250, y2: 220, y3: 125 },
{ x: new Date(2010, 0, 1), y: 765, y1: 222, y2: 225, y3: 132 },
{ x: new Date(2011, 0, 1), y: 679, y1: 181, y2: 135, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: new Date(2006, 0, 1), y: 900, y1: 190, y2: 250, y3: 150 },
{ x: new Date(2007, 0, 1), y: 544, y1: 226, y2: 145, y3: 120 },
{ x: new Date(2008, 0, 1), y: 880, y1: 194, y2: 190, y3: 115 },
{ x: new Date(2009, 0, 1), y: 675, y1: 250, y2: 220, y3: 125 },
{ x: new Date(2010, 0, 1), y: 765, y1: 222, y2: 225, y3: 132 },
{ x: new Date(2011, 0, 1), y: 679, y1: 181, y2: 135, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];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. When the total at a point is 0, all series for that point are omitted.
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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average'};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average'};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average', fill: 'red'};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average', fill: 'red'};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint = { mode: 'Zero'};
const emptyPoint1 = { mode: 'Average', fill: 'red', border: {width: 1.5, color: 'green'}};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const emptyPoint: object = { mode: 'Zero'};
const emptyPoint1: object = { mode: 'Average', fill: 'red', border: {width: 1.5, color: 'green'}};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100' emptyPointSettings={emptyPoint1}>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: null, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: null, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];100% Cylindrical stacked column chart
To render a 100% stacked column with cylindrical (rounded) tops 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, DateTime, Tooltip, DataLabel, StackingColumnSeries } from '@syncfusion/ej2-react-charts';
import { cylindricalData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'DateTime', labelFormat: 'y' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, DateTime]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y' name='UK' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y1' name='Germany' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y2' name='France' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y3' name='Italy' type='StackingColumn100' 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, DateTime, Tooltip, DataLabel, StackingColumnSeries
}
from '@syncfusion/ej2-react-charts';
import { cylindricalData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'DateTime', labelFormat: 'y' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, DateTime]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y' name='UK' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y1' name='Germany' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y2' name='France' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
<SeriesDirective dataSource={cylindricalData} xName='x' yName='y3' name='Italy' type='StackingColumn100' columnFacet='Cylinder'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let cylindricalData = [
{ x: new Date(2006, 0, 1), y: 900, y1: 190, y2: 250, y3: 150 },
{ x: new Date(2007, 0, 1), y: 544, y1: 226, y2: 145, y3: 120 },
{ x: new Date(2008, 0, 1), y: 880, y1: 194, y2: 190, y3: 115 },
{ x: new Date(2009, 0, 1), y: 675, y1: 250, y2: 220, y3: 125 },
{ x: new Date(2010, 0, 1), y: 765, y1: 222, y2: 225, y3: 132 },
{ x: new Date(2011, 0, 1), y: 679, y1: 181, y2: 135, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];export let cylindricalData: Object[] = [
{ x: new Date(2006, 0, 1), y: 900, y1: 190, y2: 250, y3: 150 },
{ x: new Date(2007, 0, 1), y: 544, y1: 226, y2: 145, y3: 120 },
{ x: new Date(2008, 0, 1), y: 880, y1: 194, y2: 190, y3: 115 },
{ x: new Date(2009, 0, 1), y: 675, y1: 250, y2: 220, y3: 125 },
{ x: new Date(2010, 0, 1), y: 765, y1: 222, y2: 225, y3: 132 },
{ x: new Date(2011, 0, 1), y: 679, y1: 181, y2: 135, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];Corner radius
The cornerRadius property on the chart series is used to round the corners of 100% 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' 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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'
pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100' cornerRadius= {{ topRight: 10, topLeft: 10 }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];Point corner radius
You can override the corner radius for individual 100% 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth'
pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 100% 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth' seriesRender={seriesRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth'
seriesRender={seriesRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];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 100% 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 { columnperData } from './datasource';
function App() {
const primaryxAxis = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
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='Gross Domestic Product Growth' pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</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 { columnperData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Years', interval: 1, valueType: 'Category' };
const primaryyAxis: AxisModel = { title: 'GDP (%) Per Annum', rangePadding: 'None', labelFormat: '{value}%' };
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Gross Domestic Product Growth'
pointRender={pointRender}>
<Inject services={[StackingColumnSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y' name='UK' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y1' name='Germany' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y2' name='France' type='StackingColumn100'>
</SeriesDirective>
<SeriesDirective dataSource={columnperData} xName='x' yName='y3' name='Italy' type='StackingColumn100'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let columnperData = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];export let columnperData: Object[] = [
{ x: '2006', y: 900, y1: 190, y2: 250, y3: 150 },
{ x: '2007', y: 544, y1: 226, y2: 145, y3: 120 },
{ x: '2008', y: 450, y1: 194, y2: 190, y3: 115 },
{ x: '2009', y: 675, y1: 250, y2: 220, y3: 125 },
{ x: '2010', y: 765, y1: 222, y2: 225, y3: 132 },
{ x: '2011', y: 679, y1: 181, y2: 220, y3: 137 },
{ x: '2012', y: 770, y1: 128, y2: 152, y3: 110 }
];