Getting Started with Angular Sankey Chart Component
30 Jul 20268 minutes to read
This section explains the steps required to create a simple Angular Sankey Chart and demonstrates the basic usage of the Angular Sankey Chart component.
Note: This guide supports Angular 21 and other recent Angular versions. For detailed compatibility with other Angular versions, please refer to the Angular version support matrix. Starting from Angular 19, standalone components are the default, and this guide reflects that architecture.
Ready to streamline your Syncfusion® Angular development? Discover the full potential of Syncfusion® Angular components with Syncfusion® AI Coding Assistant. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like VS Code, Cursor, Syncfusion® CodeStudio and more. Explore Syncfusion® AI Coding Assistant
Prerequisites
Before getting started, ensure that your environment meets the system requirements for Syncfusion® Angular UI components, which covers supported Node.js, Angular, and @syncfusion/ej2-angular-charts versions.
Setup Angular Environment
A straightforward approach to begin with Angular is to create a new application using the Angular CLI. Install Angular CLI globally with the following command:
npm install -g @angular/cliVerify the installation:
ng versionAngular 21 Standalone Architecture: Standalone components are the default in Angular 21. This guide uses the modern standalone architecture. If you need more information about the standalone architecture, refer to the Standalone Guide.
Installing a specific version
To install a particular version of Angular CLI, use:
npm install -g @angular/[email protected]Create an Angular application
With Angular CLI installed, execute the following command to generate a new application:
ng new syncfusion-angular-app- This command will prompt you to configure settings like enabling Angular routing and choosing a stylesheet format.
? Which stylesheet format would you like to use? (Use arrow keys)
> CSS [ https://developer.mozilla.org/docs/Web/CSS]
Sass (SCSS) [ https://sass-lang.com/documentation/syntax#scss ]
Sass (Indented) [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]
Less [ http://lesscss.org]- By default, a CSS-based application is created. Use SCSS if required:
ng new syncfusion-angular-app --style=scss- During project setup, when prompted for the Server-side rendering (SSR) option, choose the appropriate configuration.

- Select the required AI tool or ‘none’ if you do not need any AI tool.

Navigate to your newly created application directory:
cd syncfusion-angular-appIn Angular 19 and below, the CLI generates files like
app.component.ts,app.component.html, etc. In Angular 20+, the CLI generates a simpler structure withapp.ts,app.html, andapp.css(no.component.suffixes).
Adding the Syncfusion® Angular Sankey Chart package
To install the Syncfusion® Angular Sankey Chart package, use the following command:
ng add @syncfusion/ej2-angular-chartsThe ng add command installs the package, registers it in package.json, and configures the required entries in your workspace automatically.
If ng add is unavailable in your setup, install the package manually with:
npm install @syncfusion/ej2-angular-chartsAdd Syncfusion® Angular Sankey Chart component
Update src/app/app.component.ts (or src/app/app.ts in Angular 20+) to render the Sankey Chart component:
import { Component } from '@angular/core';
import { SankeyAllModule } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [SankeyAllModule],
standalone: true,
selector: 'app-root',
template: `
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey id="sankey-container" width="90%" height="420px" >
<e-sankey-nodes>
<e-sankey-node id="A"></e-sankey-node>
<e-sankey-node id="B"></e-sankey-node>
<e-sankey-node id="C"></e-sankey-node>
</e-sankey-nodes>
<e-sankey-links>
<e-sankey-link sourceId="A" targetId="B" [value]="100"></e-sankey-link>
<e-sankey-link sourceId="B" targetId="C" [value]="80"></e-sankey-link>
</e-sankey-links>
</ejs-sankey>
</div>
</div>
`,
})
export class AppComponent {
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Run the application
Run the application using the following command:
ng serveModule Injection
Sankey components are segregated into individual feature-wise modules. To use a particular feature, you need to inject its feature service in src/app/app.ts (Angular 20+) or src/app/app.component.ts (Angular 19 and below). This example will use the tooltip and legend features of the Sankey Chart.
-
SankeyTooltipService- Inject this provider to render the tooltip. -
SankeyLegendService- Inject this provider to render the legend.
Replace the contents of src/app/app.ts (or src/app/app.component.ts on Angular 19 and below) with the following:
import { Component, ViewEncapsulation } from '@angular/core';
import { SankeyModule, SankeyTooltipService, SankeyLegendService } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [SankeyModule],
standalone: true,
selector: 'app-root',
providers: [SankeyTooltipService, SankeyLegendService],
template: `<ejs-sankey id="sankey-container"></ejs-sankey>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent { }Bind Data to the Sankey Chart
Now that the granular services are registered, you can populate the Sankey Chart with data. Nodes represent the categories, and links represent the flow between them. Each node has a unique id. Each link uses sourceId and targetId to reference the source and target node IDs, while value defines the flow amount between the connected nodes. The following example shows a simple energy-flow Sankey:
import { Component } from '@angular/core';
import { SankeyAllModule } from '@syncfusion/ej2-angular-charts';
import {
SankeyTooltipService,
SankeyLegendService,
SankeyExportService
} from '@syncfusion/ej2-angular-charts';
@Component({
imports: [SankeyAllModule],
providers: [
SankeyTooltipService,
SankeyLegendService,
SankeyExportService
],
standalone: true,
selector: 'app-container',
template: `
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="420px"
title="Energy Flow Diagram">
<e-sankey-nodes>
<e-sankey-node id="Energy Input" [label]="{ text: 'Energy Input' }"></e-sankey-node>
<e-sankey-node id="Generation" [label]="{ text: 'Generation' }"></e-sankey-node>
<e-sankey-node id="Distribution" [label]="{ text: 'Distribution' }"></e-sankey-node>
<e-sankey-node id="Consumption" [label]="{ text: 'Consumption' }"></e-sankey-node>
</e-sankey-nodes>
<e-sankey-links>
<e-sankey-link sourceId="Energy Input" targetId="Generation" [value]="500"></e-sankey-link>
<e-sankey-link sourceId="Generation" targetId="Distribution" [value]="450"></e-sankey-link>
<e-sankey-link sourceId="Distribution" targetId="Consumption" [value]="400"></e-sankey-link>
</e-sankey-links>
</ejs-sankey>
</div>
</div>
`
})
export class AppComponent {}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));The Sankey diagram renders nodes (rectangles) sized proportionally to their flow, with links (curved bands) connecting source nodes to target nodes. Hovering over a link displays a tooltip with the source, target, and value.
Troubleshooting
If the Sankey Chart does not render as expected, check for these common issues:
-
Chart not visible: Verify that
ViewEncapsulation.Noneis set on the component, that theidon<ejs-sankey>is unique, and that theselectormatches the root element inindex.html(commonly<app-root>). -
Data not displayed: Check that your data contains
sourceId,targetId, andvalueproperties and that node ids match exactly between links. -
Build errors: Run
ng versionto confirm that Node.js, Angular CLI, and@syncfusion/ej2-angular-chartsare on supported versions.