syncfusion-angular-diagram
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion Angular Diagrams
实现Syncfusion Angular Diagram
When to Use This Skill
何时使用该技能
Use this skill when you need to:
- Create visual diagrams (flowcharts, org-charts, BPMN, UML)
- Build interactive diagrams with nodes and connectors
- Apply layouts (hierarchical, org-chart, mindmap, radial, flowchart)
- Design BPMN or UML diagrams for business processes
- Add interaction (drag, resize, selection, undo/redo)
- Export or serialize diagrams to JSON/images
当你需要以下功能时使用本技能:
- 创建可视化图表(流程图、组织架构图、BPMN、UML)
- 构建带节点和连接器的交互式图表
- 应用布局(层级结构、组织架构图、思维导图、放射状、流程图)
- 为业务流程设计BPMN或UML图表
- 添加交互功能(拖拽、调整大小、选择、撤销/重做)
- 导出或序列化图表为JSON/图片格式
Important: API Verification Required
重要提示:需验证API
API Verification Required: Always verify API class names, properties, and signatures by reading reference files () BEFORE generating code examples. Do not assume or infer class names.
⚠️ Before writing ANY code, review the Common Mistakes section directly below to avoid known invalid APIs and properties.
references/*.md需验证API:在生成代码示例之前,务必通过阅读参考文件()验证API类名、属性和签名。请勿主观推测类名。
⚠️ 在编写任何代码之前,请直接查看下方的常见错误部分,避免使用已知无效的API和属性。
references/*.mdComponent Overview
组件概述
The Syncfusion Angular Diagram component provides a visual canvas for creating and editing diagrams:
Syncfusion Angular Diagram组件提供了一个可视化画布,用于创建和编辑图表:
Core Concepts
核心概念
- Nodes - Rectangles, circles, flowchart shapes, custom shapes
- Connectors - Lines linking nodes (Straight, Orthogonal, Bezier)
- Labels - Text annotations on nodes and connectors
- Ports - Connection points on node boundaries
- Swimlanes - Horizontal/vertical lanes for process diagrams
- Layouts - Automatic positioning (hierarchical, org-chart, mindmap, etc.)
- BPMN Shapes - Business process diagram standardized shapes
- UML Diagrams - Class and sequence diagram notation
- Symbol Palette - Draggable symbol library
- Data Binding - Render diagrams from JSON data
- Nodes(节点) - 矩形、圆形、流程图形状、自定义形状
- Connectors(连接器) - 连接节点的线条(直线、正交线、贝塞尔曲线)
- Labels(标签) - 节点和连接器上的文本注释
- Ports(端口) - 节点边界上的连接点
- Swimlanes(泳道) - 用于流程图表的水平/垂直分区
- Layouts(布局) - 自动定位(层级、组织架构图、思维导图等)
- BPMN Shapes(BPMN形状) - 业务流程图表的标准化形状
- UML Diagrams(UML图表) - 类图和序列图符号
- Symbol Palette(符号面板) - 可拖拽的符号库
- Data Binding(数据绑定) - 从JSON数据渲染图表
Key Features
关键特性
- Interactive editing: Drag, resize, rotate nodes and connectors
- Auto-layout: Hierarchical, org-chart, mindmap, radial, flowchart layouts
- BPMN & UML: Built-in shape libraries for standard diagrams
- Serialization: Save/load diagrams as JSON
- Export: PNG, SVG, PDF image export and print
- Undo/Redo: Full history support
- Virtualization: Render large diagrams efficiently
- Accessibility: WCAG 2.1 compliance with keyboard navigation
- 交互式编辑:拖拽、调整大小、旋转节点和连接器
- 自动布局:层级、组织架构图、思维导图、放射状、流程图布局
- BPMN & UML支持:内置标准图表的形状库
- 序列化:将图表保存/加载为JSON格式
- 导出:导出为PNG、SVG、PDF图片格式并支持打印
- 撤销/重做:完整的历史记录支持
- 虚拟化:高效渲染大型图表
- 可访问性:符合WCAG 2.1标准,支持键盘导航
Documentation and Navigation Guide
文档与导航指南
Start with Getting Started, then jump to the specific feature you need:
从入门指南开始,然后跳转到你需要的特定功能:
Core Diagram Building
核心图表构建
📄 Read: references/getting-started.md
- Installation and dependencies
- Theme setup (material, bootstrap, fabric)
- CSS/SCSS imports
- Basic DiagramComponent usage
- Module injection pattern
- Standalone component setup
📄 Read: references/nodes.md
- Creating and adding nodes to diagram
- Offsetting and positioning (offsetX, offsetY)
- Node dimensions (width, height)
- Built-in shapes (Flow, Basic, Path)
- Custom styling (fill, stroke, opacity)
- Node templates and appearance
- Expand/collapse node groups
- Node events (click, select, drag)
- getNodeDefaults pattern for style defaults
📄 Read: references/connectors.md
- Three connector types: Straight, Orthogonal, Bezier
- Segments configuration and pathfinding
- sourceID and targetID linking nodes
- Multiple segments in connectors
- Bezier control points and orientation
- Connector customization (stroke, fill, dashing)
- Connector events and interaction
- getConnectorDefaults pattern for style defaults
📄 阅读:references/getting-started.md
- 安装和依赖项
- 主题设置(material、bootstrap、fabric)
- CSS/SCSS导入
- DiagramComponent基础用法
- 模块注入模式
- 独立组件设置
📄 阅读:references/nodes.md
- 创建并向图表添加节点
- 偏移和定位(offsetX、offsetY)
- 节点尺寸(width、height)
- 内置形状(Flow、Basic、Path)
- 自定义样式(fill、stroke、opacity)
- 节点模板和外观
- 展开/折叠节点组
- 节点事件(click、select、drag)
- 使用getNodeDefaults设置样式默认值
📄 阅读:references/connectors.md
- 三种连接器类型:直线、正交线、贝塞尔曲线
- 线段配置和路径查找
- 使用sourceID和targetID连接节点
- 连接器中的多线段
- 贝塞尔曲线控制点和方向
- 连接器自定义(stroke、fill、dashing)
- 连接器事件和交互
- 使用getConnectorDefaults设置样式默认值
Labels, Ports & Styling
标签、端口与样式
📄 Read: references/labels-and-annotations.md
- Adding annotations to nodes and connectors
- Label appearance (font, color, bold, italic, alignment)
- Positioning labels on connectors (start, end, center)
- Node labels vs connector labels
- Label interaction (edit mode, drag, resize)
- Label events (edit, focus, blur)
- Formatting with markdown or HTML
📄 Read: references/ports.md
- Port types and positioning on nodes
- Appearance customization (shape, fill, size)
- Connecting connectors to specific ports
- Connection visibility and constraints
- Port interaction and visibility
- getPortDefaults pattern
📄 Read: references/shapes-and-styles.md
- Built-in shape types: Flow, Basic, Path, Image, HTML, Native SVG
- Flow chart shapes (process, decision, start, end, etc.)
- Style properties (fill, stroke, strokeWidth, dashArray, shadow)
- CSS class and theme customization
- Gradient and pattern fills
📄 阅读:references/labels-and-annotations.md
- 为节点和连接器添加注释
- 标签外观(字体、颜色、加粗、斜体、对齐方式)
- 连接器上的标签定位(起点、终点、中心)
- 节点标签与连接器标签的区别
- 标签交互(编辑模式、拖拽、调整大小)
- 标签事件(edit、focus、blur)
- 使用markdown或HTML格式化
📄 阅读:references/ports.md
- 端口类型和在节点上的定位
- 外观自定义(形状、填充、尺寸)
- 将连接器连接到特定端口
- 连接可见性和约束
- 端口交互和可见性
- getPortDefaults模式
📄 阅读:references/shapes-and-styles.md
- 内置形状类型:Flow、Basic、Path、Image、HTML、原生SVG
- 流程图形状(流程、决策、开始、结束等)
- 样式属性(fill、stroke、strokeWidth、dashArray、shadow)
- CSS类和主题自定义
- 渐变和图案填充
Advanced Diagrams
高级图表
📄 Read: references/bpmn-diagrams.md
- BPMN module injection and setup
- BPMN shapes overview and standard notation
- Activities (task, subprocess, expanded subprocess, loop)
- Events (start, end, intermediate catch/throw)
- Gateways (exclusive, parallel, inclusive, complex)
- Flows (sequence flow, message flow, association)
- Data objects and data sources
- Groups and text annotations
- BPMN-specific styling and labels
📄 Read: references/uml-diagrams.md
- UML class diagram shapes
- Classifier shapes (class, interface, enumeration, package, component)
- Class attributes, methods, visibility modifiers
- UML relationships (association, generalization, aggregation, composition)
- UML sequence diagrams
- Lifelines, actors, messages (sync, async, return)
- Interaction frames and combined fragments
📄 阅读:references/bpmn-diagrams.md
- BPMN模块注入和设置
- BPMN形状概述和标准符号
- 活动(任务、子流程、展开式子流程、循环)
- 事件(开始、结束、中间捕获/抛出)
- 网关(排他、并行、包容、复杂)
- 流(序列流、消息流、关联)
- 数据对象和数据源
- 组和文本注释
- BPMN特定样式和标签
📄 阅读:references/uml-diagrams.md
- UML类图形状
- 分类器形状(类、接口、枚举、包、组件)
- 类属性、方法、可见性修饰符
- UML关系(关联、泛化、聚合、组合)
- UML序列图
- 生命线、参与者、消息(同步、异步、返回)
- 交互框架和组合片段
Layout & Structure
布局与结构
📄 Read: references/layouts.md
- Hierarchical tree layout with top-down, bottom-up, left-right, right-left
- Organizational chart layout
- Mindmap layout (sub-trees, branches)
- Radial tree layout
- Flowchart layout with swimlanes
- Complex hierarchical tree with extended nodes
- Automatic layout configuration
- Layout customization (orientation, spacing, margin)
- Layout events and completion
📄 Read: references/swimlanes.md
- Swimlane structure overview (header, children, phases)
- Creating lanes and phases within swimlanes
- Swimlane children positioning and constraints
- Swimlane headers and labeling
- Swimlane palette integration
- Swimlane interaction (resize, move, add/remove children)
📄 Read: references/groups-and-containers.md
- Grouping nodes together
- Group operations (add/remove children, expand/collapse)
- Container nodes with padding and layout
- Child positioning within containers
- Container constraints
📄 阅读:references/layouts.md
- 层级树布局(自上而下、自下而上、从左到右、从右到左)
- 组织架构图布局
- 思维导图布局(子树、分支)
- 放射状树布局
- 带泳道的流程图布局
- 带扩展节点的复杂层级树
- 自动布局配置
- 布局自定义(方向、间距、边距)
- 布局事件和完成回调
📄 阅读:references/swimlanes.md
- 泳道结构概述(标题、子项、阶段)
- 在泳道内创建分区和阶段
- 泳道子项的定位和约束
- 泳道标题和标签
- 泳道面板集成
- 泳道交互(调整大小、移动、添加/删除子项)
📄 阅读:references/groups-and-containers.md
- 将节点分组
- 组操作(添加/删除子项、展开/折叠)
- 带内边距和布局的容器节点
- 容器内子项的定位
- 容器约束
Interaction & Tools
交互与工具
📄 Read: references/symbol-palette.md
- SymbolPaletteComponent setup and integration
- Defining palette symbols and categories
- Drag and drop symbols to diagram
- Palette customization (icons, search, categories, size)
- Symbol palette events
- Creating custom symbol libraries
📄 Read: references/data-binding.md
- DataManager and dataSourceSettings configuration
- Mapping data to nodes (id, parentId, nodeTemplate)
- Rendering organizational charts from JSON data
- PostgreSQL data source integration
- setNodeTemplate for data-driven node styling
- Dynamic data updates and refresh
📄 Read: references/interaction-and-tools.md
- Node selection, drag, and resize interactions
- Tool modes (pointer, draw, pan, pan-select)
- Constraints (node constraints, connector constraints, diagram constraints)
- Commands (keyboard shortcuts, custom commands)
- Undo and Redo functionality
- Context menu (right-click menu)
- User handles (custom connection handles)
📄 阅读:references/symbol-palette.md
- SymbolPaletteComponent的设置和集成
- 定义面板符号和分类
- 将符号拖拽到图表中
- 面板自定义(图标、搜索、分类、尺寸)
- 符号面板事件
- 创建自定义符号库
📄 阅读:references/data-binding.md
- DataManager和dataSourceSettings配置
- 将数据映射到节点(id、parentId、nodeTemplate)
- 从JSON数据渲染组织架构图
- PostgreSQL数据源集成
- 使用setNodeTemplate实现数据驱动的节点样式
- 动态数据更新和刷新
📄 阅读:references/interaction-and-tools.md
- 节点选择、拖拽和调整大小交互
- 工具模式(指针、绘制、平移、平移选择)
- 约束(节点约束、连接器约束、图表约束)
- 命令(键盘快捷键、自定义命令)
- 撤销和重做功能
- 上下文菜单(右键菜单)
- 用户手柄(自定义连接手柄)
Serialization & Export
序列化与导出
📄 Read: references/serialization-and-export.md
- saveDiagram and loadDiagram (JSON serialization)
- Export to image formats (PNG, SVG, PDF)
- Print diagram functionality
- Visio file import (.vsdx)
- EJ1 API migration serialization
- Custom serialization handling
📄 阅读:references/serialization-and-export.md
- saveDiagram和loadDiagram(JSON序列化)
- 导出为图片格式(PNG、SVG、PDF)
- 图表打印功能
- Visio文件导入(.vsdx)
- EJ1 API迁移序列化
- 自定义序列化处理
Configuration & Settings
配置与设置
📄 Read: references/diagram-settings.md
- Layers (add, lock, visibility, ordering)
- Virtualization (performance optimization for large diagrams)
- Grid lines (snapping, dots/lines, step size)
- Ruler (horizontal and vertical measurement rulers)
- Scroll settings (auto-scroll, pan)
- Page settings (size, orientation, margin, fit to page)
- Tooltip configuration
- Overview panel for navigation
- Localization and language support
- Accessibility (WCAG, ARIA labels, keyboard navigation)
📄 阅读:references/diagram-settings.md
- 图层(添加、锁定、可见性、排序)
- 虚拟化(大型图表的性能优化)
- 网格线(对齐、点/线、步长)
- 标尺(水平和垂直测量标尺)
- 滚动设置(自动滚动、平移)
- 页面设置(尺寸、方向、边距、适配页面)
- 提示框配置
- 导航概览面板
- 本地化和语言支持
- 可访问性(WCAG、ARIA标签、键盘导航)
Quick Start Example
快速入门示例
Here's a minimal diagram to get started:
typescript
import { Component, Inject } from '@angular/core';
import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams';
@Component({
selector: 'app-diagram',
template: `
<ejs-diagram #diagram
width="100%"
height="600px"
[nodes]="nodes"
[connectors]="connectors">
</ejs-diagram>
`,
standalone: true,
imports: [DiagramModule]
})
export class DiagramComponent {
nodes = [
{
id: 'start',
width: 80,
height: 80,
offsetX: 150,
offsetY: 150,
shape: { type: 'Flow', shape: 'Terminator' },
annotations: [{ content: 'START' }]
},
{
id: 'process',
width: 100,
height: 80,
offsetX: 350,
offsetY: 150,
shape: { type: 'Flow', shape: 'Process' },
annotations: [{ content: 'Process' }]
},
{
id: 'end',
width: 80,
height: 80,
offsetX: 550,
offsetY: 150,
shape: { type: 'Flow', shape: 'Terminator' },
annotations: [{ content: 'END' }]
}
];
connectors = [
{ id: 'connector1', sourceID: 'start', targetID: 'process' },
{ id: 'connector2', sourceID: 'process', targetID: 'end' }
];
}For detailed setup, read Getting Started.
以下是一个最简图表示例,帮助你快速上手:
typescript
import { Component, Inject } from '@angular/core';
import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams';
@Component({
selector: 'app-diagram',
template: `
<ejs-diagram #diagram
width="100%"
height="600px"
[nodes]="nodes"
[connectors]="connectors">
</ejs-diagram>
`,
standalone: true,
imports: [DiagramModule]
})
export class DiagramComponent {
nodes = [
{
id: 'start',
width: 80,
height: 80,
offsetX: 150,
offsetY: 150,
shape: { type: 'Flow', shape: 'Terminator' },
annotations: [{ content: 'START' }]
},
{
id: 'process',
width: 100,
height: 80,
offsetX: 350,
offsetY: 150,
shape: { type: 'Flow', shape: 'Process' },
annotations: [{ content: 'Process' }]
},
{
id: 'end',
width: 80,
height: 80,
offsetX: 550,
offsetY: 150,
shape: { type: 'Flow', shape: 'Terminator' },
annotations: [{ content: 'END' }]
}
];
connectors = [
{ id: 'connector1', sourceID: 'start', targetID: 'process' },
{ id: 'connector2', sourceID: 'process', targetID: 'end' }
];
}如需详细设置,请阅读入门指南。
Module Injection Pattern
模块注入模式
Syncfusion Diagram uses Inject directive for feature registration:
typescript
import { Component, Inject } from '@angular/core';
import { BpmnDiagrams, Swimlane, SymbolPalette } from '@syncfusion/ej2-angular-diagrams';
Diagram.Inject(BpmnDiagrams, SymbolPalette)Always inject the features you use. This keeps bundle size small and makes dependencies explicit.
Syncfusion Diagram使用Inject指令进行功能注册:
typescript
import { Component, Inject } from '@angular/core';
import { BpmnDiagrams, Swimlane, SymbolPalette } from '@syncfusion/ej2-angular-diagrams';
Diagram.Inject(BpmnDiagrams, SymbolPalette)请始终仅注入你使用的功能模块。这样可以减小包体积,并明确依赖关系。
Common Patterns
常见模式
1. Get Node/Connector Defaults
1. 获取节点/连接器默认值
typescript
getNodeDefaults(node: NodeModel): NodeModel {
return {
shape: { type: 'Flow', shape: 'Process' },
style: { fill: '#90EE90', stroke: '#228B22' }
};
}typescript
getNodeDefaults(node: NodeModel): NodeModel {
return {
shape: { type: 'Flow', shape: 'Process' },
style: { fill: '#90EE90', stroke: '#228B22' }
};
}2. Bind Data to Nodes
2. 将数据绑定到节点
typescript
dataSourceSettings: {
id: 'id',
parentId: 'parentId',
dataSource: yourDataArray
}typescript
dataSourceSettings: {
id: 'id',
parentId: 'parentId',
dataSource: yourDataArray
}3. Handle Selection
3. 处理选择事件
typescript
diagram.selectionChange((args) => {
console.log('Selected:', args.newItems);
});typescript
diagram.selectionChange((args) => {
console.log('Selected:', args.newItems);
});4. Export Diagram
4. 导出图表
typescript
diagram.exportDiagram({format: 'PNG', fileName: 'diagram'});typescript
diagram.exportDiagram({format: 'PNG', fileName: 'diagram'});5. Serialize Diagram
5. 序列化图表
typescript
const diagramData = diagram.saveDiagram();
localStorage.setItem('diagram', JSON.stringify(diagramData));typescript
const diagramData = diagram.saveDiagram();
localStorage.setItem('diagram', JSON.stringify(diagramData));Common Mistakes
常见错误
❌ Shape Type Errors
❌ 形状类型错误
Mistake:
typescript
// ❌ WRONG - Shape type should be 'Flow', not 'FlowShape'
shape: { type: 'FlowShape', shape: 'Process' }Correct:
typescript
// ✅ CORRECT - Use 'Flow' for flowchart shapes
shape: { type: 'Flow', shape: 'Process' }
// ✅ CORRECT - Use 'Bpmn' for BPMN shapes
shape: { type: 'Bpmn', shape: 'Task' }
// ✅ CORRECT - Use 'Basic' for basic geometries
shape: { type: 'Basic', shape: 'Rectangle' }Reference: references/shapes-and-styles.md
错误示例:
typescript
// ❌ 错误 - 形状类型应为'Flow',而非'FlowShape'
shape: { type: 'FlowShape', shape: 'Process' }正确示例:
typescript
// ✅ 正确 - 流程图形状使用'Flow'
shape: { type: 'Flow', shape: 'Process' }
// ✅ 正确 - BPMN形状使用'Bpmn'
shape: { type: 'Bpmn', shape: 'Task' }
// ✅ 正确 - 基础几何形状使用'Basic'
shape: { type: 'Basic', shape: 'Rectangle' }参考文档: references/shapes-and-styles.md
❌ Invalid Module in Diagram.Inject()
❌ 在Diagram.Inject()中使用无效模块
Wrong:
typescript
// ❌ Swimlane is NOT an injectable module
Diagram.Inject(BpmnDiagrams, Swimlane);Correct:
typescript
// ✅ Only inject verified documented modules
Diagram.Inject(BpmnDiagrams);📄 Verify injectable modules in:,references/bpmn-diagrams.mdreferences/swimlanes.md
错误示例:
typescript
// ❌ Swimlane不是可注入模块
Diagram.Inject(BpmnDiagrams, Swimlane);正确示例:
typescript
// ✅ 仅注入已验证的文档化模块
Diagram.Inject(BpmnDiagrams);📄 请在以下文档中验证可注入模块:,references/bpmn-diagrams.mdreferences/swimlanes.md
❌ whiteSpace
Does Not Exist in Annotation Style
whiteSpace❌ Annotation Style中不存在whiteSpace
属性
whiteSpaceWrong:
typescript
// ❌ whiteSpace is NOT a valid TextStyleModel property
annotations: [{
content: 'Multi\nLine',
style: { fontSize: 11, whiteSpace: 'pre-wrap' } // ❌
}]Correct:
typescript
// ✅ Use \n in content — valid style props:
// fontSize, color, bold, italic, fontFamily,
// opacity, strokeColor, strokeWidth, fill
annotations: [{
content: 'Multi\nLine',
style: { fontSize: 11, color: '#000', bold: true }
}]📄 Verify annotation style properties in:references/labels-and-annotations.md
错误示例:
typescript
// ❌ whiteSpace不是TextStyleModel的有效属性
annotations: [{
content: 'Multi\nLine',
style: { fontSize: 11, whiteSpace: 'pre-wrap' } // ❌
}]正确示例:
typescript
// ✅ 在content中使用\n换行 — 有效的样式属性包括:
// fontSize, color, bold, italic, fontFamily,
// opacity, strokeColor, strokeWidth, fill
annotations: [{
content: 'Multi\nLine',
style: { fontSize: 11, color: '#000', bold: true }
}]📄 请在以下文档中验证注释样式属性:references/labels-and-annotations.md
❌ updateNode()
Does Not Exist on DiagramComponent
updateNode()❌ DiagramComponent中不存在updateNode()
方法
updateNode()Wrong:
typescript
// ❌ updateNode() does not exist in EJ2 Diagram API
this.diagram.updateNode('nodeId', { style: { fill: '#ff0000' } });Correct:
typescript
// ✅ getObject() → mutate property → dataBind()
const node = this.diagram.getObject('nodeId') as NodeModel;
if (node) {
node.style!.fill = '#ff0000';
this.diagram.dataBind(); // ← always required after mutation
}📄 Verify runtime APIs in:references/nodes.md
错误示例:
typescript
// ❌ EJ2 Diagram API中不存在updateNode()方法
this.diagram.updateNode('nodeId', { style: { fill: '#ff0000' } });正确示例:
typescript
// ✅ 使用getObject() → 修改属性 → dataBind()
const node = this.diagram.getObject('nodeId') as NodeModel;
if (node) {
node.style!.fill = '#ff0000';
this.diagram.dataBind(); // ← 修改后必须调用此方法
}📄 请在以下文档中验证运行时API:references/nodes.md
❌ Data Binding Configuration
❌ 数据绑定配置错误
Mistake:
typescript
// ❌ WRONG - Missing proper data source setup
nodes = this.employeeData; // Direct array assignmentCorrect:
typescript
// ✅ CORRECT - Use dataSourceSettings with proper mapping
dataSourceSettings: {
id: 'EmployeeID',
parentId: 'ReportingManagerID',
dataSource: this.employeeData
}
// Then configure setNodeTemplate for rendering:
setNodeTemplate(obj: NodeModel): void {
// obj contains the data row
obj.width = 100;
obj.height = 60;
obj.annotations = [{
content: obj.data.EmployeeName
}];
}Reference: references/data-binding.md
错误示例:
typescript
// ❌ 错误 - 缺少正确的数据源设置
nodes = this.employeeData; // 直接赋值数组正确示例:
typescript
// ✅ 正确 - 使用dataSourceSettings并配置映射
dataSourceSettings: {
id: 'EmployeeID',
parentId: 'ReportingManagerID',
dataSource: this.employeeData
}
// 然后配置setNodeTemplate用于渲染:
setNodeTemplate(obj: NodeModel): void {
// obj包含数据行
obj.width = 100;
obj.height = 60;
obj.annotations = [{
content: obj.data.EmployeeName
}];
}参考文档: references/data-binding.md
❌ Standalone Component Setup
❌ 独立组件设置错误
Mistake:
typescript
// ❌ WRONG - Using traditional decorator without standalone
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
imports: [DiagramModule]
// Missing: standalone: true
})Correct:
typescript
// ✅ CORRECT - Mark as standalone component
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
standalone: true, // ← Add this
imports: [CommonModule, DiagramModule],
})Reference: references/getting-started.md
错误示例:
typescript
// ❌ 错误 - 使用传统装饰器但未设置standalone
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
imports: [DiagramModule]
// 缺失: standalone: true
})正确示例:
typescript
// ✅ 正确 - 标记为独立组件
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
standalone: true, // ← 添加此属性
imports: [CommonModule, DiagramModule],
})参考文档: references/getting-started.md
⚠️ Performance Tips
⚠️ 性能优化建议
- Virtualization: For diagrams with 1000+ nodes, enable virtualization in references/diagram-settings.md
- Layout Performance: Pre-compute positions for complex hierarchies
- Connector Updates: Use instead of recreating connectors
connectorChanges - Export Large Diagrams: Use incremental approach for PDFs > 50MB
- 虚拟化:对于包含1000+节点的图表,请在references/diagram-settings.md中启用虚拟化
- 布局性能:为复杂层级结构预计算位置
- 连接器更新:使用而非重新创建连接器
connectorChanges - 导出大型图表:对于大于50MB的PDF,使用增量导出方式
Next Steps
下一步
- Choose your diagram type: flowchart, BPMN, UML, org-chart, etc.
- Read the relevant reference files above
- Check Syncfusion Diagram Docs for API details
- Explore examples in their sample repository
- 选择你的图表类型:流程图、BPMN、UML、组织架构图等
- 阅读上述相关参考文档
- 查看Syncfusion Diagram官方文档获取API详情
- 在他们的示例仓库中探索更多示例