To render a stacked column series, use series type
as
StackingColumn
and inject StackingColumnSeries
module
using Chart.Inject(StackingColumnSeries)
method.
import { Chart, StackingColumnSeries, Category } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, Category);
let chart: Chart = new Chart({
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
//Series type as stacked column
type: 'StackingColumn'
}, {
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn'
}, {
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn'
}
],
}, '#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>
You can use the stackingGroup
property to group the stacked columns and 100% stacked columns.
Columns with same group name are stacked on top of each other.
import { Chart, StackingColumnSeries, Category } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, Category);
let chart: Chart = new Chart({
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y',
type: 'StackingColumn'
//Stacking group for stacked column series
stackingGroup: 'UKAndGermany'
}, {
dataSource: stackedData, xName: 'x', yName: 'y1',
type: 'StackingColumn', stackingGroup: 'UKAndGermany'
}, {
dataSource: stackedData, xName: 'x', yName: 'y2',
type: 'StackingColumn', stackingGroup: 'FranceAndItaly'
}
],
}, '#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>
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.import { Chart, StackingColumnSeries, Category } from '@syncfusion/ej2-charts';
import { stackedData } from './datasource.ts';
Chart.Inject(StackingColumnSeries, Category);
let chart: Chart = new Chart({
series: [
{
dataSource: stackedData, xName: 'x', yName: 'y', dashArray: '2.2',
//Series type as stacked column
type: 'StackingColumn', border: { width: 1.5, color: 'blue'}
}, {
dataSource: stackedData, xName: 'x', yName: 'y1', dashArray: '2.2',
type: 'StackingColumn',border: { width: 1.5, color: 'yellow'}
}, {
dataSource: stackedData, xName: 'x', yName: 'y2', dashArray: '2.2',
type: 'StackingColumn',border: { width: 1.5, color: 'red'}
}
],
}, '#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>