mcpField
S
syncfusion-javascript-diagram

syncfusion-javascript-diagram

github.com/syncfusionDevelopment065 installsUpdated 1w ago
Repository

About syncfusion-javascript-diagram

A reference-based skill for TypeScript and JavaScript developers working with Syncfusion Diagram to build and configure interactive diagrams. It restricts generated code to the supplied references and flags undocumented features instead of guessing.

Key features

  1. 01Configure nodes, connectors, and labels
  2. 02Set up automatic layouts and data binding
  3. 03Configure diagram interactions and styling
  4. 04Serialize, export, and print diagrams
  5. 05Check references before generating code

Use cases

  1. 01Build flowcharts or organizational charts
  2. 02Create BPMN, UML, or ER diagrams
  3. 03Configure diagram nodes and connectors
  4. 04Add layout or export capabilities

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/syncfusion/javascript-ui-controls-skills --skill syncfusion-javascript-diagram

After installing, type/syncfusion-javascript-diagramin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
advanced-features.md
bpmn-diagrams.md
connectors-and-connections.md
data-binding-and-loading.md
diagram-settings.md
entity-relationship-diagrams.md
getting-started.md
groups-and-containers.md
interaction-and-tools.md
labels-and-annotations.md
layout-and-automation.md
nodes-and-shapes.md
ports.md
serialization-and-export.md
shapes-and-styles.md
styling-and-appearance.md
swimlanes.md
symbol-palette.md
uml-diagrams.md

Details

From the project README

⚠️ STRICT USAGE RULES — MANDATORY FOR ALL CODE GENERATION

These rules are non-negotiable and must be followed for every code generation request.

Rule A — Use Only Provided Reference Files

  1. Always read references/getting-started.md for every request
  2. Read additional reference files only if they match the user's query (see Navigation Guide below)
  3. No external knowledge allowed:
    • ❌ Do NOT use internet documentation
    • ❌ Do NOT use training-data assumptions about Syncfusion APIs
    • ❌ Do NOT reference older EJ1 APIs or deprecated syntax
    • ✅ If a feature cannot be confirmed from reference files, apply Rule B

Rule B — No Guessing, No Inference

If a feature, property, API, or behavior is not explicitly documented in the reference files:

You must NOT:

  • Invent class properties, subclasses, or constructor overloads
  • Infer JavaScript/TypeScript callback signatures or method names
  • Assume module injections exist beyond those documented
  • Generalize from other Syncfusion components
  • Use deprecated or undocumented shape types

Instead, respond with:

⚠️ NOT DOCUMENTED: [feature name] is not covered in the reference files.
Skipping this feature to avoid generating incorrect code.

Rule C — Enforce Required Module Injections

Before generating code for these features, always include the corresponding injection:

FeatureRequired Injection
Entity Relationship DiagramsDiagram.Inject(ErDiagrams)
BPMN diagramsDiagram.Inject(BpmnDiagrams)
Export / PrintDiagram.Inject(PrintAndExport)
Mind Map layoutDiagram.Inject(MindMap)
Complex Hierarchical layoutDiagram.Inject(ComplexHierarchicalTree)
Hierarchical or Organizational layoutDiagram.Inject(HierarchicalTree)
UML Sequence DiagramsNo additional injection required
Undo/RedoDiagram.Inject(UndoRedo)
Line DistributionDiagram.Inject(LineDistribution)
Line RoutingDiagram.Inject(LineRouting)
Mermaid SyntaxDiagram.Inject(FlowchartLayout, DataBinding) or Diagram.Inject(MindMap, DataBinding)

Do NOT assume any other injections exist unless confirmed in reference files.


Diagram Component Overview

The Diagram control is a feature-rich component for creating interactive, editable diagrams in TypeScript/JavaScript applications.

Core Elements

ElementPurposeCommon Properties
NodesGraphical shapes representing entitiesid, offsetX, offsetY, width, height, shape, style
ConnectorsLines/arrows connecting nodesid, sourceID, targetID, type, style, targetDecorator
LabelsText annotations on nodes/connectorscontent, font, alignment, offset

Key Features

✅ Automatic Layout (flowchart, hierarchical, organizational)
✅ Data Binding (JSON, parent-child relationships)
✅ Interactive Tools (drawing, selection, pan, zoom, drag-drop)
✅ Styling (CSS customization, themes, conditional styles)
✅ Serialization (save/load as JSON)
✅ Export (PNG, JPG, SVG, PDF)
✅ User Interactions (events, constraints, undo/redo)


Navigation Guide

Always read references/getting-started.md first, then read only files relevant to the request.

Reference FileRead When the Query Involves
📄 getting-started.mdEvery request — Package installation, imports, first diagram, initialization
📄 nodes-and-shapes.mdCreating/styling nodes, shapes, positioning, BPMN/UML shapes, annotations
📄 connectors-and-connections.mdLines (Straight/Orthogonal/Bezier), arrows, routing, sourceID/targetID, segments
📄 labels-and-annotations.mdText labels, font, alignment, hyperlinks on nodes/connectors
📄 ports.mdConnection points, port positioning, port constraints
📄 shapes-and-styles.mdFlow/Basic/Path/Image/HTML/Native shapes, fill, stroke, gradient, opacity
📄 data-binding-and-loading.mdDataSourceSettings, JSON loading, parent-child mapping, dynamic updates
📄 layout-and-automation.mdHierarchical, org chart, mind map, radial, symmetric layouts, orientation
📄 bpmn-diagrams.mdBPMN module injection, events, gateways, activities, data objects, annotations
📄 uml-diagrams.mdUML class diagrams, UML sequence diagrams, classifiers, relationships, participants, messages, fragments
📄 entity-relationship-diagrams.mdER entities, entity fields, data types, primary/foreign keys, relationships, Crow's Foot multiplicity, ERD styling
📄 swimlanes.mdSwimlane structure, lanes, phases, header config, interaction
📄 groups-and-containers.mdGrouping nodes, Canvas/Stack/Grid containers, nesting, boundaries
📄 symbol-palette.mdSymbolPaletteComponent, drag-drop, categories, custom symbols, search
📄 interaction-and-tools.mdDrawing tools, selection, constraints, pan/zoom, events, undo/redo
📄 styling-and-appearance.mdCSS theming, colors, fonts, accessibility, responsive design
📄 serialization-and-export.mdSave/load diagrams as JSON, prevent defaults, detect unsaved changes, export to image/PDF/Visio, Mermaid syntax, uploader support
📄 diagram-settings.mdLayers, virtualization, grid, ruler, scroll, page settings, tooltip, localization
📄 advanced-features.mdUndo/redo, custom commands, toolbars, performance optimization

Quick Start

1. Install Package

npm install @syncfusion/ej2-diagrams

2. Import Required Modules

import { Diagram, NodeModel, ConnectorModel } from '@syncfusion/ej2-diagrams';

3. Create Diagram with Nodes & Connectors

// Define nodes
let nodes: NodeModel[] = [
  {
    id: 'node1',
    offsetX: 250,
    offsetY: 250,
    width: 100,
    height: 100,
    style: { fill: '#6BA5D7' },
    annotations: [{ content: 'Start' }]
  },
  {
    id: 'node2',
    offsetX: 400,
    offsetY: 250,
    width: 100,
    height: 100,
    style: { fill: '#FFD700' },
    annotations: [{ content: 'Process' }]
  }
];

// Define connector between nodes
let connectors: ConnectorModel[] = [
  {
    id: 'connector1',
    sourceID: 'node1',
    targetID: 'node2',
    style: { strokeColor: '#6BA5D7' },
    targetDecorator: { shape: 'Arrow' }
  }
];

// Create diagram
let diagram: Diagram = new Diagram({
  width: '100%',
  height: '500px',
  nodes: nodes,
  connectors: connectors
});

diagram.appendTo('#diagram-container');

HTML:

<div id="diagram-container"></div>

Common Patterns

Flowchart Pattern

Creating a simple flowchart with decision points:

  • Use rectangle shapes for processes
  • Use diamond shapes for decisions
  • Connect with arrows
  • Apply Flowchart auto-layout

Organizational Chart Pattern

Creating hierarchical structures:

  • Use data binding with parent-child relationships
  • Apply HierarchicalTree layout
  • Define employee nodes with names/photos
  • Show reporting relationships via connectors

Network Diagram Pattern

Creating system architecture diagrams:

  • Use predefined shapes (server, database, client)
  • Connect with labeled lines showing data flow
  • Organize using grid-based positioning
  • Add icons and styling for clarity

Interactive Diagram Pattern

Building user-editable diagrams:

  • Enable drawing tools
  • Allow node/connector creation and deletion
  • Add context menus for operations
  • Implement save/load with serialization
  • Handle user events (selection, drag, resize)

When to Use This Skill

✅ Creating any diagram type in TypeScript/JavaScript
✅ Building flowcharts, process flows, or hierarchies
✅ Implementing BPMN or UML diagrams
✅ Configuring node/connector shapes, styles, annotations
✅ Setting up automatic layouts
✅ Adding symbol palettes for drag-and-drop
✅ Binding diagram data from APIs or JSON
✅ Exporting diagrams or printing
✅ Enabling drawing tools, undo/redo, layers

Do NOT use for: Simple static charts or graphs (use Chart component), data tables (use Grid component)


Key TypeScript Interfaces

InterfacePurposeKey Properties
NodeModelNode configurationid, offsetX, offsetY, width, height, shape, style, annotations
ConnectorModelConnector configurationid, sourceID, targetID, type, style, targetDecorator
ShapeModelShape definitiontype (Basic/BPMN/UML/Flow), shape name
AnnotationModelLabel on node/connectorcontent, font, alignment, offset
PortModelConnection pointid, offset, shape, visibility, constraints

Common Shape Types

Flow Shapes

Terminator, Process, Decision, Document, DirectData, MultiDocument, PreDefinedProcess, Delay, Annotation, ManualOperation, ManualInput, Card, Or, SummingJunction, Extract, Merge, Sort, OffPageReference

Usage:

shape: { type: 'Flow', shape: 'Process' }
Basic Shapes

Rectangle, Ellipse, Triangle, Pentagon, Hexagon, Heptagon, Octagon, Star, Cross, Diamond, CylindricalShape, Trapezoid, Parallelogram, Rhombus

Usage:

shape: { type: 'Basic', shape: 'Rectangle' }

Comments

Markdown supported