Stacked Step Area Chart in Angular Charts
28 Aug 202624 minutes to read
Stacked Step Area
A stacked step area chart stacks multiple step-shaped area series to show cumulative values with interval-based transitions.

To render a stacked step area series in your chart, you need to follow a few steps to configure it correctly.
Here’s a concise guide on how to do this:
-
Set the series type: Define the series
typeasStackingStepAreain your chart configuration. This indicates that the data should be represented as a stacked step area chart, which is a combination of a stacked area chart and a step area chart. It connects the data points with vertical and horizontal lines, creating a step-like appearance. -
Register the StackingStepAreaSeriesService provider: Register
StackingStepAreaSeriesService(along with any other chart services you need) in the component’sprovidersarray.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Binding data with series
Bind data via the dataSource property on the series. Map the fields from your records to xName and yName so the chart knows which value drives each point. The included basic sample renders two StackingStepArea series (USA, UK) on the same dataSource, with each series pointing to a different yName (y, y1).
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Series customization
The following properties customize the Stacked Step Area series.
Solid fill
The fill property determines the color applied to the series. Default value is null.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' fill='red'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' fill='green'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Gradient fill
The fill property can apply an SVG gradient to a stacked step area series. Define the gradient within an SVG <defs> element using a unique ID, and assign it to the series in the url(#gradientId) format. Place the following SVG elements in your application’s index.html file, inside the <body> element and outside the <app-container> element.
<svg>
<defs>
<linearGradient id="gradient1">
<stop offset="0%" style="stop-color:darkviolet;stop-opacity:1" />
<stop offset="50%" style="stop-color:darkgoldenrod;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<svg>
<defs>
<linearGradient id="gradient2">
<stop offset="0%" style="stop-color:darkred;stop-opacity:1" />
<stop offset="50%" style="stop-color:darkorange;stop-opacity:1" />
</linearGradient>
</defs>
</svg>import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' fill='url(#gradient1)'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' fill='url(#gradient2)'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Opacity
The opacity property specifies the transparency level of the fill. Valid range is 0 (completely transparent) to 1 (completely opaque). Default value is 1.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' opacity='0.5'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' opacity='0.5'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Series Border
Use the border property to style the series border. The border object supports these fields:
-
width- Border thickness in pixels. -
color- Border stroke color. -
dashArray- Dash pattern for the border (for example'5','5,5', or'2,3,4').
Example: { width: 2, color: 'red', dashArray: '2,5' }.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [border]='border'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' [border]='border'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public border?: Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.border={ width: 2, color: 'red', dashArray: '2,5' };
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Step
Use the step property to change the position of the steps in a stacked step area series. Available values are:
-
Left(default) - The step rises/joins on the left side of each x-interval. -
Center- The step is centered in each x-interval. -
Right- The step rises/joins on the right side of each x-interval.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [step]='step'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' [step]='step'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public step?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
this.step = 'Center';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];No Risers
Eliminate the vertical lines between points by setting the noRisers property to true on the series.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' opacity='0.1' [border]='border' name='USA' noRisers='true'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' opacity='0.1' [border]='border' yName='y1' name='UK' noRisers='true'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public step?: string;
public border?: object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
this.step = 'Center';
this.border = { width: 1.5 };
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Empty points
Data points with null or undefined values are considered empty. How an empty point is rendered on the chart depends on the mode you choose.
Mode
Use the mode property to define how empty or missing data points are handled. Available values are:
-
Gap(default) - Leaves a gap at the empty point. -
Drop- Drops the empty point and connects adjacent points. -
Zero- Replaces the empty point with the value0. -
Average- Replaces the empty point with the average of adjacent points.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [emptyPointSettings]='emptyPointSettings'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public emptyPointSettings?: Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
this.emptyPointSettings = { mode: 'Gap' };
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: null, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: undefined },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Empty Point Fill
Use the fill property to customize the fill color of empty points in the series. Applies only when mode is Zero or Average.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [marker]='marker' [emptyPointSettings]='emptyPointSettings'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public emptyPointSettings?: Object;
public marker?: Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
this.emptyPointSettings = { mode: 'Average', fill: 'red' };
this.marker = { visible: true, width: 7, height: 7 };
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: null, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: undefined },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Empty Point Border
Use the border property to customize the width and color of the border for empty points. Applies only when mode is Zero or Average.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [marker]='marker' [emptyPointSettings]='emptyPointSettings'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public emptyPointSettings?: Object;
public marker?: Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.marker = { visible: true, width: 10, height:10 };
this.title = 'Annual Temperature Comparison';
this.emptyPointSettings = { mode: 'Average', fill: 'red', border: {width: 2, color: 'Green'} };
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: null, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: undefined },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Stack labels
Stack labels in stacked charts display cumulative total values for stack segments directly using data labels. If a stack point has negative values, the stack labels are displayed below the point.
To enable stack labels, set [stackLabels]='{ visible: true }' on the chart.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService, DataLabelService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService, DataLabelService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title' [stackLabels]='stackLabels'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [marker]='marker'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public marker?: Object;
public stackLabels?:Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.marker = { dataLabel: { visible: true } };
this.stackLabels = { visible: true };
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Stack labels customization
Stack labels have various properties for customization to enhance the visuals based on your requirements:
-
visible- Specifies whether stack labels are visible. Setting totruewill display the labels. Default isfalse. -
fill- Defines the background color of the stack labels. Accepts valid CSS color strings (hex, RGBA, etc.). Default istransparent. -
format- Formats the text displayed in the stack labels. Supports placeholders like{value}. Default isnull. -
angle- Specifies the rotation angle for stack labels in degrees. Default is0. -
rx- Defines the rounded corner radius along the X-axis (horizontal direction) for the stack label background. Default is5. -
ry- Defines the rounded corner radius along the Y-axis (vertical direction) for the stack label background. Default is5. -
margin- Configures the margin around the stack label (left, right, top, and bottom). -
border- Configures the appearance of the stack label’s border. -
font- Customizes the stack label text, including font size, color, style, weight, and family.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, StackingStepAreaSeriesService, DataLabelService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService, DataLabelService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title' [stackLabels]='stackLabels'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA' [marker]='marker'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK' [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public marker?: Object;
public stackLabels?:Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.marker = { dataLabel: { visible: true } };
this.stackLabels = { visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } };
this.title = 'Annual Temperature Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Events
Series render
The seriesRender event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart. The included handler branches on args.series.index and assigns a different args.fill per series.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { ISeriesRenderEventArgs } from '@syncfusion/ej2-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" (seriesRender)='seriesRender($event)' [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y' name='USA'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
}
public 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';
}
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Point render
The pointRender event allows you to customize each data point before it is rendered on the chart. The included handler branches on args.point.index and assigns a different args.fill for even versus odd-indexed points.
import { ChartModule, ChartAllModule } from '@syncfusion/ej2-angular-charts'
import { IPointRenderEventArgs } from '@syncfusion/ej2-charts'
import { DateTimeService, StackingStepAreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { percentData } from './datasource';
@Component({
imports: [
ChartModule, ChartAllModule
],
providers: [DateTimeService, StackingStepAreaSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" (pointRender)='pointRender($event)' [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' [marker]='marker' yName='y' name='USA'></e-series>
<e-series [dataSource]='chartData' type='StackingStepArea' xName='x' [marker]='marker' yName='y1' name='UK'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public marker?: Object;
ngOnInit(): void {
this.chartData = percentData;
this.primaryXAxis = {
valueType: 'DateTime'
};
this.title = 'Annual Temperature Comparison';
this.marker = {visible: true};
}
public pointRender(args: IPointRenderEventArgs) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));export let percentData: Object[] = [
{ x: new Date(2006, 0, 1), y: 34, y1: 51, y2: 14, y3: 37 },
{ x: new Date(2007, 0, 1), y: 20, y1: 26, y2: 34, y3: 15 },
{ x: new Date(2008, 0, 1), y: 40, y1: 37, y2: 73, y3: 53 },
{ x: new Date(2009, 0, 1), y: 51, y1: 51, y2: 51, y3: 51 },
{ x: new Date(2010, 0, 1), y: 26, y1: 26, y2: 26, y3: 26 },
{ x: new Date(2011, 0, 1), y: 37, y1: 37, y2: 37, y3: 37 },
{ x: new Date(2012, 0, 1), y: 54, y1: 43, y2: 12, y3: 54 },
{ x: new Date(2013, 0, 1), y: 44, y1: 23, y2: 16, y3: 44 },
{ x: new Date(2014, 0, 1), y: 48, y1: 55, y2: 34, y3: 23 }
];Troubleshooting
- Ensure
StackingStepAreaSeriesServiceis registered in the providers; otherwise the stacked step area series will not render. -
Stack labels do not appear: set
[stackLabels]='{ visible: true }'on the chart. -
Step position doesn’t change: confirm you used a value accepted by the
stepproperty —Left,Center, orRight. Any other string is treated as the default. -
Empty-point customization has no visible effect: the
fillandbordersettings onemptyPointSettingsapply only whenmodeisZeroorAverage. WithGapandDropmodes no marker is drawn. -
Gradient fill renders as solid color: the SVG gradients referenced by
fill='url(#gradient1)'etc. are not defined. Add matching<linearGradient>(or<radialGradient>) blocks inside a<defs>block in the chart template, or in a global stylesheet.