Loading...
Loading...
Compare original and translation side by side
@syncfusion/ej2-angular-charts@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
};
}import { 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 }
];// 定义带分类的节点,用于图例分组
const nodes = [
{ id: 'Power', label: { text: 'Power Plant' }, category: 'Source' },
{ id: 'Grid', label: { text: 'Grid' }, category: 'Intermediary' },
{ id: 'Home', label: { text: 'Households' }, category: 'Sink' }
];
// 链接代表流的数量
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';
};// 渲染事件处理器,实现基于数值的颜色设置
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;
};// 使用透明度强调关系
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) |
| 属性 | 类型 | 用途 |
|---|---|---|
| string | 组件宽度('700px'、'100%'或'90%') |
| string | 组件高度('420px'、'450px'或'100%') |
| string | 图的主标题 |
| string | 带描述性文本的副标题 |
| string | 流方向('Horizontal'或'Vertical') |
| boolean | 启用从右到左布局 |
| string | 内置主题(Material、Bootstrap、Tailwind、HighContrast等) |
| Object | 全局节点样式(宽度、内边距、透明度、颜色) |
| Object | 全局链接样式(曲率、透明度、colorType) |
| Object | 标签定位与可见性设置 |
| Object | 图例配置与定位设置 |
| Object | 工具提示模板与可见性设置 |
| Array | 节点定义(手动属性绑定) |
| Array | 链接定义(手动属性绑定) |