Skip to content

Diagram for Angular

AngularData visualization

A flowchart and diagram editor and viewer rendered in SVG from a JSON model: nodes (rectangle, rounded, ellipse, diamond, parallelogram, cylinder, document, or custom SVG from renderShape) with labels, positions, sizes, and ports; edges with straight, orthogonal, or curved routing, arrowheads, dashes, and labels; optional groups. Auto-layout is layered (Sugiyama style) or tree, in four directions, and can keep pinned or hand-moved nodes (keepPositions). Nodes form a multi-select listbox with one roving tab stop: arrow keys move focus to the nearest node in that direction. In edit mode nodes are added from a palette (click or drag), moved by pointer with grid snap and alignment guides, by keyboard (M, arrows), or by a single pointer (Move selection); connected by dragging from a port, by keyboard (C on the source, C or Enter on the target), or the Connect button; edges are reconnected by dragging their end handles; labels are edited inline (plain text); selections are copied, pasted, and deleted; marquee and Shift-click select several items; every edit is undoable. A text alternative table lists nodes and connections. Pan by dragging the background, Pan tool, or arrow keys on the canvas; zoom with Ctrl/Cmd + wheel, +/-, and fit. diagramToSvg, diagramToPng, and downloadDiagram export the drawing.

  • JSON modelNodes with seven shapes or custom SVG, ports, edges with three routings, arrowheads, labels, and groups.
  • Auto-layoutLayered flowcharts and trees in four directions, keeping hand-moved steps when you ask.
  • Full editingPalette, drag to move with snap and guides, connect from ports, reconnect, inline labels, copy, paste, undo.
  • Keyboard firstSpatial arrow navigation, move mode, a connect flow, and a text alternative listing every connection.
  • ExportTheme-matched SVG and PNG files without style attributes, ready to share.

Behavior, design tokens, and limitations are described on the Diagram page; this page covers the Angular API.

import { Component } from '@angular/core';
import type { DiagramModel, DiagramNodeActivateDetail } from '@absoluteui/components/diagram';
import { AuiDiagram } from '@absoluteui/angular/diagram';
@Component({
selector: 'app-workflow',
imports: [AuiDiagram],
template: `<aui-diagram label="Leave approval" [(model)]="model" [editable]="true" (nodeActivated)="open($event)"></aui-diagram>`,
})
export class WorkflowComponent {
model: DiagramModel = {
nodes: [
{ id: 'a', label: 'Request', x: 0, y: 0 },
{ id: 'b', label: 'Manager approval', shape: 'diamond', x: 240, y: 0 },
],
edges: [{ id: 'ab', from: 'a', to: 'b' }],
};
open(detail: DiagramNodeActivateDetail): void {
// show detail.node in a side panel
}
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiDiagram } from '@absoluteui/angular/diagram';

Defaults for every instance: provideAbsoluteUIConfig({ components: { diagram: { ... } } }) (see Configuration).

Class AuiDiagram; template reference #ref="auiDiagram".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
label string Required. Accessible name of the diagram (canvas); the node list is named ‘{label}: nodes’, the connection list ‘{label}: connections’, and the toolbar ‘{label} controls’. Non-empty.
editable boolean false Edit mode: palette, ports, moving, connecting, reconnecting, inline labels, copy and paste, delete, marquee selection, undo and redo.
layout DiagramAutoLayout | null Auto-layout settings { algorithm?: ‘layered’ | ‘tree’, direction?: ‘TB’ | ‘BT’ | ‘LR’ | ‘RL’, nodeGap?, rankGap?, sweeps?, keepPositions? }. Given on create, the layout runs once (keepPositions keeps nodes that have positions). Also the defaults of layout() and of placing nodes without positions.
palette readonly DiagramPaletteItem[] Shapes offered in edit mode: { shape, label, width?, height? }. Default: Step (rounded), Decision (diamond), Start or end (ellipse), Process, Input or output, Document, Database.
renderShape (node: Readonly<DiagramNode>, context: DiagramShapeContext) => SVGElement Draws nodes with shape ‘custom’ ({ width, height, selected, doc } context): return SVG content in local coordinates. The label is drawn on top; return non-interactive content.
canConnect (from: Readonly<DiagramNode>, to: Readonly<DiagramNode>) => boolean Veto new and changed connections (pointer, keyboard, addEdge). Self connections and exact duplicates are always refused (announced).
historyLimit number '100' Undo depth, integer 0..500 (0 disables history).
showGrid boolean true Dotted grid on the canvas in edit mode.
nodeWidth number '160' Default node width, integer 40..800 diagram px.
nodeHeight number '64' Default node height, integer 24..600 diagram px.
gridSize number '16' Grid spacing (snap, keyboard move step, grid dots), integer 4..200.
snapToGrid boolean true Snap moved and added nodes to the grid (keyboard moves step by gridSize; off: 1 px).
routing DiagramRouting 'orthogonal' Default edge routing (an edge’s own routing wins).
nodeGap number '40' Auto-layout space between neighbors of one rank, integer 8..400.
rankGap number '64' Auto-layout space between ranks, integer 16..600.
minZoom number '0.2' Smallest zoom factor, 0.05..1.
maxZoom number '3' Largest zoom factor, 1..8.
textAlternative DiagramTextAlternative 'toggle' Nodes and connections table below the canvas: behind a Show text description button (toggle), always shown, visually hidden but available to screen readers, or none.
locale string 'en-US' Locale of messages, counts, and zoom percentages.
direction Direction 'ltr' rtl mirrors auto-layout and the reading order of nodes; arrow keys stay spatial.
Model Type Change output Description
[(model)] DiagramModel (modelChange) JSON model { nodes, edges, groups? }. Node: { id, label, shape? (‘rectangle’ | ‘rounded’ (default) | ‘ellipse’ | ‘diamond’ | ‘parallelogram’ | ‘cylinder’ | ‘document’ | ‘custom’), x?, y?, width?, height? (16..2000), ports? ({ id, side, offset? }; default one per side: top, right, bottom, left), group?, pinned?, locked?, data? }. Edge: { id, from, to, fromPort?, toPort?, label?, routing?, arrowStart? (default ‘none’), arrowEnd? (default ‘arrow’; ‘none’ | ‘arrow’ | ‘triangle’ | ‘diamond’ | ‘circle’), dashed?, data? }. Group: { id, label }. Validated (DIAGRAM_OPTIONS). Nodes without x/y are placed by auto-layout. Replacing it with update() clears the undo history.
Output Payload Description
(changed) DiagramChangeDetail The model changed through the UI or an API method. Save detail.model. Re-emits aui-change.
(selected) DiagramSelectDetail The selection changed through the UI (click, Shift-click, marquee, Space, Ctrl/Cmd+A, Escape, paste, delete). select() does not emit. Re-emits aui-select.
(nodeActivated) DiagramNodeActivateDetail A node was activated: Enter or double-click in view mode, or double-click on a locked node in edit mode. Re-emits aui-node-activate.
(zoomed) DiagramZoomDetail The zoom changed through the toolbar, keys, Ctrl/Cmd + wheel, or zoomTo (fit does not emit). Re-emits aui-zoom.

Call them through a viewChild query or a template reference.

Method Description
select(ids: readonly string[]): void Replace the selection with these node and edge ids (no event).
focusNode(id: string): void Focus a node and pan it into view.
addNode(node: Partial<DiagramNode> & { label: string; }): string | undefined Add a node; id, size, and position are filled in (position: a free spot at the view center). Undoable; emits aui-change (‘add’); returns the id.
addEdge(edge: Partial<DiagramEdge> & { from: string; to: string; }): string | null | undefined Connect two nodes; null when refused (self, duplicate, canConnect). Undoable; emits aui-change (‘connect’).
updateNode(id: string, patch: Partial<Omit<DiagramNode, "id">>): void Change one node or edge (validated). Undoable; emits aui-change (‘update’).
updateEdge(id: string, patch: Partial<Omit<DiagramEdge, "id">>): void Change one node or edge (validated). Undoable; emits aui-change (‘update’).
moveNode(id: string, x: number, y: number): void Move a node (snapped when snapToGrid). Undoable; emits aui-change (‘move’).
remove(ids: readonly string[]): void Remove nodes (with their edges) and edges. Undoable; emits aui-change (‘delete’).
undo(): boolean | undefined Undo / redo the last edit (whole-model snapshots). Announce and emit aui-change (‘undo’ / ‘redo’); false when there is nothing to undo/redo.
redo(): boolean | undefined Undo / redo the last edit (whole-model snapshots). Announce and emit aui-change (‘undo’ / ‘redo’); false when there is nothing to undo/redo.
copy(): number | undefined Copy the selected nodes and the edges between them into the instance clipboard; paste them offset by two grid steps (new ids), select them, emit aui-change (‘paste’).
paste(): string[] | undefined Copy the selected nodes and the edges between them into the instance clipboard; paste them offset by two grid steps (new ids), select them, emit aui-change (‘paste’).
editLabel(id: string): void Open the inline label editor of a node or edge (edit mode). Enter or blur commits, Escape cancels.
fit(): void Scale (at most 100 %) and center the drawing; announces the zoom.
zoomTo(scale: number): void Zoom around the viewport center, clamped to minZoom..maxZoom; announces and emits aui-zoom.
centerOn(id: string): void Center the view on a node.
describe(): string | undefined Plain-text description: one line per node with its shape and connections.

Pattern: A focusable canvas (group, roledescription ‘canvas’) containing two multi-select listboxes, one for nodes and one for connections, each with one roving tab stop (WAI-ARIA APG listbox, with spatial arrow navigation for nodes). Each node’s accessible name states its label, shape, and connections; a text alternative table lists every node with what it leads to and comes from. Edits have keyboard and single-pointer paths (no deprecated ARIA drag-and-drop attributes) and are announced through live regions.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Diagram: Accessibility and performance.