To render a 100% stacked area series, use series type
as StackingArea100
and inject StackingAreaSeries
module using Chart.Inject(StackingAreaSeries)
method.
import { Chart, StackingAreaSeries, DateTime } from '@syncfusion/ej2-charts';
Chart.Inject(StackingAreaSeries, DateTime);
let chartData: any[] = [
{ x: new Date(2000, 0, 1), y: 0.61, y1: 0.03, y2: 0.48, y3: 0.23 },
{ x: new Date(2001, 0, 1), y: 0.81, y1: 0.05, y2: 0.53, y3: 0.17 },
{ x: new Date(2002, 0, 1), y: 0.91, y1: 0.06, y2: 0.57, y3: 0.17 },
{ x: new Date(2003, 0, 1), y: 1.0, y1: 0.09, y2: 0.61, y3: 0.2 },
{ x: new Date(2004, 0, 1), y: 1.19, y1: 0.14, y2: 0.63, y3: 0.23 },
{ x: new Date(2005, 0, 1), y: 1.47, y1: 0.2, y2: 0.64, y3: 0.36 },
{ x: new Date(2006, 0, 1), y: 1.74, y1: 0.29, y2: 0.66, y3: 0.43 },
{ x: new Date(2007, 0, 1), y: 1.98, y1: 0.46, y2: 0.76, y3: 0.51 },
{ x: new Date(2008, 0, 1), y: 1.99, y1: 0.64, y2: 0.77, y3: 0.72 },
{ x: new Date(2009, 0, 1), y: 1.7, y1: 0.75, y2: 0.55, y3: 1.29 },
{ x: new Date(2010, 0, 1), y: 1.48, y1: 1.06, y2: 0.54, y3: 1.38 },
{ x: new Date(2011, 0, 1), y: 1.38, y1: 1.25, y2: 0.57, y3: 1.82 },
{ x: new Date(2012, 0, 1), y: 1.66, y1: 1.55, y2: 0.61, y3: 2.16 },
{ x: new Date(2013, 0, 1), y: 1.66, y1: 1.55, y2: 0.67, y3: 2.51 },
{ x: new Date(2014, 0, 1), y: 1.67, y1: 1.65, y2: 0.67, y3: 2.61 },
];
let chart: Chart = new Chart(
{
primaryXAxis: {
valueType: 'DateTime',
},
series: [
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'blue', xName: 'x', yName: 'y',
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'black', xName: 'x', yName: 'y1',
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'blue', xName: 'x', yName: 'y3'
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'red', xName: 'x', yName: 'y2'
},
],
},
'#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 100% stacked area
series.
fill
– Specifies the color of the area series.opacity
– Specifies the opacity of fill
.dashArray
– Specifies the dashes of series.width
– Specifies the width for series.import { Chart, StackingAreaSeries, DateTime } from '@syncfusion/ej2-charts';
Chart.Inject(StackingAreaSeries, DateTime);
let chartData: any[] = [
{ x: new Date(2000, 0, 1), y: 0.61, y1: 0.03, y2: 0.48, y3: 0.23 },
{ x: new Date(2001, 0, 1), y: 0.81, y1: 0.05, y2: 0.53, y3: 0.17 },
{ x: new Date(2002, 0, 1), y: 0.91, y1: 0.06, y2: 0.57, y3: 0.17 },
{ x: new Date(2003, 0, 1), y: 1.0, y1: 0.09, y2: 0.61, y3: 0.2 },
{ x: new Date(2004, 0, 1), y: 1.19, y1: 0.14, y2: 0.63, y3: 0.23 },
{ x: new Date(2005, 0, 1), y: 1.47, y1: 0.2, y2: 0.64, y3: 0.36 },
{ x: new Date(2006, 0, 1), y: 1.74, y1: 0.29, y2: 0.66, y3: 0.43 },
{ x: new Date(2007, 0, 1), y: 1.98, y1: 0.46, y2: 0.76, y3: 0.51 },
{ x: new Date(2008, 0, 1), y: 1.99, y1: 0.64, y2: 0.77, y3: 0.72 },
{ x: new Date(2009, 0, 1), y: 1.7, y1: 0.75, y2: 0.55, y3: 1.29 },
{ x: new Date(2010, 0, 1), y: 1.48, y1: 1.06, y2: 0.54, y3: 1.38 },
{ x: new Date(2011, 0, 1), y: 1.38, y1: 1.25, y2: 0.57, y3: 1.82 },
{ x: new Date(2012, 0, 1), y: 1.66, y1: 1.55, y2: 0.61, y3: 2.16 },
{ x: new Date(2013, 0, 1), y: 1.66, y1: 1.55, y2: 0.67, y3: 2.51 },
{ x: new Date(2014, 0, 1), y: 1.67, y1: 1.65, y2: 0.67, y3: 2.61 },
];
let chart: Chart = new Chart(
{
primaryXAxis: {
valueType: 'DateTime',
},
series: [
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'blue', xName: 'x', yName: 'y', dashArray: '5.5',
border: { width: 2, color: 'white' }, marker: { visible: true}
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'black', xName: 'x', yName: 'y1', dashArray: '5.5',
border: { width: 2, color: 'yellow' }
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'blue', xName: 'x', yName: 'y3', dashArray: '5.5',
border: { width: 2, color: 'black' }
},
{
type: 'StackingArea100', opacity: 0.7, dataSource: chartData,
fill: 'red', xName: 'x', yName: 'y2', dashArray: '5.5',
border: { width: 2, color: 'white' }
},
],
},
'#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>