To render a 100% stacked column series, use series type
as
StackingColumn100
and inject StackingColumnSeries
module using Chart.Inject(StackingColumnSeries)
method.
var chartData = [
{ 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 },
];
var chart = new ej.charts.Chart({
primaryXAxis: {
title: 'Years',
interval: 1,
valueType: 'DateTime',
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: chartData, xName: 'x', yName: 'y',
//Series type as 100% stacked column series
type: 'StackingColumn100',
name: 'UK',
}, {
dataSource: chartData, xName: 'x', yName: 'y1',
type: 'StackingColumn100', name: 'Germany',
}, {
dataSource: chartData, xName: 'x', yName: 'y2',
type: 'StackingColumn100', name: 'France',
}, {
dataSource: chartData, 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://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
The following properties can be used to customize the column
series.
fill
– Specifies the color of the series.opacity
– Specifies the opacity of fill
.dashArray
– Specifies the dashes of series.border
– Specifies the color
and width
of series border.var chartData = [
{ 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 },
];
var chart = new ej.charts.Chart({
primaryXAxis: {
title: 'Years',
interval: 1,
valueType: 'DateTime',
labelFormat: 'y'
},
primaryYAxis:
{
title: 'GDP (%) Per Annum',
rangePadding: 'None',
labelFormat: '{value}%',
},
series: [
{
dataSource: chartData, xName: 'x', yName: 'y', dashArray: '2.2',
//Series type as stacked column
type: 'StackingColumn100', border: { width: 1.5, color: 'blue'}
}, {
dataSource: chartData, xName: 'x', yName: 'y1', dashArray: '2.2',
type: 'StackingColumn100',border: { width: 1.5, color: 'yellow'}
}, {
dataSource: chartData, xName: 'x', yName: 'y2', dashArray: '2.2',
type: 'StackingColumn100',border: { width: 1.5, color: 'red'}
}
],
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://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>