Loading...
Loading...
Create and configure Syncfusion Angular Sankey diagrams for flow visualization. Use this when visualizing weighted flows, processes, and hierarchical relationships. Supports node and link styling, legends, tooltips, events, accessibility features, and comprehensive data binding for complex flow diagrams.
npx skill4agent add syncfusion/angular-ui-components-skills syncfusion-angular-sankey@syncfusion/ej2-angular-chartsimport { Component, ViewEncapsulation } from '@angular/core';
import { SankeyAllModule } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [SankeyAllModule],
standalone: true,
selector: 'app-sankey-demo',
template: `<ejs-sankey [dataSource]="data" [nodeSettings]="nodeSettings"></ejs-sankey>`,
encapsulation: ViewEncapsulation.None
})
export class SankeyDemoComponent {
data: any[] = [
{ sourceID: 'S1', targetID: 'T1', value: 5 },
{ sourceID: 'S1', targetID: 'T2', value: 3 },
{ sourceID: 'S2', targetID: 'T1', value: 2 }
];
nodeSettings: any = {
width: 20,
padding: 10
};
}// Define nodes with categories for legend grouping
const nodes = [
{ id: 'Power', label: { text: 'Power Plant' }, category: 'Source' },
{ id: 'Grid', label: { text: 'Grid' }, category: 'Intermediary' },
{ id: 'Home', label: { text: 'Households' }, category: 'Sink' }
];
// Links represent flow quantities
const links = [
{ sourceID: 'Power', targetID: 'Grid', value: 100 },
{ sourceID: 'Grid', targetID: 'Home', value: 80 }
];// Render event handler for value-based coloring
onNodeRendering = (args: INodeRenderingEventArgs) => {
const value = args.node.value || 0;
args.node.color = value > 100 ? '#00A651' : value > 50 ? '#FFB81C' : '#E81B23';
};// Use opacity to emphasize relationships
onNodeEnter = (args: INodeEnterEventArgs) => {
args.node.highlightOpacity = 1;
};
onNodeLeave = (args: INodeLeaveEventArgs) => {
args.node.highlightOpacity = 0.3;
};| Property | Type | Purpose |
|---|---|---|
| string | Component width ('700px', '100%', or '90%') |
| string | Component height ('420px', '450px', or '100%') |
| string | Main title for the diagram |
| string | Subtitle with descriptive text |
| string | Flow direction ('Horizontal' or 'Vertical') |
| boolean | Enable right-to-left layout |
| string | Built-in theme (Material, Bootstrap, Tailwind, HighContrast, etc.) |
| Object | Global node styling (width, padding, opacity, colors) |
| Object | Global link styling (curvature, opacity, colorType) |
| Object | Label positioning and visibility |
| Object | Legend configuration and positioning |
| Object | Tooltip template and visibility settings |
| Array | Node definitions (manual property binding) |
| Array | Link definitions (manual property binding) |