Skip to content

NetworkGraph ​

NetworkGraph draws nodes and edges as an interactive SVG graph: a layered layout by default, other layouts through the layout prop, groups, swimlanes, ports, a minimap, search highlighting and export to SVG and PNG. Use it for process flows, dependency networks, PERT diagrams, lot genealogy or any diagram the user explores or edits.

It is controlled. Node moves, connections, deletions and label edits are emitted as proposals (node-move, connect, reconnect, …) that your code applies, and validateConnection can reject a connection synchronously. Positions you keep in your state override the layout.

Minimal example ​

vue
<script setup lang="ts">
import { ref } from 'vue'
import { NetworkGraph, type GraphEdge, type NetworkNode } from '@eightkk/vue-weave'
import '@eightkk/vue-weave/style.css'

const selected = ref('design')
const nodes: NetworkNode[] = [
  { id: 'design', label: 'Design' },
  { id: 'build', label: 'Build' },
  { id: 'release', label: 'Release' },
]
const edges: GraphEdge[] = [
  { id: 'db', from: 'design', to: 'build' },
  { id: 'br', from: 'build', to: 'release', label: 'Approved' },
]
</script>

<template>
  <NetworkGraph v-model:selected-id="selected" :nodes="nodes" :edges="edges" :options="{ direction: 'LR' }" />
</template>

Examples: Linked views, Bill of materials and the example index. Guide: Graph integration. Types: NetworkNode, GraphEdge, NetworkGraphExposed. The layout functions behind the component are on Graph layout and routing.

NetworkGraph ​

PropType / defaultMeaning
nodesreadonly N[] (N extends NetworkNode) / requiredID, label, optional detail, tone, shape and opaque data. N is inferred; see Typed data
edgesreadonly E[] (E extends GraphEdge) / requiredID, from/to node IDs, optional label, data, waypoints, edge style, markers and animation. E is inferred
selectedIdstring / undefinedControlled selection; also supports v-model:selected-id
relatedIdsReadonlySet<string> / undefinedEmphasizes included nodes and edges joining two included nodes
optionsGraphLayeredLayoutOptions / defaults belowBuilt-in layout configuration
layoutGraphLayoutFunction<GraphShownNode<N, G>, GraphShownEdge<E, G>> / undefinedOverrides built-in layout. Without groups it receives N and E; see Typed data. While rendering, a result without positive finite dimensions throws RangeError, a node without a box Missing layout box: <id> (Error), a box without finite coordinates and a positive size Invalid layout box: <id> (RangeError), and an edge without a path Missing layout path: <id> (Error; with routingPolicy: 'preserve' such an edge gets a built-in route instead)
labelsPartial<GraphLabels> / EnglishRegion, empty, zoom, zoomIn, zoomOut and fit
heightnumber or CSS string / 220pxSVG viewport height
showControlsboolean / trueZoom/fit buttons
dirChartDirection / ltrrtl or auto mirrors the zoom tools, minimap and label alignment; see Right-to-left layout

GraphLayoutOptions defaults are direction LR, nodeWidth 144, nodeHeight 58, columnGap 50, rowGap 24 and padding 20. Sizes must be finite numbers > 0; spacing must be finite numbers ≥ 0 (see Layout defaults and option checks). Empty graphs keep positive layout dimensions even with zero padding. TB changes the layout direction while preserving each node's physical width and height.

NetworkNode<D> has id, label, optional detail, tone (teal/blue/amber/violet), shape (NetworkNodeShape: box, rounded, diamond, ellipse or hexagon; see Node shapes, edge markers, animated and parallel edges), resizable and data (D, default unknown). GraphEdge<D> has id, from, to, optional label, data (D, default unknown) and points (waypoints, see Group collapse, edge styles and waypoints, level of detail and node resizing), and the optional edgeStyle, markerStart, markerEnd and animated (see Node shapes, edge markers, animated and parallel edges). The default renderer clips long text to the node box; its title exposes the full label. Node slots own their clipping and sizing.

A custom layout returns GraphLayout containing boxes, paths and edgeLabels Maps plus positive finite width and height. Each node box has x, y, width, height and rank. Each edge needs an SVG path. Labels are optional map entries. Coordinates are chart-local pixels. Keep paths and boxes within the supplied bounds for accurate fit-to-view.

Events are select(id), update:selectedId(id), and viewport-change({x,y,scale}). The last event reports pan/zoom/fit changes. Exposed methods are fit(options) (see Fit to selection), zoom(factor, optionalX, optionalY), getViewport() and setViewport({x,y,scale}), plus focusNode(id, options), revealNode(id, options) and getTargetClientRect(target) (see Large graphs, touch gestures, nested groups and search), exportSvg(options) and exportPng(options) (see Export to SVG and PNG), and toGraphPoint(clientX, clientY), getViewportCenter() and setViewportCenter(center, scale) (see Snap to grid, alignment guides, auto-pan, drops and clipboard). Viewport scale is clamped by zoom to 0.1–3, and setViewport requires the same range. When the whole graph only fits below 0.1, the lower limit becomes the fit scale for the current viewport size, so Fit to view always shows every node and a fitted viewport from getViewport() can be restored. The camera starts in automatic fit mode: it is fitted on mount, on resize and whenever the graph structure changes. Panning, zooming (buttons, Ctrl + wheel or pinch), the minimap, keyboard panning, auto-pan, setViewport, focusNode and fit({ ids }) switch it to manual mode. In manual mode a structural change that the parent accepts (connect, delete, paste or duplicate, a group collapse or expand) keeps the camera where it is; if the smaller graph raises the lower zoom limit, the scale is clamped to it around the stage centre and viewport-change is emitted. The camera re-fits and returns to automatic mode when the layout function or layout options (for example the direction) change, or when the graph is replaced: it was or becomes empty, or none of the previous node IDs remain. fit() without ids re-fits the whole graph and also returns to automatic fitting. Slots are node({node,box,selected,dimmed,related,highlighted,scale}) (NetworkNodeSlot), edge({edge,path,selected,related,highlighted,dimmed,scale}) (NetworkEdgeSlot, plus band for an edge in edgeBands), empty and the optional HTML tooltip({target}), plus the opt-in node-toolbar, edge-toolbar, group and minimap-node slots (see Label editing, lasso selection and item slots). In the node slot selected is the node selection, related is membership in relatedIds and highlighted in highlightedNodeIds. In the edge slot selected is the edge selection (selectedEdgeIds, only with edgesSelectable), related is true when both ends are in relatedIds and highlighted follows highlightedEdgeIds; before 0.4.0 the edge slot's selected carried the related state. The stylesheet paints node rectangles and text (fill, stroke, hover, selected, related and highlighted strokes), and these rules also reach rect and text elements in a node slot and override their presentation attributes such as fill. Set unstyledNodeSlots to keep that paint off the slot content: node groups rendered by the slot get vw-is-unstyled, and only the default renderer is painted; the focus ring, cursor and the user-select and pointer-events rules on text still apply. SVG slots must contain SVG elements. Each node and edge renders as its own internal component, so a node or edge slot runs again only when its own slot props change, when reactive state it reads changes, or when the slot function is replaced; a node drag re-renders the dragged nodes and their edges, not the whole graph. Read changing data reactively (props, refs, computed values) inside these slots, not from plain variables. The scale slot prop follows the camera, so zooming re-renders every node and edge slot; panning does not.

A narrow viewport initially focuses around the selected node at a readable scale. Fit-to-view explicitly shows the full graph. Pointer dragging pans the background. Ctrl+wheel zooms around the cursor. Arrow keys pan a focused SVG. Enter/Space select a focused node. Optional node movement and connection proposals are described in Graph editing and minimap.

NetworkGraph directions and crossing reduction ​

NetworkGraph options.direction accepts LR, TB, RL and BT. Edge endpoints, edited positions, ports, groups, the minimap and culling follow the chosen direction; unnamed endpoints use the mirrored sides for RL and BT, and the default handle of a node without ports sits on its left edge in RL. options.crossingReduction (none, barycenter, median) and options.crossingSweeps are passed to layoutLayeredGraph; the defaults (none, 8) apply no crossing reduction. When the layout prop is set, it replaces the built-in layout and these two options are ignored, while options.direction still controls edge routing for moved nodes.

Graph editing and minimap ​

APIBehavior
draggableEnables dragging and arrow-key movement. A node can opt out with draggable false.
positionsReadonlyMap of node ID to absolute GraphPoint in chart coordinates. Saved positions must be finite and nonnegative.
node-move(change)GraphNodeMove carries id, before and after. Update positions to accept the proposal.
connectableShows the node ports or a default handle. Drag between handles, or activate two handles with click, tap, Enter or Space.
validateConnectionSynchronous callback accepting true or undefined, rejecting with false or a reason string.
connect(connection)Emits from and to. The caller assigns an edge ID and updates edges.
connect-rejected(connection, reason)Reports rejected proposals.
selectedIds / update:selectedIdsControlled multiple selection when a set is supplied. Ctrl, Meta or Shift toggles membership. A plain selection replaces the set.
showMinimapShows graph geometry and the current viewport. Click to center on a point. Arrow keys pan.
gesture-start(gesture) / gesture-end(gesture)Report the gestures that a new layout or other source change would cancel, so an application can hold such changes until they end (see Asynchronous layouts and preserved routes). GraphGesture is { kind, source }; GraphGestureEnd adds outcome: 'committed' | 'cancelled'. kind (GraphGestureKind) is 'node-drag' (one node) or 'nodes-drag' (several, including a group label drag), 'node-resize', 'edge-reshape' (a waypoint or insert handle drag), 'connect' or 'reconnect' (from arming, by press, click, Enter or Space, until the connection is completed, dropped or cancelled; a press without movement stays armed), 'box-select', 'pan' (a background press, also one that does not move) or 'pinch'. source is 'keyboard' only for a connection or reconnection armed from the keyboard. Each gesture-start is followed by exactly one gesture-end of the same gesture, emitted after any proposal or *-rejected event: 'committed' when the user released the pointer or completed or dropped the connection (with or without a proposal), 'cancelled' on Escape, pointer cancellation, lost capture, a context menu, a second touch, a camera method (fit, zoom, setViewport, focusNode, revealNode, setViewportCenter, the minimap, keyboard panning, Ctrl + wheel), a change of data, layout, options or editing props, a resize of the stage, a direction change, or the component unmounting (emitted before it unmounts). A pointer gesture and an armed connection can be in flight at the same time, so count starts and ends rather than tracking one flag. Instant edits (arrow-key moves, keyboard resizing and waypoint edits, Delete, clipboard keys) and instant camera changes (zoom buttons, Ctrl + wheel, keyboard panning, the minimap, fit) are not gestures: they finish in one step, and a new layout cannot interrupt them. Nothing is emitted during server rendering.

Editing and the minimap are opt-in. The select and update:selectedId events fire for node selection, including when selectedIds is supplied. A selected node moves with the other selected movable nodes. Escape or a new layout discards an in-flight preview. groups and labels are compared by value like options, so a new but equal array or object (such as an inline literal in a parent template) neither rebuilds the layout nor cancels a drag or pan; a real change still cancels it. A custom layout function keeps reference semantics. A drag, pan or connection belongs to one pointer; while it is in flight, a press of another pointer (for example a pen next to the mouse) starts nothing, except that a second touch still starts a pinch. Keyboard movement uses ten chart units per arrow press and forty with Shift, or grid steps with snapGrid. Update positions with a fresh map when accepting a move. The built-in overlay reroutes incident edges as curves and preserves other paths. A custom router can own absolute positions by supplying a layout function without the positions overlay. A new layout cancels a gesture in flight, except when the layout function returns a new object with the same geometry (boxes, paths, label anchors, size and route metadata) for unchanged inputs, as an asynchronous layout cache can (see Asynchronous layouts and preserved routes).

The optional GraphLabels fields minimap, connectFrom, connectTo, reconnectSource, reconnectTarget, moveGroup, groupWithin (default "within"), rejected (default "This connection was rejected."), selectEdge (default "Select edge", followed by the edge label or ID) and deleteRejected (default "This deletion was rejected.") localize editor controls and announcements.

Related exported types: GraphConnection.

Named ports, reconnection and group actions ​

APIBehavior
NetworkNode.portsOptional named ports with an ID, side, direction, offset and label. Side is left, right, top or bottom; any other value throws an Error naming the node and the port. Direction defaults to both. Offset defaults to 0.5 and measures down a vertical side or across a horizontal side.
GraphEdge.fromPort / toPortOptional names scoped to the edge's source and target nodes. Named endpoints are validated. Unnamed edges keep their original routing.
reconnectable / reconnect(change)Select an edge, then drag a source or target endpoint to a port. With the keyboard, select the edge and activate an endpoint and destination port. The proposal includes id, before and after.
validateConnection(connection, replacingEdgeId)Receives the existing edge ID during reconnection. The application can exclude it when checking for duplicates.
boxSelectEnables Shift-drag on the canvas. Partially intersecting nodes count. Add Ctrl or Meta to retain the previous selection. Use with controlled selectedIds.
groupsGroups with id, label, nodeIds and an optional parentId (see Nested groups). The element type is the third type parameter G of NetworkGraph; with groups, slots and callbacks can also receive collapsed proxy nodes (see Typed data). Direct members are disjoint. The bounds follow member nodes. Drag a group label or focus it and use arrow keys to move movable members together.
nodes-move(changes)Emitted once when multiple nodes move. The node-move event covers single-node changes.

The application accepts reconnection by replacing the corresponding edge. Preserve the edge ID and metadata and set both endpoint port fields from the proposal, including clearing a field when it is absent. Group and multi-selection movements preserve relative offsets among the movable nodes. Nodes with draggable false keep their positions. Groups use absolute positions; nesting is opt-in through parentId. The diagram editor expects different source and target nodes.

Related exported types: GraphReconnect.

Port rules and valid-target hints ​

Port rules declare what each connection endpoint accepts: a type tag, a direction and a connection limit. They live in a separate GraphPortRules object rather than on GraphPort, so node, port and edge data and their types stay unchanged (the existing GraphPort.direction keeps its source/target meaning and still applies), rules can be derived from application state without copying them into nodes, and snapshots, clones and exports of graph data carry no rules.

APIBehavior
GraphPortRuletype (a string, or a list of accepted strings; two endpoints are compatible when either has no type or they share a tag), direction (GraphPortDirection: in only as a target, out only as a source, both, the default; it applies together with GraphPort.direction) and maxConnections (a non-negative integer counting edge ends at the endpoint; omit for no limit)
GraphPortRulesports (node ID → port ID → rule) for named ports, nodes (node ID → rule) for connections without a port, such as the single handle of a node without ports, and default for every endpoint without a rule of its own. An endpoint without any rule accepts everything
connectionRules (prop)Opt-in. Every connect and reconnect proposal, by pointer or by the keyboard two-step connect, is checked against the rules (with the current edges) first; a broken rule rejects it with its reason through connect-rejected and the polite live region, and validateConnection is not called. A proposal that passes the rules then goes to validateConnection, which can still reject it. While a connection or reconnection is in progress (pointer drag or armed keyboard connect), each connection handle gets vw-is-valid-target or vw-is-invalid-target; an invalid handle also gets aria-description with the reason (none for the other handles of the fixed node, which the component never connects). Invalid handles stay activatable, so a keyboard user hears the reason. Without the prop, markup and behavior are unchanged

A reconnection leaves the edge being reconnected out of the counts, so a port with maxConnections: 1 can move its own edge. Collapsed-group proxies are not in nodes, so with connectionRules a connection to a proxy is rejected as unknown-node. Rules that name an unknown node or port throw when the component first checks a connection; keep the rules in step with nodes.

ts
import { graphConnectionValidator, type GraphPortRules } from '@eightkk/vue-weave/core'

const rules: GraphPortRules = {
  ports: {
    sensor: { reading: { type: 'number', direction: 'out' } },
    average: { a: { type: 'number', direction: 'in', maxConnections: 1 }, out: { type: 'number', direction: 'out' } },
  },
}
// <NetworkGraph :connection-rules="rules" :validate-connection="noDuplicates" ... />
// Or, without the prop, compose the rules into one validator (rules first, then your own):
const validate = graphConnectionValidator(nodes, edges, rules, noDuplicates)

The core functions below implement the rules; the component uses createGraphConnectionChecker.

APIBehavior
cullOffscreenboolean / false. Renders only the nodes, edges, edge labels, connection handles and groups whose bounds intersect the viewport plus cullOverscan. Layout, routing, box selection, keyboard panning and the minimap still use every node, so the minimap and export show the whole graph. With culling on, the component also keeps a route cache (createGraphRouteCache) and its culling bounds across saved layouts, so a saved change such as a drop routes and measures again only the edges it can affect; the routes drawn are the same as without culling.
cullOverscannumber / 200. Margin in screen pixels around the viewport that stays rendered, so a short pan does not reveal blank space.
matchIdsReadonlySet<string> / undefined. When supplied, nodes outside the set are dimmed. An empty set dims every node.
dimmedIdsReadonlySet<string> / undefined. Nodes to dim explicitly. Combines with matchIds.
focusNode(id, options?)Exposed method. Centers the camera on the node and keeps the current scale, or applies options.scale (0.1 to 3, or down to the fit scale for a graph that only fits below 0.1). Throws Error for an unknown ID and RangeError for a bad scale. Emits viewport-change. It works with culling because culling follows the camera.
highlightedNodeIds / highlightedEdgeIdsReadonlySet<string> / undefined. Display-only highlight: the node group or the edge group gets the class vw-is-highlighted (stroke --vw-graph-highlight). See below.
revealNode(id, options?)Exposed method. Returns Promise<RevealResult>. For a shown node (a proxy included) it centers the camera like focusNode (options.scale, else the current scale), waits for the next render so culling has rendered the node, then moves keyboard focus to it when options.focus is true, and resolves { status: 'revealed' }. For a node hidden in a collapsed group it resolves { status: 'hidden-by-collapse', proxyId } and for an unknown ID { status: 'unknown' }, in both cases without moving the camera. It never throws for an ID; a bad scale rejects with RangeError. focusNode is unchanged.
getTargetClientRect(target)Exposed method. The DOMRect a ViewTarget of the graph view occupies on screen, in CSS pixels relative to the viewport like getBoundingClientRect: a node box, the bounding box of an edge path, or a group frame (a collapsed group is its proxy box). Undefined before mount, for targets of other views and for unknown or hidden nodes, edges and groups. The rectangle may lie outside the stage and does not depend on culling. Use it to place a toolbar or inspector next to an item.
target-enter / target-leave / target-activateEvents with ViewTargetEvent<GraphViewTarget>: { target: { view: 'graph', kind: 'node' | 'edge' | 'group', id }, source: 'pointer' | 'keyboard' }. Enter and leave fire when the pointer enters or leaves a node, an edge or a group frame, and when keyboard focus (focus-visible, not focus moved by a press) enters or leaves a node, an edge hit area or a group label. Activate fires on click, Enter or Space on a node (after select), an edge hit area (after edge-select) or a group label; a click that ends a drag does not activate. A proxy of a collapsed group is reported as kind 'group' with the group ID. Hovering never moves the camera.
background-clickGraphPoint in graph coordinates. Fires when a primary-button press on the empty canvas is released before it moves past the drag threshold (a click, not a pan or box selection). It does not fire for nodes, edges, group frames, handles or the zoom tools. The component keeps no selection of its own, so an application usually clears its controlled selection here.
idle-escapeKeyboardEvent. Declared as the listener prop onIdleEscape and delivered as a component event, so @idle-escape (with .once) works in templates and onIdleEscape (or onIdleEscapeOnce) in render functions. Fires when Escape is pressed inside the graph and cancels nothing of the graph's own: no gesture was in flight (no gesture-end for it; an Escape anywhere in the graph, including its zoom buttons, the minimap and toolbar slots, first cancels a drag or an armed connection), the key was not pressed in a text field, select or editable content, not handled by the label editor (which keeps its Escape) and not part of an input method composition, and no handler inside called preventDefault. Dismissing the tooltip does not count as cancelling. Opt-in, like background-click: an application usually clears its controlled selection here, so the first Escape cancels a drag and the next one clears the selection, without counting gesture-start and gesture-end itself.
NetworkGroup.parentIdOptional ID of another group. The group is painted inside its parent and the parent bounds enclose it.

Culling keeps these elements rendered even when they are off screen: selected nodes, the node or edge that has keyboard focus (and the node that owns a focused connection handle), nodes involved in a pointer drag or group drag, the source of a pending connection, the edge being reconnected and the groups that contain moved nodes. Elements that are culled are not in the DOM, so Tab skips them and they cannot be found by accessible name. Call focusNode(id) to bring one into view. Before mount there is no measured viewport. Server rendering and the first client render use the 1150 x 270 default viewport with the initial fit camera, so the output is deterministic and hydrates cleanly. The measured size replaces it after mount. Culling is based on bounding boxes: a path is bounded by its control points, and edge labels are included with a fixed reach, so culling errs on the side of rendering. Custom node and edge slots are not rendered for culled elements.

Two-finger gestures use Pointer Events with pointerType touch. When a second finger lands, any in-flight one-finger drag, connection, box selection or pan is cancelled without emitting a proposal. Pinching then scales around the midpoint, the scale is clamped like the zoom buttons, and moving both fingers together pans. Each change emits viewport-change. One-finger background pan, node drag, connecting and box selection work as with a single pointer, and plain wheel scrolling passes through to the page (Ctrl + wheel zooms). Lifting one finger ends the pinch; the remaining finger does nothing until it is lifted.

Nested groups are opt-in. Give a group parentId to place it in another group. nodeIds lists only the direct members, and a group that has child groups may have an empty nodeIds. A node can still belong to one group directly. Parents are painted first, in input order among siblings. The parent bounds enclose the child bounds, its label strip and a margin, and nested bounds can extend past the layout padding, so leave extra options.padding for deep nesting. Dragging a parent label (or using arrow keys on it) moves every descendant member as one node-move or nodes-move proposal. Dragging a child moves only its own members. A nested group is announced as "Move group Inner within Outer"; the within word is the optional GraphLabels.groupWithin label. The component throws Error for an invalid or duplicate ID, an unknown parentId, a parent cycle, an unknown or repeated member, or a group with no members after expansion, with the texts of collapseGraphGroups (see Validation and errors); a group with no members is Invalid graph group: <id>. Groups without parentId are top-level groups.

The dimming hooks are presentation only. Dimmed nodes and the edges that touch them receive the vw-dimmed class and reduced opacity (--vw-dimmed-opacity, default 0.28). Selection, events and keyboard behavior do not change. The node and edge slots receive dimmed. Compute matches in your application; the component never filters data.

highlightedNodeIds and highlightedEdgeIds are for showing what another view selected or hovers (see Linked views). They are independent of the other sets:

InputMeaningDelete, move, copyEdgesKept rendered when culled
selectedId / selectedIdsSelection owned by this graphYesNot restyledYes
relatedIdsRelated nodesNoAn edge whose two ends are related (vw-is-related)No
matchIds / dimmedIdsDimmingNoAn edge with a dimmed end is dimmedNo
highlightedNodeIds / highlightedEdgeIdsDisplay-only highlightNoOnly the edges listed in highlightedEdgeIdsNo; use revealNode to bring one into view

The classes combine: a highlighted node can also be selected, related or dimmed, and dimming still lowers its opacity. Changing the highlight sets never cancels a drag, connection or pan. Unknown IDs are ignored. With collapsed groups, a highlighted hidden node highlights its proxy, a merged edge is highlighted when any of its original edges is, and an edge dropped inside a collapsed group highlights that group's proxy, as resolveCollapsedTargets resolves them. Slots do not receive a highlight prop; style custom content through the vw-is-highlighted class of the node or edge group. exportSvg and exportPng draw the highlight unless includeHighlight is false.

Related exported types: NetworkFocusOptions.

Edge selection, deletion, context menu, tooltips and fit to selection ​

APIBehavior
edgesSelectableboolean / false. Gives every edge the focusable hit area that reconnectable uses (role button, named "Select edge" plus the edge label or ID). Click, Enter or Space selects the edge; Ctrl, Meta or Shift toggles it in or out of the selection. When reconnectable is also set, the selected edge shows its reconnect handles.
selectedEdgeIds / update:selectedEdgeIdsReadonlySet<string> / undefined. Controlled edge selection; supports v-model:selected-edge-ids. Without it the component keeps the last selected edge itself and still emits update:selectedEdgeIds. Unknown IDs are ignored.
edge-select(id)Emitted for every edge activation, including a toggle that removes it.
deletableboolean / false. Delete or Backspace on the focused stage, node, edge or group label proposes a deletion. A focused node or edge that is not selected is deleted alone; otherwise the current selection is: selectedIds (or selectedId) plus the edge selection.
NetworkNode.deletablefalse keeps the node out of every deletion proposal, like draggable false. Its edges are only deleted when they are selected or focused themselves.
validateDelete(deletion)Synchronous callback. true or undefined accepts, false rejects with labels.deleteRejected, a string rejects with that reason.
delete(deletion)GraphDeletion with nodeIds and edgeIds in input order, without duplicates. edgeIds also lists every edge incident to a deleted node. Apply it with removeGraphElements.
delete-rejected(deletion, reason)Reports a rejected proposal. The reason is announced in the polite live region.
contextMenuboolean / false. A contextmenu event over a node, edge, group label or the empty stage is cancelled and reported as context-menu(GraphContextMenu). The ContextMenu key and Shift+F10 report the focused node, edge, group label or stage at its on-screen centre. The component renders no menu.
tooltip slotOptional HTML content for the hovered or keyboard-focused node or edge. Receives target, either { kind: 'node', node } or { kind: 'edge', edge } (NetworkTooltipSlot).
tooltipDelaynumber / 400. Hover delay in milliseconds before the tooltip appears. Must be finite and nonnegative, otherwise rendering throws RangeError.
unstyledNodeSlotsboolean / false. With a node slot, keeps the stylesheet's fill and stroke rules off the slot content (class vw-is-unstyled on each node group), so the slot's own attributes and classes decide its paint. No effect on the default renderer.
fit(options?)Exposed method. GraphFitOptions has ids (node IDs) and padding (screen pixels, finite and nonnegative, default 0).

Edge selection is opt-in. With edgesSelectable, a plain edge selection also empties a controlled selectedIds set, and a plain node selection or box selection empties the edge selection, so one Delete removes what is shown as selected. Toggling with Ctrl, Meta or Shift keeps the other kind. Selected edges receive the vw-is-selected class on their hit area and their group receives vw-edge-selected; the default edge path is drawn in --vw-edge-selected (default --vw-accent). Culling keeps selected edges rendered, like selected nodes. Without edgesSelectable, the hit area of a reconnectable edge only activates that edge for reconnection; edges are not selected.

A deletion proposal is never emitted during a pointer drag, connection, pan, box selection or pinch, nor while a keyboard connection is armed. Holding the key does not repeat it. Keys pressed in focusable slot content such as an input keep their usual meaning. The parent applies the proposal by replacing nodes and edges, and should also prune positions, groups and selections that mention removed IDs (groups must keep at least one member). When the focused element disappears, focus moves to the stage.

GraphContextMenu has target ({ kind: 'node' | 'edge' | 'group', id } or { kind: 'canvas' }), point (GraphPoint in chart coordinates, the inverse of the camera transform), clientX and clientY (viewport coordinates for a position: fixed menu) and source ('pointer' or 'keyboard'). A right-click on the thin drawn path of an edge reports the edge; with edgesSelectable or reconnectable the wider hit area does too. Requesting a menu cancels an armed connection and hides the tooltip. Render the menu in your application with role menu, move focus into it, close it with Escape and return focus to the element that had it. The browser's follow-up contextmenu event after a handled keyboard request is cancelled and not reported twice. With or without contextMenu, a contextmenu event during a pointer gesture (node, group or resize drag, connection or reconnection drag, box selection, pan or pinch), such as a macOS Control-click, cancels the gesture without a proposal, as Escape does, because the native menu can swallow pointerup. With contextMenu, a menu requested after the gesture had started to move is not reported.

The tooltip is never rendered on the server or before mounting. Hover shows it after tooltipDelay; moving to another element switches it at once. Keyboard focus shows it immediately; focus caused by a pointer press does not. The pointer can move onto the tooltip without hiding it (WCAG 1.4.13), and Escape dismisses it anywhere on the page. A press in the stage, a drag, connection, box selection, pan or pinch hides it. While shown it has role tooltip and an ID from useId, and the described node or edge hit area references it with aria-describedby. It is placed beside the element and follows the camera, after the element or before it in right-to-left graphs, flipping to the side with more room. While the slot is provided, nodes omit their SVG title so the browser does not show a second tooltip; the accessible name is unchanged. Style it through the vw-network-tooltip class.

fit() without options shows the whole graph, like the Fit to view button. fit({ ids }) centres the combined boxes of those nodes at the largest scale that fits inside the viewport minus padding on each side, capped at 1.15 like Fit to view and clamped to the zoom range, then emits viewport-change. Unknown IDs throw Error, invalid padding throws RangeError, and an empty ids list leaves the camera unchanged and emits nothing. fit({ padding }) fits the whole graph with that margin and keeps it when the viewport is resized, until the camera moves or fit() runs again.

Related exported types: GraphContextMenuTarget.

Snap to grid, alignment guides, auto-pan, drops and clipboard ​

APIBehavior
snapGridnumber / undefined. Grid size in chart units; must be positive and finite, otherwise rendering throws RangeError. Pointer drags put the top-left corner of the dragged node on a grid multiple, and arrow keys move it to the next grid line in the arrow direction (four lines with Shift) instead of 10 or 40 units. Drop and paste points are rounded to the grid.
background'none' | 'dots' | 'lines' / 'none'. Draws a decorative SVG pattern (dots or grid lines) behind the graph that follows pan and zoom. Any other value throws RangeError while rendering. 'none' keeps the stylesheet's fixed dotted backdrop.
backgroundGapnumber / snapGrid, else 20. Pattern spacing in chart units; positive and finite, otherwise RangeError.
alignmentGuidesboolean / false. During a pointer drag, snaps the moving box to the left, centre or right and top, middle or bottom of other nodes, and draws the guides.
guideThresholdnumber / 6. Snap distance of the guides in screen pixels; finite and nonnegative, otherwise RangeError.
autoPanboolean / false. Pans the camera while a node or group drag, a connection or reconnection drag, or a box selection is held within 40 screen pixels of the stage edge.
droppableboolean / false. Accepts HTML drag and drop on the stage and emits node-drop(GraphDrop).
clipboardboolean / false. Ctrl or Cmd with C, V and D emit copy-selection, paste-request and duplicate-selection. The names avoid the native copy, paste and drop events, so listeners such as @copy or @drop on the component still fall through to its root element.
node-drop(event)GraphDrop has point (chart coordinates, rounded to snapGrid when set), clientX, clientY and dataTransfer. The type is exported from the Vue entry only because it refers to the DOM DataTransfer.
copy-selection(selection) / duplicate-selection(selection)GraphClipboardSelection has nodeIds and edgeIds in input order and positions, a Map of the current top-left corner of each listed node.
paste-request(event)GraphPaste has point: the pointer position while the pointer is over the stage, otherwise the centre of the viewport, rounded to snapGrid when set.
toGraphPoint(clientX, clientY)Exposed method. The chart point under a viewport position, using the current camera and the stage position on the page. Throws Error before mount and RangeError for non-finite coordinates.
getViewportCenter()Exposed method. The chart point at the centre of the stage. Before mount it uses the 1150 x 270 default viewport.
setViewportCenter(center, scale?)Exposed method. Centers the camera on a chart point at scale (default: the current scale; the range of setViewport). With getViewportCenter() and getViewport().scale it saves and restores a camera independently of the container size, unlike the container-pixel translation of setViewport. After replacing nodes, call it after nextTick, because a replaced graph re-fits. Called before the stage is measured, the centre is applied again to the measured size unless the camera moved in between. Throws RangeError for a non-finite centre or a bad scale; emits viewport-change.

Every new input is opt-in; without them the markup, events and keyboard behavior are unchanged.

Snapping moves a reference point: the top-left corner of the dragged or focused node, or of the bounding box of the moved nodes when a group label is dragged or focused. The other moved nodes keep their offsets from it, so the multiple selection and group members move rigidly; nodes that started off the grid stay off it relative to the reference. No node moves to a negative coordinate: a move that would cross the origin stops at the first grid line that keeps every moved node at zero or above. Emitted node-move and nodes-move proposals carry the snapped positions. A keyboard move only snaps the axis of its arrow key.

Alignment guides compare the dragged node's box, or the bounding box of every moved node when several move, with the boxes of the nodes that do not move. On each axis the closest anchor within guideThreshold screen pixels wins, ties being broken in the layout's box order; on that axis the guide wins over snapGrid. Guides for the final position, including positions the grid or the origin clamp happen to align, are drawn as lines with the class vw-guide inside an aria-hidden group (vw-guides) and in the colour --vw-guide; they disappear when the drag ends or is cancelled. With cullOffscreen only rendered nodes, those within the viewport and cullOverscan, are compared. Keyboard moves draw no guides. The same calculation is available as graphAlignmentGuides in the core entry.

Auto-pan uses requestAnimationFrame. The speed grows from 0 at 40 pixels from the edge to 20 pixels per frame at or beyond the edge, independently on each axis, and only after the gesture has moved (past the 4-pixel drag threshold, or once a connection or box preview exists). The preview stays under the pointer, the camera change emits viewport-change, and panning stops when the pointer is released, the gesture is cancelled (Escape, data change, a second touch) or the component unmounts. It never runs during a pinch. Towards the left and top it stops 40 pixels beyond the chart origin, or the content when that is further out; towards the right and bottom it continues while the pointer is held, so a node can be dragged into new space. Culling keeps the dragged nodes, their edges and the connection source rendered while the camera moves.

With droppable, dragenter, dragover and drop events on the stage call preventDefault, so the browser allows the drop; without it they keep their default handling. The component does not read dataTransfer; the application decides what the drop means and applies it, for example by adding a node at point and committing it to its history. HTML drag and drop needs a pointer, so give keyboard users an equivalent control: a button that adds the same item at getViewportCenter() (the demo palette chips do both). toGraphPoint also converts other screen positions, for example from a custom pointer interaction.

With clipboard, Ctrl+C (Cmd+C), Ctrl+V and Ctrl+D on the stage or one of its nodes, edges, group labels or handles emit proposals; keys pressed in focusable slot content such as an input keep their usual meaning, Alt or Shift with the key is ignored, and held keys do not repeat. Like deletion, a focused node or edge outside the selection is copied or duplicated alone; otherwise the selection is: selectedIds (or selectedId) plus the edge selection, and every edge between two listed nodes is added. Nothing is emitted, and the browser default is kept, when that is empty. paste-request is always emitted. Nothing is proposed during a pointer drag, connection, pan, box selection or pinch, nor while a keyboard connection is armed. The component keeps no clipboard: store what copy-selection reports, then build the copies with cloneGraphElements and commit them as one history entry. Ctrl+D is also the browser's bookmark shortcut; it is only cancelled when duplicate-selection is emitted.

The background pattern is a pattern element with an ID from useId, inside an aria-hidden group drawn behind the groups, edges and nodes; its rectangle ignores pointer events. Cells are backgroundGap chart units apart; when that is less than 8 screen pixels, every second (fourth, and so on) line is drawn. The dots and lines keep a 1-pixel size at every zoom level and use --vw-background-pattern (default --vw-grid). With a pattern, the root also receives vw-network-patterned, which replaces the fixed dotted backdrop with the plain --vw-surface-muted surface. The pattern is part of the server markup.

Related exported types: GraphCloneOptions.

Group collapse, edge styles and waypoints, level of detail and node resizing ​

APIBehavior
collapsibleGroupsboolean / false. Draws a toggle button at the end of every group label strip (named "Collapse group" plus the group label, aria-expanded true) and on every proxy node ("Expand group" plus the label, aria-expanded false). The proxy toggle sits in the bottom corner at the text end, so it never covers the connection handle in the top corner; a proxy lower than 40 units gets it in the top corner opposite the handle. Click, Enter or Space toggles. Without collapsedGroupIds the component keeps the collapsed set itself.
collapsedGroupIds / update:collapsedGroupIdsReadonlySet<string> / undefined. Controlled collapsed groups; supports v-model:collapsed-group-ids. It applies even without collapsibleGroups (then no toggles are drawn). IDs of groups that are not in groups are ignored. update:collapsedGroupIds is emitted with a new Set for every toggle.
edgeStyle'curve' | 'orthogonal' | 'straight' / 'curve'. curve keeps today's routes. orthogonal draws right-angle routes with 6-unit rounded corners, straight draws straight lines clipped to the box borders (or to the outline of a diamond, ellipse or hexagon node). An edge's own GraphEdge.edgeStyle overrides it for that edge. Any other value throws RangeError while rendering.
GraphEdge.pointsOptional waypoints in chart coordinates. The edge is drawn through them in every style: a polyline in straight and orthogonal, a smooth curve through the points in curve.
avoidNodesboolean | GraphObstacleAvoidance / false. Opt-in: orthogonal edges (the edgeStyle prop or an edge's own edgeStyle) without points are routed around every node box, collapsed-group proxies included, keeping clearance chart units away (default 8) and leaving and entering on the same sides as without the option. true uses the defaults; an object sets clearance and bendPenalty (default 24, the extra cost of a bend in units of length). Waypoints keep their precedence, self-loops keep their bracket, and a long-edge bypass lane is kept while it crosses no other box. An edge without a route around the boxes (an end boxed in) keeps the plain orthogonal route. Drag and resize previews reroute the edges of the changed nodes this way, and also the orthogonal edges without waypoints whose saved route meets the clearance area of a changed box at its old or new place, so a route moves out of the way of a box dragged across it during the drag. When more than 32 such edges meet the changed boxes in one preview frame, that frame reroutes none of them and they follow once the new position is in positions; routes that only detoured around the old place without touching its clearance area also straighten then. Edges with waypoints are never rerouted. exportSvg and exportPng draw the same routes. Curve and straight edges are not affected. A negative or non-finite clearance or bend penalty, or a value of another type, throws RangeError while rendering. An object is compared by value, so an inline literal such as :avoid-nodes="{ clearance: 12 }" does not route the edges again or cancel a gesture each time the parent renders. See findOrthogonalRoute for the algorithm and its cost.
edgeLabelPlacement'midpoint' | 'avoid' | options / 'midpoint'. Opt-in: avoid places the edge labels with placeGraphEdgeLabels after all routing (avoidNodes included), away from node boxes (collapsed-group proxies included), from each other and from other edges where there is space, and an object (GraphEdgeLabelPlacement: the GraphEdgeLabelPlacementOptions without edgeIds and labelText) does so with its options, such as fontSize when a stylesheet changes the 11-unit .vw-edge-label size, or labelSize with measured sizes. The component draws edge.label; edges drawn by an edge slot get the placed anchor only through the layout. midpoint keeps the anchors of the layout and routing. With edgeBands, the band widths are the placement's edgeWidth (other edges keep the option's own edgeWidth), so a band's label keeps its gap from the outer side of the band and other labels stay off it. A drag or resize preview places again only the labels of the edges whose route it changes and the labels whose estimated box lies within 80 units of a changed node, against the edges and nodes around them; edges it reroutes along an unchanged path keep their saved anchors. The whole set is placed again once the change is saved, so labels away from the change can still move then. exportSvg and exportPng draw the placed labels. Another value, or an invalid option, throws RangeError while rendering.
routingPolicy'builtin' | 'preserve' / 'builtin'. builtin is the routing described here: edges with named ports are redrawn from their port anchors, and orthogonal and straight redraw every edge. preserve keeps every path the layout drew, in every edge style and also for edges with named ports, while both ends still fit their boxes and ports (isGraphRouteValid); only edges with points, edges of moved or resized nodes, edges whose port or route metadata no longer fits and temporary routes are routed as above. With preserve, an edge the layout has no path for (such as an edge just connected while an external layout is recomputed) gets a temporary built-in route (completeGraphLayout) instead of the Missing layout path error. When preserve and edgeStyle disagree, preserve wins: a kept path is not restyled. Only paths the layout itself drew are kept: a path that the core routing functions drew (the output of routeGraphPorts or routeGraphEdges, a rerouted edge of a moved or resized node, a temporary route) counts as built-in and is drawn again by the built-in router. Any other value throws RangeError while rendering.
editableEdgesboolean / false. Gives every edge its focusable hit area (like edgesSelectable) and shows waypoint handles on the selected edge (the edge whose reconnect handles would show): a "Move waypoint N · edge" button per waypoint and an "Add waypoint N · edge" button in the middle of every segment between the edge ends and the waypoints.
edge-reshape(change)GraphEdgeReshape with id, before and after: the edge's whole waypoint list before and after. Set the edge's points to after (remove the field when it is empty).
validateEdgeReshape / edge-reshape-rejected(change, reason)Synchronous check; false rejects with labels.reshapeRejected, a string rejects with that reason, announced in the live region.
lodThresholdnumber / undefined. Level of detail: while the camera scale is below it, the root gets vw-lod-low and the default renderer hides node detail text and edge labels. Must be greater than 0 and at most 3, otherwise rendering throws RangeError. Accessible names are unchanged.
node and edge slot scaleThe node slot ({node, box, selected, dimmed, related, highlighted, scale}) and the edge slot ({edge, path, selected, related, highlighted, dimmed, scale}) receive the current camera scale for custom level-of-detail rendering.
sizesReadonlyMap<string, GraphNodeSize> / undefined. Width and height per node ID, applied on top of the layout boxes after positions, keeping each box's top-left corner; incident edges are rerouted. Sizes must be finite and positive (RangeError); unknown IDs are ignored.
resizableboolean / false. Shows four corner handles on the node when exactly one node is selected (selectedId, or a selectedIds set of one), named "Resize" plus the node label and the corner ("Resize Split · bottom right"). NetworkNode.resizable false opts a node out; proxies of collapsed groups are not resizable.
minNodeSizeGraphNodeSize / { width: 40, height: 24 }. Smallest size a resize proposes; finite and positive, otherwise RangeError.
node-resize(change)GraphNodeResize with id, before and after boxes ({ x, y, width, height }). Store after.width and after.height in sizes and, when after.x or after.y changed (a left or top corner), after.x and after.y in positions.
validateNodeResize / node-resize-rejected(change, reason)Synchronous check; false rejects with labels.resizeRejected, a string with that reason.

Every input is opt-in. Without them, and with edgeStyle 'curve', no waypoints, no sizes and no collapsed groups, none of their markup is rendered, and routes, events and accessible names are not affected by them. The toggles and handles are drawn in one vw-network-overlay group above the nodes, which then also holds the connection preview and alignment guides.

Collapsing uses collapseGraphGroups before layout, so the layout, culling, the minimap, Fit to view, fit, focusNode and exportSvg all see the collapsed graph. Each outermost collapsed group becomes one proxy node whose ID is the group ID, with the group label, the detail "N nodes" (labels.collapsedNode and labels.collapsedNodes), the rounded shape and data { collapsedGroup, nodeIds }. Members are hidden; their edges are re-attached to the proxy, edges inside the group are dropped, and parallel re-attached edges merge into one edge that keeps the ID of the first original edge. Group IDs must therefore differ from node IDs. A collapsed child group becomes a member of its expanded parent. Hidden nodes cannot be focused, fitted or selected; fit and focusNode throw Error for their IDs, so map them to the proxy (the group ID). revealNode resolves { status: 'hidden-by-collapse', proxyId } for them instead; to show the node itself, expand its groups through a controlled collapsedGroupIds and call revealNode again after the render, or let revealLinkedTarget do both (see Linked views). Toggling moves keyboard focus to the replacement toggle.

Proposals that involve a proxy refer to the real data where they can:

  • Moving a proxy (drag, arrow keys, a group label or a multiple selection that contains it) emits node-move or nodes-move for its movable members. They keep their offsets, and the top-left corner of their boxes in the expanded graph lands on the proxy's new position. A proxy is placed by the layout until one of its members has a saved position; from then on it sits at the top-left corner of its members.
  • Deleting a proxy proposes its members; deleting a merged edge proposes all of its original edges. The GraphDeletion contains real IDs only.
  • select, update:selectedId, update:selectedIds, box selection and connect proposals use the proxy ID. Reject connections to a proxy in validateConnection or map them to a member. Re-attached edges show no reconnect or waypoint handles, and proxies and hidden nodes are left out of copy-selection and duplicate-selection.

The orthogonal router leaves the source and enters the target on the sides that face each other along the layout direction (right and left for LR, left and right for RL, bottom and top for TB, top and bottom for BT), turning halfway between them. Boxes that overlap along that axis, such as nodes of the same rank, are joined by a bracket on the direction's outgoing side, and self-loops are brackets on that side. Named ports keep their anchors: the route leaves and enters perpendicular to the port side. A long-edge bypass lane drawn by layoutLayeredGraph is kept while both of its boxes are where the layout placed them. Moved and resized nodes are routed again. The straight style clips the line between the box centres, or towards the next waypoint, to the box borders. The orthogonal and straight styles also reroute the edges of a custom layout, unless routingPolicy is 'preserve'. Labels sit just above the middle of each route unless edgeLabelPlacement places them. Known limits: without avoidNodes, routes do not avoid other nodes, so orthogonal routes between distant or overlapping nodes and straight lines may cross boxes; with avoidNodes, orthogonal routes go around boxes but different edges may still share segments or cross each other, and curve and straight edges still ignore boxes. Waypoints are absolute chart coordinates that do not follow moved nodes.

Waypoint and resize handles are focusable buttons. On a waypoint handle the arrow keys move it by 10 chart units (40 with Shift), or to the next snapGrid line (four with Shift); Delete or Backspace removes it and focus returns to the edge. Enter or Space on an add handle inserts a waypoint at that point. A pointer drag of a waypoint, or of an add handle, which inserts a new waypoint there, previews the route and proposes the new list on release; a press without movement on an add handle inserts the waypoint at the handle. On a resize handle the arrow keys move that corner's vertical or horizontal edge by 10 (40 with Shift), or to the next grid line; a pointer drag previews the box with the dragged edges on the grid when snapGrid is set. Resizes keep the opposite corner, minNodeSize and a nonnegative origin. Waypoints are clamped to nonnegative coordinates. Escape, pointer cancellation, a second touch and changes of the source data or layout cancel a drag in flight without a proposal. The new GraphLabels fields collapseGroup, expandGroup, collapsedNode, collapsedNodes, moveWaypoint, addWaypoint, reshapeRejected, resizeNode, topLeft, topRight, bottomLeft, bottomRight and resizeRejected localize the names and announcements.

Related exported types: GraphCollapseOptions.

Node shapes, edge markers, animated and parallel edges ​

APIBehavior
NetworkNode.shapeNetworkNodeShape: 'box' (default) | 'rounded' | 'diamond' | 'ellipse' | 'hexagon'. box and rounded are rectangles (corner radius 8 and 19). diamond, ellipse and hexagon (pointed on the left and right) are drawn inside the node box, 2 units in from its border like the rectangles, as an ellipse or polygon with the class vw-node-shape, and the label and detail are centred (text-anchor="middle", also right-to-left); at the default height of 58 the text keeps its rows, and taller nodes centre it vertically. Text is clipped to the box, not to the shape. The stylesheet paints .vw-node-shape with the same tone, hover, focus, selected, related, highlighted, dimmed, dark-theme and forced-colors rules as the node rectangle. Unknown values draw a box. The minimap, the proxies of collapsed groups (rounded), connection handles, resize handles and the focus ring keep the box.
GraphEdge.edgeStyleGraphEdgeStyle / undefined. The routing style of this edge, overriding the edgeStyle prop and the style option of routeGraphEdges. A curve edge in an orthogonal graph keeps the layout's path; an orthogonal edge in a curve graph gets the component's 6-unit rounded corners. With routingPolicy 'preserve' a valid layout path is kept whatever the edge's style. Drag, resize and waypoint previews route the edge in its own style. An unknown value throws RangeError ("Unknown edge style on graph edge …") while rendering and in routeGraphEdges.
GraphEdge.markerEnd / markerStartGraphEdgeMarker: 'arrow' | 'open-arrow' | 'circle' | 'diamond' | 'bar' | 'none'. markerEnd defaults to 'arrow' (a filled arrowhead), markerStart to 'none'. open-arrow is a line arrowhead, circle and diamond are hollow and filled with the stage background (--vw-surface-muted, class vw-edge-marker-hollow), bar is a line across the edge. A start marker points away from the edge (orient="auto-start-reverse"). Markers take the colour of their edge (context-stroke), so related, selected and highlighted edges colour them too. The default end arrow keeps the marker element in the stage's defs; every other marker and end is written once, in a defs element before the edges, only while an edge uses it, with an ID derived from the default marker's useId ID (for example v-0-open-arrow and v-0-start-circle). The markers belong to the default edge renderer: the edge slot draws its own. An unknown value throws RangeError ("Unknown edge marker on graph edge …") while rendering and in renderGraphSvg.
GraphEdge.animatedboolean / undefined. Adds vw-is-animated to the default edge path: a 6 4 dash pattern that flows from source to target over --vw-edge-animation-duration (default 1s). It stays still, still dashed, under prefers-reduced-motion: reduce and in print.
parallelEdgeSpacingnumber / undefined. Opt-in distance in chart units between parallel edges: edges between the same two nodes, in either direction, that have no points and no named ports. They are spread symmetrically around the line between the box centres, in input order, in every edge style: curve and straight edges are drawn through a point beside the middle of that line (a smooth curve, or a polyline with one bend), and orthogonal edges are the same route shifted sideways, closer together when a leg or a node side is too short. Labels follow their edges. Self-loops of one node are nested, each loop starting and ending further out on the side and reaching further away. A single edge, an edge with points or ports, the long-edge bypass lanes that the orthogonal style keeps (the layered layout gives each long edge a lane of its own) and paths kept by routingPolicy 'preserve' are not changed; an edge that gets waypoints leaves its group and the others are spread again, also in the waypoint drag preview. The bend points are not waypoints: they never appear in edge.points or in edge-reshape proposals, and the add-waypoint handles stay between the drawn ends. Must be positive and finite, otherwise rendering throws RangeError. routeGraphEdges takes the same as parallelSpacing.

Every input is opt-in: without these fields and with the defaults written out (shape 'box', markerEnd 'arrow', markerStart 'none', animated false, an edgeStyle equal to the prop, or parallelEdgeSpacing without parallel edges) the markup, routes, exports and accessible names are the same as without these fields.

Where edges meet shaped nodes: straight edges, and curve or straight edges through waypoints or spread as parallel edges, end where the line from the node centre meets the outline. Orthogonal edges and the layout's own paths attach to the middle of the box sides, which lies on every outline; orthogonal routes through waypoints leave from that middle as well, and the ends of self-loops and of spread orthogonal edges slide along their first leg onto the outline. Named ports, connection handles and edges of moved or resized nodes in the curve style stay on the box sides.

The export (exportSvg, exportPng and renderGraphSvg) draws the same shapes, markers (hollow ones filled with the theme's surfaceMuted, the markers of highlighted edges in the highlight colour) and paths; animated edges are dashed (stroke-dasharray="6 4") without motion.

Label editing, lasso selection and item slots ​

APIBehavior
editableLabelsboolean / false. A double-click on a node or an edge (its hit area or its default label), or F2 on a focused node or edge hit area, opens an in-place text editor over the label. Enter and Space select a node, as they do without editableLabels. It also gives every edge the focusable hit area that edgesSelectable uses (named "Select edge" plus the edge label or ID) and lets the default edge labels receive the double-click (root class vw-labels-editable).
label-edit(change)GraphLabelEdit with kind ('node' or 'edge'), id, before (the current label, empty for an edge without one) and after (the text typed, unchanged and untrimmed). Set the node's or edge's label to accept it. Nothing is emitted when the text is unchanged.
validateLabelEdit / label-edit-rejected(change, reason)Synchronous check; true or undefined accepts, false rejects with labels.labelRejected (default "This label change was rejected."), a string rejects with that reason, announced in the polite live region.
selectionModeGraphSelectionMode / 'box'. With boxSelect, 'lasso' turns the Shift-drag into a free-form outline (a vw-lasso-selection polygon) that selects the nodes whose box centre it encloses (graphNodesInPolygon, even-odd rule, the outline counting as inside). Any other value throws RangeError while rendering.
node-toolbar slotHTML in a group (role group, named labels.nodeToolbar plus the node label, default "Node actions Split") anchored above the only selected node: selectedId, or a selectedIds set of one. Receives NetworkNodeToolbarSlot { node, box, scale }.
edge-toolbar slotHTML in a group named labels.edgeToolbar plus the edge label or ID (default "Edge actions 72") anchored above the selected edge's label point, or the middle between its path ends. Receives NetworkEdgeToolbarSlot { edge, point, scale }. The edge is the only member of selectedEdgeIds with edgesSelectable, otherwise the edge last activated through the hit area of reconnectable, editableEdges or editableLabels.
group slotSVG that replaces a group's frame and label, in chart coordinates (not translated). Receives NetworkGroupSlot { group, box, depth }, where box is the frame including the label strip.
minimap-node slotSVG that replaces a node's rectangle in the minimap, in chart coordinates. Receives NetworkMinimapNodeSlot { node, box, selected }.

Every input is opt-in. Without editableLabels, with selectionMode 'box' and without the four slots, none of their markup is rendered, and keys, events and accessible names are not affected by them.

Label editor. The editor is an HTML input (class vw-label-editor, dir="auto") after the stage, never rendered on the server or before a user opens it. Its accessible name is labels.editLabel plus the current label, for example "Edit label of Split" or, for an edge without a label, "Edit label of" plus its ID. It covers the node's box at its vertical middle, starting at the text start edge (the right edge in right-to-left graphs), at least 120 pixels wide so it stays usable when zoomed out; an edge's editor (vw-is-edge, --vw-label-editor-width, default 140px) is centred on the label point. It follows pan and zoom while open, keeps a fixed 13px text size, and the edited node or edge stays rendered with cullOffscreen. Enter proposes the text and Escape discards it; both return keyboard focus to the node or edge hit area. Leaving the editor (blur, for example a click elsewhere or Tab) also proposes the text, like the GanttChart cell editor. Composition (IME) keys are left to the input. A rejected proposal closes the editor and keeps the label. A change of nodes, edges, positions, sizes or the layout while the editor is open, or turning editableLabels off, closes it without a proposal, and focus returns to the item when the editor had it. The component never changes a label itself. A collapsed group's proxy and an edge merged from several edges have no editor. No editor opens during a pointer gesture or an armed connection.

Lasso. The outline is sampled every 3 screen pixels in chart coordinates and closed at the release point. It starts after the 4-pixel drag threshold, follows auto-pan, and reports the same events as a box selection: update:selectedIds with the enclosed nodes (added to the previous selection with Ctrl or Meta) and an empty update:selectedEdgeIds with edgesSelectable; gesture-start and gesture-end report it with kind 'box-select'. Escape, pointer cancellation, a second touch, a context menu or a source change discards it without a selection, and changing selectionMode cancels a drag in flight. Partial overlap does not count: a node is selected only when its centre is inside.

Toolbars. The toolbars are HTML after the stage, placed in screen pixels (classes vw-node-toolbar and vw-edge-toolbar), so their text keeps its size at every zoom level. They are centred above the item, --vw-toolbar-offset (default 8px) away, and placed below it (vw-is-below) when the item is within 44 pixels of the stage top. They follow pan, zoom and drag previews, and disappear while the item is outside the stage. They render on the server for the selection in the initial fit, like the rest of the graph. Use buttons and other controls inside them; they are in the tab order after the stage.

Group and minimap slots. With the group slot, the group element gets vw-has-slot, the stylesheet's frame and label paint no longer applies to the slot content, and a transparent strip over the top 20 units of the frame (class vw-group-handle) takes over the label's role: it carries data-vw-group and, with draggable, the "Move group" button name, drag, arrow keys and activation. Slot content should not take pointer events where the handle should receive them. The minimap-node slot content is drawn inside a vw-minimap-custom group (with vw-is-selected for selected nodes) inside the minimap button, so it must not be interactive; clicks and keys still navigate the minimap.

Slot content (toolbars, group frames, minimap nodes, like the node, edge and tooltip slots) is not part of exportSvg or exportPng, which draw the default rendering. The GraphLabels fields editLabel, labelRejected, nodeToolbar and edgeToolbar localize the names and announcements.

Swimlanes ​

APIBehavior
lanesreadonly GraphSwimlaneBand[] / undefined. Opt-in. Each lane { id, label, x, y, width, height, header } is drawn behind the groups, edges and nodes: a band (class vw-swimlane-band, every second lane also vw-is-alternate on its vw-swimlane element), a header rectangle (vw-swimlane-header) and the label clipped to the header area (a nested svg with overflow="hidden", class vw-swimlane-title). Each lane is an SVG group (role group) whose accessible name is its label and which carries data-vw-lane. Bands and titles never take the pointer, so panning, box selection, drops and node drags work over them. The bands are part of the fitted content, the minimap (vw-minimap-lane outlines) and exportSvg and exportPng. An ID that is not a non-empty string (Invalid swimlane ID: <value>) or a repeated ID (Duplicate swimlane ID: <id>) or a label that is not a string throws Error, and a band or header that is not finite or has a negative size throws RangeError while rendering. A header with a zero width or height draws no header and no title.

Without lanes (or with an empty list) no lane markup is rendered, and keys, events and accessible names are not affected.

The usual source is layoutSwimlaneGraph, whose result is both a GraphLayout for the layout prop and the lane geometry for lanes. Compute it once and pass a stable function that reads it, so the graph lays out again whenever the result changes, and pass the same direction in options so edge routing and handles use the flow's sides:

ts
const swimlanes = computed(() => layoutSwimlaneGraph(nodes.value, edges.value, {
  lanes: [{ id: 'buy', label: 'Purchasing' }, { id: 'make', label: 'Machining' }, { id: 'check', label: 'Inspection' }],
  laneOf: node => node.data.lane,
  direction: direction.value,
}))
const layout: GraphLayoutFunction = () => swimlanes.value
vue
<NetworkGraph :nodes="nodes" :edges="edges" :layout="layout" :lanes="swimlanes.lanes" :options="{ direction }" draggable @node-move="moveStep" />

Lane changes are the application's decision. The component never moves a node to another lane, never blocks a drag out of one and never clips nodes to their band. A drag still proposes node-move with the new top-left corner; graphSwimlaneAt(lanes, { ...change.after, width, height }) returns the lane holding the moved box's centre, or undefined when it is in a gap or outside every band, so the parent can turn the proposal into a lane reassignment (change the node's lane and lay out again), keep the position inside the lane, or refuse it:

ts
function moveStep(change: GraphNodeMove) {
  const box = swimlanes.value.boxes.get(change.id)!
  const lane = graphSwimlaneAt(swimlanes.value.lanes, { ...change.after, width: box.width, height: box.height })
  if (!lane) return // outside every lane: refuse, or keep the position and flag the node
  nodes.value = nodes.value.map(node => node.id === change.id ? { ...node, data: { ...node.data, lane: lane.id } } : node)
}

Bands do not follow saved positions: a node placed through positions outside its band stays drawn where it is, and graphSwimlaneAt on its box tells the application. Lanes and groups are independent; a group frame is drawn above the bands. With dir="rtl" the lane titles are right-aligned in their header with direction: rtl; like the rest of the graph geometry, the bands and headers are not mirrored (use direction: 'RL' in the layout for a flow from right to left, which also puts the headers on the right).

BPMN and flowchart shapes, markers and pools ​

Opt-in additions for BPMN processes and classic flowcharts. Without them the server markup, routes, exports and accessible names are unchanged.

APIBehavior
NetworkNode.shape (flowchart shapes)NetworkFlowchartShape, part of NetworkNodeShape: 'circle' (a true circle centred in the box with the radius of the shorter half side, a BPMN event), 'stadium' (a terminator: a rectangle with half-circle ends), 'parallelogram' (input or output; the sides slant by min(0.36 × height, width / 4)), 'document' (a wavy bottom that dips at the inline start and rises at the end, within the box), 'cylinder' (a data store or database, with the front rim of its top drawn as a separate line) and 'data-object' (a page with a folded top-right corner, also drawn as a separate line). Like diamond, ellipse and hexagon they are drawn 2 units inside the node box (an ellipse, polygon or path with the class vw-node-shape; the rim and the fold are a path with the class vw-node-shape-detail), the text is centred (a cylinder moves it down by half its rim) and clipped to the box, and the minimap, connection handles, resize handles and the focus ring keep the box. Unknown values still draw a box.
NetworkNode.eventNetworkNodeEvent: 'start' (the normal thin border), 'intermediate' (a second outline 4 units inside the first, class vw-node-shape-inner or, for the rectangle shapes, a rect) or 'end' (a 3.5-unit border, class vw-node-event-end). The outline gets the class vw-node-event-<event>. Meant for circle, it works on every shape. Unknown values are ignored.
NetworkNode.markerNetworkNodeMarker, a decorative BPMN symbol in the node ink (a g with the class vw-node-marker, aria-hidden="true" and data-vw-marker): the gateway symbols 'exclusive' (×), 'parallel' (+), 'inclusive' (a thick circle) and 'event-based' (a pentagon in a double circle) and the event symbols 'message' (an envelope) and 'timer' (a clock), centred and sized to the shorter side of the box; and the task types 'user', 'service' and 'manual', a 16-unit icon in the top inline-start corner (top right with dir="rtl", the manual hand mirrored). With a task icon, the text of a rectangle starts 30 units from the inline-start edge instead of 13. Centred symbols do not move the text, so give events and gateways labelPosition: 'below'. Unknown values draw nothing.
NetworkNode.labelPositionNetworkNodeLabelPosition: 'inside' (default) or 'below'. Below draws the label and detail centred under the box (baselines 17 and 32 units below its bottom), outside the clipped node content (class vw-node-label-below), in --vw-text with a halo in --vw-surface-muted, also when the node is selected. The text is not clipped and not part of the layout box, so leave room for it (rowGap, lanePadding); renderGraphSvg widens its bounds for it.
GraphEdge.dashedDraws the default edge with a static dash pattern (class vw-is-dashed, stroke-dasharray: 5 4; 5 4 in renderGraphSvg), for BPMN message flows and data associations. animated wins when both are set. collapseGraphGroups keeps it on a merged edge only when every merged edge agrees.
GraphEdgeMarker 'hollow-arrow'A triangle filled with the graph background (class vw-edge-marker-hollow, surfaceMuted in exports), the end of a BPMN message flow. A message flow is { dashed: true, markerStart: 'circle', markerEnd: 'hollow-arrow' }; a data association { dashed: true, markerEnd: 'open-arrow' }.
poolsreadonly GraphSwimlanePoolBand[] / undefined. Opt-in. Pools (BPMN participants), usually the pools of a layoutSwimlaneGraph result, drawn in the lanes layer: each pool is an SVG group (role group, class vw-swimlane-pool, data-vw-pool) named by its label, with a frame (vw-swimlane-pool-band), a title band (vw-swimlane-pool-header) and the title centred in the band and clipped to it (vw-swimlane-pool-title), rotated by −90° to read from bottom to top when the band is taller than it is wide. The lanes whose IDs a pool lists in laneIds are drawn inside its group, after its frame; other lanes follow the pools. Pools are part of the fitted content, exportSvg and exportPng, and never take the pointer. An invalid or repeated ID (Invalid swimlane pool ID: <value>, Duplicate swimlane pool ID: <id>), a label that is not a string or laneIds that are not an array of IDs throw Error, and geometry that is not finite or has a negative size throws RangeError while rendering. A title band of zero size draws no band and no title.

Where edges meet flowchart shapes: straight edges, and curve or straight edges through waypoints or spread as parallel edges, end where the line from the node centre meets the outline (curves are followed to within about 0.1 units). Unlike diamond, ellipse and hexagon, a flowchart shape need not touch the middle of every box side (a circle in a wide box, the slanted sides of a parallelogram, the wave of a document), so the ends of orthogonal routes that are not at a named port slide along their first (or last) leg onto the outline. The layout's own curve paths, and the long-edge bypass lanes the orthogonal style keeps, still end on the box sides: give circles and diamonds square boxes (a custom layout that shrinks their boxes, sizes, or square nodeWidth and nodeHeight) or use the orthogonal or straight edge style. Named ports and connection handles stay on the box sides.

layoutSwimlaneGraph takes the opt-in pools (GraphSwimlanePoolSpec[]: { id, label?, lanes }), poolHeaderSize (default 32) and poolGap (default 24, in place of laneGap between lanes of different pools) options and then returns pools (GraphSwimlanePool[], in display order: { id, label, index, laneIds, x, y, width, height, header }). Every lane must belong to exactly one pool and the lanes of a pool must be consecutive in lanes (in any order in the pool); otherwise it throws Error (Unknown swimlane in swimlane pool <id>: <lane>, Swimlane <lane> is in more than one pool, The lanes of swimlane pool <id> must be consecutive, Swimlane <lane> is in no pool, Swimlane pool needs at least one lane: <id>, and the ID texts with the kind swimlane pool); a poolHeaderSize or poolGap that is not finite and nonnegative throws RangeError. Each pool's title band sits at the flow start before the lane headers, so every lane band starts poolHeaderSize later and the nodes poolHeaderSize further along the flow; the lane of a pool with a single lane gets a zero-size header, as a BPMN pool without lanes. TB and BT turn the pools with the lanes (the title band on top or at the bottom, read without rotation). Without pools the result is unchanged and has no pools field.

ts
const swimlanes = computed(() => layoutSwimlaneGraph(nodes.value, edges.value, {
  lanes: [{ id: 'customer', label: 'Customer' }, { id: 'sales', label: 'Sales' }, { id: 'warehouse', label: 'Warehouse' }],
  pools: [{ id: 'buyer', label: 'Customer', lanes: ['customer'] }, { id: 'supplier', label: 'Supplier', lanes: ['sales', 'warehouse'] }],
  laneOf: node => node.data.lane,
}))
vue
<NetworkGraph :nodes="nodes" :edges="edges" :layout="() => swimlanes" :lanes="swimlanes.lanes" :pools="swimlanes.pools" edge-style="orthogonal" />

renderGraphSvg takes the same pools (drawn before the lanes: a g class="vw-swimlane-pool" with a title, a surface frame and a surfaceMuted title band with 1.5-unit muted borders and the 13-unit bold title, validated like the prop) and draws flowchart shapes (stroke-linejoin="round" on paths and polygons, the rim and fold as unfilled lines at most 1.5 units wide), event borders (an end border at least 3.5 units, an intermediate second outline), markers (a g with fill="none" and the stroke in the tone's ink, or onSolid when selected), labels below (outside the node's nested svg, in text with a surfaceMuted halo) and dashed edges like NetworkGraph draws them; exportSvg and exportPng follow.

Accessibility: the accessible name of a node stays its label and detail; shapes, event borders and markers are decorative and are not announced. Put the BPMN meaning that matters into the label or the detail (for example "Order received" with the detail "message start event"), or describe it in your own tooltip.

Quantity bands ​

APIBehavior
edgeBandsReadonlyMap<string, GraphEdgeBand> / undefined. Opt-in. Draws each listed edge as a band with real width: GraphEdgeBand is { width, reference?, label? }, usually built by graphFlowBands from a layoutFlowGraph result. The default edge path gets the classes vw-network-edge and vw-network-band (plus vw-is-reference for a reference band, drawn dashed), an inline stroke-width of width chart units, and no markers or animation. The hit area (with edgesSelectable, editableEdges, editableLabels or reconnectable) gets vw-is-band and a stroke width of width, never below the usual 14, so the whole band takes the pointer; its accessible name is labels.selectEdge plus label when set (for example "Select edge Cut → Inspect: 60 pcs"), else the edge label or ID. Bands keep the hover (active), selected, related, highlighted and dimmed states of other edges. Edges are drawn widest band first, then the edges without a band, so thin bands stay above thick ones. The edge slot receives the band as band. exportSvg and exportPng draw the same bands (see renderGraphSvg edgeBands). A width that is not a finite number of at least 0 throws RangeError while rendering; unknown IDs are ignored.

Without edgeBands, or with an empty map, no band markup is rendered, and keys, events and accessible names are not affected.

The usual source is layoutFlowGraph: its result is a GraphLayout with a box for every node and a centre-line path for every band. Pass a stable function that reads it as layout, only the edges that have a band, and its bands:

ts
const flow = computed(() => layoutFlowGraph(nodes.value, edges.value, {
  quantity: edge => edge.data.amount, unit: edge => edge.data.unit, displayUnit: unit.value, direction: direction.value,
}))
const layout: GraphLayoutFunction = () => flow.value
const shownEdges = computed(() => edges.value.filter(edge => flow.value.paths.has(edge.id)))
const bands = computed(() => graphFlowBands(flow.value))
vue
<NetworkGraph :nodes="nodes" :edges="shownEdges" :layout="layout" :edge-bands="bands" :options="{ direction }" edges-selectable />

A band is a stroke along the edge path, not a filled outline, so every edge feature that reads the path (hit areas, toolbars, culling, exports) works unchanged. Where a curve turns steeply its stroke looks slightly thinner than at its ends; keep rankGap large compared with the band widths. Saved positions, node drags and edge styles reroute bands like other edges, as curves between box centres, so keep flow pictures non-draggable. The theme variables are --vw-flow-band-opacity (default .5), --vw-flow-band-active-opacity (hover, selected and highlighted, default .78), --vw-flow-reference-opacity (default .35) and --vw-flow-reference-dash (default 10 6, lengthened for wide bands to a dash of twice and a gap of at least three quarters of the band width, with the gaps of a straight-segment loop route evened out so it starts and ends with a dash; the export draws the same); in forced colors bands use CanvasText, reference bands GrayText with the dash, and selected bands Highlight.

Released under the MIT License.