Implementing Syncfusion Angular Diagrams
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
Important: API Verification Required
API Verification Required: Always verify API class names, properties, and signatures by reading reference files (references/*.md) 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.
Component Overview
The Syncfusion Angular Diagram component provides a visual canvas for creating and editing diagrams:
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
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
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
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
Advanced Diagrams
📄 Read: references/entity-relationship-diagrams.md
- Entity Relationship Diagram design and database schema visualization
- ER entity nodes with ErShapeModel configuration
- Entity header, fields, and constraints (primary key, foreign key, unique, not null)
- Field management at runtime (add, remove, modify)
- Entity styling and alternate row colors
- ER relationships and connectors with Crow's Foot multiplicity notation
- Complete database schema examples (Customer-Order-Product)
📄 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 with participants, messages, and activation boxes
- Sequence participants with 6 stereotypes (Actor, Boundary, Control, Entity, Database, Default)
- Sequence messages with 6 types (Synchronous, Asynchronous, Reply, Create, Delete, Self)
- Activation boxes and destruction markers
- Destruction markers for participant termination
- Complete login flow and interaction sequence examples
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
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)
Serialization & Export
📄 Read: references/serialization-and-export.md
- saveDiagram and loadDiagram (JSON serialization)
- Mermaid syntax support (saveDiagramAsMermaid, loadDiagramFromMermaid)
- Detect unsaved changes with isModified property
- Export to image formats (PNG, SVG, PDF)
- Print diagram functionality
- Visio file import (.vsdx)
- EJ1 API migration serialization
- Custom serialization handling
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)
Quick Start Example
Here's a minimal diagram to get started:
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.
Module Injection Pattern
Syncfusion Diagram uses Inject directive for feature registration:
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.
Common Patterns
1. Get Node/Connector Defaults
getNodeDefaults(node: NodeModel): NodeModel {
return {
shape: { type: 'Flow', shape: 'Process' },
style: { fill: '#90EE90', stroke: '#228B22' }
};
}
2. Bind Data to Nodes
dataSourceSettings: {
id: 'id',
parentId: 'parentId',
dataSource: yourDataArray
}
3. Handle Selection
diagram.selectionChange((args) => {
console.log('Selected:', args.newItems);
});
4. Export Diagram
diagram.exportDiagram({format: 'PNG', fileName: 'diagram'});
5. Serialize Diagram
const diagramData = diagram.saveDiagram();
localStorage.setItem('diagram', JSON.stringify(diagramData));
Common Mistakes
❌ Shape Type Errors
Mistake:
// ❌ WRONG - Shape type should be 'Flow', not 'FlowShape'
shape: { type: 'FlowShape', shape: 'Process' }
Correct:
// ✅ 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
❌ Invalid Module in Diagram.Inject()
Wrong:
// ❌ Swimlane is NOT an injectable module
Diagram.Inject(BpmnDiagrams, Swimlane);
Correct:
// ✅ Only inject verified documented modules
Diagram.Inject(BpmnDiagrams);
📄 Verify injectable modules in: references/bpmn-diagrams.md,
references/swimlanes.md
❌ whiteSpace Does Not Exist in Annotation Style
Wrong:
// ❌ whiteSpace is NOT a valid TextStyleModel property
annotations: [{
content: 'Multi\nLine',
style: { fontSize: 11, whiteSpace: 'pre-wrap' } // ❌
}]
Correct:
// ✅ 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
❌ updateNode() Does Not Exist on DiagramComponent
Wrong:
// ❌ updateNode() does not exist in EJ2 Diagram API
this.diagram.updateNode('nodeId', { style: { fill: '#ff0000' } });
Correct:
// ✅ 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
❌ Data Binding Configuration
Mistake:
// ❌ WRONG - Missing proper data source setup
nodes = this.employeeData; // Direct array assignment
Correct:
// ✅ 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
❌ Standalone Component Setup
Mistake:
// ❌ WRONG - Using traditional decorator without standalone
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
imports: [DiagramModule]
// Missing: standalone: true
})
Correct:
// ✅ CORRECT - Mark as standalone component
@Component({
selector: 'app-diagram',
templateUrl: './component.html',
standalone: true, // ← Add this
imports: [CommonModule, DiagramModule],
})
Reference: 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
connectorChanges instead of recreating connectors
- Export Large Diagrams: Use incremental approach for PDFs > 50MB
Next Steps
1---2name: syncfusion-angular-diagram3description: Build and configure Syncfusion EJ2 Angular Diagram for flowcharts, org charts, process diagrams, and data-visualization. Trigger when users ask to create nodes/connectors, apply layouts, swimlane, use BPMN/UML shapes, ER diagrams, or add interactivity like drag-drop, zoom/pan, snapping, editing, and symbol palettes.4---56# Implementing Syncfusion Angular Diagrams78## When to Use This Skill910Use this skill when you need to:11- **Create visual diagrams** (flowcharts, org-charts, BPMN, UML)12- **Build interactive diagrams** with nodes and connectors13- **Apply layouts** (hierarchical, org-chart, mindmap, radial, flowchart)14- **Design BPMN or UML** diagrams for business processes15- **Add interaction** (drag, resize, selection, undo/redo)16- **Export or serialize** diagrams to JSON/images1718## Important: API Verification Required19 20**API Verification Required**: Always verify API class names, properties, and signatures by reading reference files (`references/*.md`) BEFORE generating code examples. Do not assume or infer class names.21⚠️ Before writing ANY code, review the **Common Mistakes** section directly below to avoid known invalid APIs and properties.22 23## Component Overview2425The **Syncfusion Angular Diagram component** provides a visual canvas for creating and editing diagrams:2627### Core Concepts28291. **Nodes** - Rectangles, circles, flowchart shapes, custom shapes302. **Connectors** - Lines linking nodes (Straight, Orthogonal, Bezier)313. **Labels** - Text annotations on nodes and connectors324. **Ports** - Connection points on node boundaries335. **Swimlanes** - Horizontal/vertical lanes for process diagrams346. **Layouts** - Automatic positioning (hierarchical, org-chart, mindmap, etc.)357. **BPMN Shapes** - Business process diagram standardized shapes368. **UML Diagrams** - Class and sequence diagram notation379. **Symbol Palette** - Draggable symbol library3810. **Data Binding** - Render diagrams from JSON data3940### Key Features4142- **Interactive editing:** Drag, resize, rotate nodes and connectors43- **Auto-layout:** Hierarchical, org-chart, mindmap, radial, flowchart layouts44- **BPMN & UML:** Built-in shape libraries for standard diagrams45- **Serialization:** Save/load diagrams as JSON46- **Export:** PNG, SVG, PDF image export and print47- **Undo/Redo:** Full history support48- **Virtualization:** Render large diagrams efficiently49- **Accessibility:** WCAG 2.1 compliance with keyboard navigation5051## Documentation and Navigation Guide5253Start with **Getting Started**, then jump to the specific feature you need:5455### Core Diagram Building56📄 **Read:** [references/getting-started.md](references/getting-started.md)57- Installation and dependencies58- Theme setup (material, bootstrap, fabric)59- CSS/SCSS imports60- Basic DiagramComponent usage61- Module injection pattern62- Standalone component setup6364📄 **Read:** [references/nodes.md](references/nodes.md)65- Creating and adding nodes to diagram66- Offsetting and positioning (offsetX, offsetY)67- Node dimensions (width, height)68- Built-in shapes (Flow, Basic, Path)69- Custom styling (fill, stroke, opacity)70- Node templates and appearance71- Expand/collapse node groups72- Node events (click, select, drag)73- getNodeDefaults pattern for style defaults7475📄 **Read:** [references/connectors.md](references/connectors.md)76- Three connector types: Straight, Orthogonal, Bezier77- Segments configuration and pathfinding78- sourceID and targetID linking nodes79- Multiple segments in connectors80- Bezier control points and orientation81- Connector customization (stroke, fill, dashing)82- Connector events and interaction83- getConnectorDefaults pattern for style defaults8485### Labels, Ports & Styling86📄 **Read:** [references/labels-and-annotations.md](references/labels-and-annotations.md)87- Adding annotations to nodes and connectors88- Label appearance (font, color, bold, italic, alignment)89- Positioning labels on connectors (start, end, center)90- Node labels vs connector labels91- Label interaction (edit mode, drag, resize)92- Label events (edit, focus, blur)93- Formatting with markdown or HTML9495📄 **Read:** [references/ports.md](references/ports.md)96- Port types and positioning on nodes97- Appearance customization (shape, fill, size)98- Connecting connectors to specific ports99- Connection visibility and constraints100- Port interaction and visibility101- getPortDefaults pattern102103📄 **Read:** [references/shapes-and-styles.md](references/shapes-and-styles.md)104- Built-in shape types: Flow, Basic, Path, Image, HTML, Native SVG105- Flow chart shapes (process, decision, start, end, etc.)106- Style properties (fill, stroke, strokeWidth, dashArray, shadow)107- CSS class and theme customization108- Gradient and pattern fills109110### Advanced Diagrams111📄 **Read:** [references/entity-relationship-diagrams.md](references/entity-relationship-diagrams.md)112- Entity Relationship Diagram design and database schema visualization113- ER entity nodes with ErShapeModel configuration114- Entity header, fields, and constraints (primary key, foreign key, unique, not null)115- Field management at runtime (add, remove, modify)116- Entity styling and alternate row colors117- ER relationships and connectors with Crow's Foot multiplicity notation118- Complete database schema examples (Customer-Order-Product)119120📄 **Read:** [references/bpmn-diagrams.md](references/bpmn-diagrams.md)121- BPMN module injection and setup122- BPMN shapes overview and standard notation123- Activities (task, subprocess, expanded subprocess, loop)124- Events (start, end, intermediate catch/throw)125- Gateways (exclusive, parallel, inclusive, complex)126- Flows (sequence flow, message flow, association)127- Data objects and data sources128- Groups and text annotations129- BPMN-specific styling and labels130131📄 **Read:** [references/uml-diagrams.md](references/uml-diagrams.md)132- UML class diagram shapes133- Classifier shapes (class, interface, enumeration, package, component)134- Class attributes, methods, visibility modifiers135- UML relationships (association, generalization, aggregation, composition)136- UML sequence diagrams with participants, messages, and activation boxes137- Sequence participants with 6 stereotypes (Actor, Boundary, Control, Entity, Database, Default)138- Sequence messages with 6 types (Synchronous, Asynchronous, Reply, Create, Delete, Self)139- Activation boxes and destruction markers140- Destruction markers for participant termination141- Complete login flow and interaction sequence examples142143### Layout & Structure144📄 **Read:** [references/layouts.md](references/layouts.md)145- Hierarchical tree layout with top-down, bottom-up, left-right, right-left146- Organizational chart layout147- Mindmap layout (sub-trees, branches)148- Radial tree layout149- Flowchart layout with swimlanes150- Complex hierarchical tree with extended nodes151- Automatic layout configuration152- Layout customization (orientation, spacing, margin)153- Layout events and completion154155📄 **Read:** [references/swimlanes.md](references/swimlanes.md)156- Swimlane structure overview (header, children, phases)157- Creating lanes and phases within swimlanes158- Swimlane children positioning and constraints159- Swimlane headers and labeling160- Swimlane palette integration161- Swimlane interaction (resize, move, add/remove children)162163📄 **Read:** [references/groups-and-containers.md](references/groups-and-containers.md)164- Grouping nodes together165- Group operations (add/remove children, expand/collapse)166- Container nodes with padding and layout167- Child positioning within containers168- Container constraints169170### Interaction & Tools171📄 **Read:** [references/symbol-palette.md](references/symbol-palette.md)172- SymbolPaletteComponent setup and integration173- Defining palette symbols and categories174- Drag and drop symbols to diagram175- Palette customization (icons, search, categories, size)176- Symbol palette events177- Creating custom symbol libraries178179📄 **Read:** [references/data-binding.md](references/data-binding.md)180- DataManager and dataSourceSettings configuration181- Mapping data to nodes (id, parentId, nodeTemplate)182- Rendering organizational charts from JSON data183- PostgreSQL data source integration184- setNodeTemplate for data-driven node styling185- Dynamic data updates and refresh186187📄 **Read:** [references/interaction-and-tools.md](references/interaction-and-tools.md)188- Node selection, drag, and resize interactions189- Tool modes (pointer, draw, pan, pan-select)190- Constraints (node constraints, connector constraints, diagram constraints)191- Commands (keyboard shortcuts, custom commands)192- Undo and Redo functionality193- Context menu (right-click menu)194- User handles (custom connection handles)195196### Serialization & Export197📄 **Read:** [references/serialization-and-export.md](references/serialization-and-export.md)198- saveDiagram and loadDiagram (JSON serialization)199- Mermaid syntax support (saveDiagramAsMermaid, loadDiagramFromMermaid)200- Detect unsaved changes with isModified property201- Export to image formats (PNG, SVG, PDF)202- Print diagram functionality203- Visio file import (.vsdx)204- EJ1 API migration serialization205- Custom serialization handling206207### Configuration & Settings208📄 **Read:** [references/diagram-settings.md](references/diagram-settings.md)209- Layers (add, lock, visibility, ordering)210- Virtualization (performance optimization for large diagrams)211- Grid lines (snapping, dots/lines, step size)212- Ruler (horizontal and vertical measurement rulers)213- Scroll settings (auto-scroll, pan)214- Page settings (size, orientation, margin, fit to page)215- Tooltip configuration216- Overview panel for navigation217- Localization and language support218- Accessibility (WCAG, ARIA labels, keyboard navigation)219220---221222## Quick Start Example223224Here's a minimal diagram to get started:225226```typescript227import { Component, Inject } from '@angular/core';228import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams';229230@Component({231 selector: 'app-diagram',232 template: `233 <ejs-diagram #diagram 234 width="100%" 235 height="600px"236 [nodes]="nodes"237 [connectors]="connectors">238 </ejs-diagram>239 `,240 standalone: true,241 imports: [DiagramModule]242})243export class DiagramComponent {244 nodes = [245 {246 id: 'start',247 width: 80,248 height: 80,249 offsetX: 150,250 offsetY: 150,251 shape: { type: 'Flow', shape: 'Terminator' },252 annotations: [{ content: 'START' }]253 },254 {255 id: 'process',256 width: 100,257 height: 80,258 offsetX: 350,259 offsetY: 150,260 shape: { type: 'Flow', shape: 'Process' },261 annotations: [{ content: 'Process' }]262 },263 {264 id: 'end',265 width: 80,266 height: 80,267 offsetX: 550,268 offsetY: 150,269 shape: { type: 'Flow', shape: 'Terminator' },270 annotations: [{ content: 'END' }]271 }272 ];273274 connectors = [275 { id: 'connector1', sourceID: 'start', targetID: 'process' },276 { id: 'connector2', sourceID: 'process', targetID: 'end' }277 ];278}279```280281For detailed setup, **read [Getting Started](references/getting-started.md)**.282283---284285## Module Injection Pattern286287Syncfusion Diagram uses **Inject directive** for feature registration:288289```typescript290import { Component, Inject } from '@angular/core';291import { BpmnDiagrams, Swimlane, SymbolPalette } from '@syncfusion/ej2-angular-diagrams';292Diagram.Inject(BpmnDiagrams, SymbolPalette)293```294295**Always inject the features you use.** This keeps bundle size small and makes dependencies explicit.296297---298299## Common Patterns300301### 1. Get Node/Connector Defaults302303```typescript304getNodeDefaults(node: NodeModel): NodeModel {305 return {306 shape: { type: 'Flow', shape: 'Process' },307 style: { fill: '#90EE90', stroke: '#228B22' }308 };309}310```311312### 2. Bind Data to Nodes313314```typescript315dataSourceSettings: {316 id: 'id',317 parentId: 'parentId',318 dataSource: yourDataArray319}320```321322### 3. Handle Selection323324```typescript325diagram.selectionChange((args) => {326 console.log('Selected:', args.newItems);327});328```329330### 4. Export Diagram331332```typescript333diagram.exportDiagram({format: 'PNG', fileName: 'diagram'});334```335336### 5. Serialize Diagram337338```typescript339const diagramData = diagram.saveDiagram();340localStorage.setItem('diagram', JSON.stringify(diagramData));341```342343---344345## Common Mistakes346347### ❌ Shape Type Errors348349**Mistake:**350```typescript351// ❌ WRONG - Shape type should be 'Flow', not 'FlowShape'352shape: { type: 'FlowShape', shape: 'Process' }353```354355**Correct:**356```typescript357// ✅ CORRECT - Use 'Flow' for flowchart shapes358shape: { type: 'Flow', shape: 'Process' }359360// ✅ CORRECT - Use 'Bpmn' for BPMN shapes361shape: { type: 'Bpmn', shape: 'Task' }362363// ✅ CORRECT - Use 'Basic' for basic geometries364shape: { type: 'Basic', shape: 'Rectangle' }365```366367**Reference:** [references/shapes-and-styles.md](references/shapes-and-styles.md)368369### ❌ Invalid Module in Diagram.Inject()370371**Wrong:**372```typescript373// ❌ Swimlane is NOT an injectable module374Diagram.Inject(BpmnDiagrams, Swimlane);375```376**Correct:**377```typescript378// ✅ Only inject verified documented modules379Diagram.Inject(BpmnDiagrams);380```381> 📄 Verify injectable modules in: `references/bpmn-diagrams.md`,382> `references/swimlanes.md`383384---385386### ❌ `whiteSpace` Does Not Exist in Annotation Style387388**Wrong:**389```typescript390// ❌ whiteSpace is NOT a valid TextStyleModel property391annotations: [{392 content: 'Multi\nLine',393 style: { fontSize: 11, whiteSpace: 'pre-wrap' } // ❌394}]395```396**Correct:**397```typescript398// ✅ Use \n in content — valid style props:399// fontSize, color, bold, italic, fontFamily,400// opacity, strokeColor, strokeWidth, fill401annotations: [{402 content: 'Multi\nLine',403 style: { fontSize: 11, color: '#000', bold: true }404}]405```406> 📄 Verify annotation style properties in:407> `references/labels-and-annotations.md`408409---410411### ❌ `updateNode()` Does Not Exist on DiagramComponent412413**Wrong:**414```typescript415// ❌ updateNode() does not exist in EJ2 Diagram API416this.diagram.updateNode('nodeId', { style: { fill: '#ff0000' } });417```418**Correct:**419```typescript420// ✅ getObject() → mutate property → dataBind()421const node = this.diagram.getObject('nodeId') as NodeModel;422if (node) {423 node.style!.fill = '#ff0000';424 this.diagram.dataBind(); // ← always required after mutation425}426```427> 📄 Verify runtime APIs in: `references/nodes.md`428429### ❌ Data Binding Configuration430431**Mistake:**432```typescript433// ❌ WRONG - Missing proper data source setup434nodes = this.employeeData; // Direct array assignment435```436437**Correct:**438```typescript439// ✅ CORRECT - Use dataSourceSettings with proper mapping440dataSourceSettings: {441 id: 'EmployeeID',442 parentId: 'ReportingManagerID',443 dataSource: this.employeeData444}445446// Then configure setNodeTemplate for rendering:447setNodeTemplate(obj: NodeModel): void {448 // obj contains the data row449 obj.width = 100;450 obj.height = 60;451 obj.annotations = [{452 content: obj.data.EmployeeName453 }];454}455```456457**Reference:** [references/data-binding.md](references/data-binding.md)458459### ❌ Standalone Component Setup460461**Mistake:**462```typescript463// ❌ WRONG - Using traditional decorator without standalone464@Component({465 selector: 'app-diagram',466 templateUrl: './component.html',467 imports: [DiagramModule]468 // Missing: standalone: true469})470```471472**Correct:**473```typescript474// ✅ CORRECT - Mark as standalone component475@Component({476 selector: 'app-diagram',477 templateUrl: './component.html',478 standalone: true, // ← Add this479 imports: [CommonModule, DiagramModule], 480})481```482483**Reference:** [references/getting-started.md](references/getting-started.md)484485### ⚠️ Performance Tips486487- **Virtualization:** For diagrams with 1000+ nodes, enable virtualization in [references/diagram-settings.md](references/diagram-settings.md)488- **Layout Performance:** Pre-compute positions for complex hierarchies489- **Connector Updates:** Use `connectorChanges` instead of recreating connectors490- **Export Large Diagrams:** Use incremental approach for PDFs > 50MB491492---493494## Next Steps495496- Choose your diagram type: flowchart, BPMN, UML, org-chart, etc.497- Read the relevant reference files above498- Check [Syncfusion Diagram Docs](https://ej2.syncfusion.com/angular/documentation/diagram/diagram-overview/) for API details499- Explore examples in [their sample repository](https://github.com/syncfusion/ej2-angular-samples)500