Stacked Column Chart in TypeScript Charts
100% Stacked Column
To render a 100% stacked column series in your chart, follow the steps below:
-
Set the series type: Define the series
typeasStackingColumn100in your chart configuration. This indicates that the data should be represented as a 100% stacked column chart, with segments that show the percentage contribution of each part. -
Inject the StackingColumnSeries and DateTime modules: Use
Chart.Inject(StackingColumnSeries, DateTime)to register theStackingColumnSeriesand theDateTimeaxis module. TheDateTimemodule is required because the x-axis usesvalueType: 'DateTime'.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];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 { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Series customization
The following properties can be used to customize the 100% stacked column series.
Solid fill
The fill property determines the color applied to the series.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK', fill: '#2F4F4F'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany', fill: '#556B2F'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France', fill: '#8B0000'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy', fill: '#00008B'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Gradient fill
The fill property also applies an SVG gradient to a 100% stacked column series. Define the gradient within an SVG <defs> element using a unique ID, and assign it to the series in the url(#gradientId) format.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK', fill: 'url(#gradient1)'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany', fill: 'url(#gradient2)'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France', fill: 'url(#gradient3)'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy', fill: 'url(#gradient4)'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
<svg style="width:1px; height:1px">
<defs>
<linearGradient id="gradient1">
<stop offset="0%" style="stop-color:coral;stop-opacity:5" />
<stop offset="50%" style="stop-color:mediumseagreen;stop-opacity:5" />
</linearGradient>
</defs>
</svg>
<svg style="width:1px; height:1px">
<defs>
<linearGradient id="gradient2">
<stop offset="0%" style="stop-color:darkred;stop-opacity:5" />
<stop offset="50%" style="stop-color:darkorange;stop-opacity:5" />
</linearGradient>
</defs>
</svg>
<svg style="width:1px; height:1px">
<defs>
<linearGradient id="gradient3">
<stop offset="0%" style="stop-color:darkmagenta;stop-opacity:5" />
<stop offset="50%" style="stop-color:darkcyan;stop-opacity:5" />
</linearGradient>
</defs>
</svg>
<svg style="width:1px; height:1px">
<defs>
<linearGradient id="gradient4">
<stop offset="0%" style="stop-color:darkviolet;stop-opacity:5" />
<stop offset="50%" style="stop-color:darkgoldenrod;stop-opacity:5" />
</linearGradient>
</defs>
</svg>
</body>
</html>export let stackedData: 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 }
];Opacity
The opacity property controls the transparency of the fill and affects how the series blends with background or overlapping series.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK', opacity: 0.7
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany', opacity: 0.7
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France', opacity: 0.7
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy', opacity: 0.7
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Border
Use the border property to configure the border width, color, and dash array of the 100% stacked column series.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK',
border: { width: 2, color: '#ff4251', dashArray: '5,5' }
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany',
border: { width: 2, color: '#66BDB7', dashArray: '5,5' }
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France',
border: { width: 2, color: '#794F1B', dashArray: '5,5' }
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy',
border: { width: 2, color: '#1a9a6f', dashArray: '5,5' }
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];100% Cylindrical stacked column chart
To render a 100% cylindrical stacked column chart, set the columnFacet property to Cylinder in the chart series. The only other valid value is Rectangle (the default), which renders rectangular columns.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { cylindricalData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%'
},
//Series type as 100% stacked column series with cylinderical shape
series: [
{
dataSource: cylindricalData, xName: 'x', yName: 'y',
type: 'StackingColumn100', columnFacet: 'Cylinder', name: 'UK'
},
{
dataSource: cylindricalData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', columnFacet: 'Cylinder', name: 'Germany'
},
{
dataSource: cylindricalData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', columnFacet: 'Cylinder', name: 'France'
},
{
dataSource: cylindricalData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', columnFacet: 'Cylinder', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>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 }
];Empty points
Data points with null or undefined values are considered empty. Configure the emptyPointSettings on the series to control how empty data points are rendered.
Mode
Use the mode property to control handling of empty points. Available modes are Gap, Drop, Zero, and Average. The default mode is Gap.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK',
emptyPointSettings: {
mode: 'Zero'
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France',
emptyPointSettings: {
mode: 'Average'
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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: null, 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: null, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];Fill
Use the fill property to set the fill color for empty points.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK',
emptyPointSettings: {
mode: 'Zero'
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France',
emptyPointSettings: {
mode: 'Average',
fill: 'red'
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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: null, 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: null, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];Border
Use the border property to customize the border width and color for empty points.
import { Chart, StackingColumnSeries, DateTime, Legend } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK',
emptyPointSettings: {
mode: 'Zero'
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France',
emptyPointSettings: {
mode: 'Average',
fill: 'red',
border: { width: 2, color: 'green' }
}
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth'
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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: null, 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: null, y3: 137 },
{ x: new Date(2012, 0, 1), y: 770, y1: 128, y2: 152, y3: 110 }
];Corner radius
The cornerRadius property in the chart series is used to customize the corner radius for 100% stacked column series. This allows you to create 100% stacked columns with rounded corners. You can customize each corner of the 100% stacked columns using the topLeft, topRight, bottomLeft, and bottomRight properties.
import { Chart, StackingColumnSeries, DateTime, Legend, IPointRenderEventArgs } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{ cornerRadius: { topRight: 10, topLeft: 10 },
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth',
pointRender: (args: IPointRenderEventArgs) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Point corner radius
You can customize the corner radius for individual points in the chart series using the pointRender event by setting the cornerRadius property in its event argument.
import { Chart, StackingColumnSeries, DateTime, Legend, IPointRenderEventArgs } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth',
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 };
}
}
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Events
Series render
The seriesRender event enables modification of series properties (for example, data, fill, or name) immediately before rendering. Use this event to adjust series appearance or to dynamically swap data sources.
import { Chart, StackingColumnSeries, DateTime, Legend, ISeriesRenderEventArgs } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth',
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';
}
}
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Point render
The pointRender event provides a hook to customize each data point (for example, marker shape, border, or fill) before it is drawn. Use this to apply per-point styling rules or conditional formatting.
import { Chart, StackingColumnSeries, DateTime, Legend, IPointRenderEventArgs } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, DateTime, Legend);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'DateTime',
title: 'Years',
interval: 1,
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100', name: 'UK'
},
{
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany'
},
{
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France'
},
{
dataSource: stackedData, xName: 'x', yName: 'y3',
type: 'StackingColumn100', name: 'Italy'
}
],
title: 'Gross Domestic Product Growth',
pointRender: (args: IPointRenderEventArgs) => {
if (args.point.series.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>export let stackedData: 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 }
];Troubleshooting
The following list describes common issues you may encounter when working with the 100% Stacked Column series and how to resolve them.
Chart does not render a 100% stacked column: Confirm the type property of each series is set to StackingColumn100. If type is omitted or set to a different value (for example, StackingColumn), the data is drawn as overlapping (non-normalized) segments. Also ensure StackingColumnSeries is registered with Chart.Inject(...) before the chart is initialized, or import the module directly from @syncfusion/ej2-charts using ES module syntax.
Cylindrical facet does not appear: columnFacet accepts only Rectangle (the default) and Cylinder. Other values are ignored. Confirm the property is set on each series configuration object and that the chart is rendered with the StackingColumn100 series type.
Bands do not normalize to 100%: 100% stacked series render each x-position as 100% of all contributing values. If percentages do not sum to 100, verify that each series shares the same xName and that the input data is non-negative. Negative values are not normalized and will produce inconsistent percentages.