English
Architecture and scope
How the package is divided between the headless core, the components and your application, how layout, routing, rendering and editing work inside, and what is in and out of scope.
The package has three boundaries.
- src/core contains typed graph/interval inputs, validation, graph traversal, layout, time mapping, interval editing, work calendars, scheduling and resource-load analysis. It has no Vue or browser imports.
- src/components owns measurement, SVG/HTML rendering, local camera/scroll state and transient pointer previews. Persistent selection and accepted schedule data belong to the parent.
- examples contains business data and validation. Components do not import examples.
Planning screens around the components (an unplanned-task backlog, an inspector, a diagnostics list, a context toolbar, typed cell editors, save-status and conflict messages) are reference implementations in examples/components/ and the planning demos. They are not part of the package: the library adds only core functions, composables and the props, events, slots and methods of the components that such screens need, and the stylesheet styles only states the components draw themselves (highlights and selected load segments).
Three models
Applications keep three kinds of data apart, and the APIs follow that split.
| Model | Contents | Changes when |
|---|---|---|
| Input | Tasks, dependencies, assignments, calendars, constraints; graph nodes, edges, groups, positions and sizes | An edit is accepted, the server sends an update, a snapshot is restored |
| Computed | Schedules, work intervals, float, load, diagnostics and traces, layouts | A calculation of the current input succeeds |
| Projection | What a view draws: resource rows and their bars (projectResourceTimeline), collapsed proxies, highlights, search and sort results (projectTimelineView, and projectTimelineRows for the rows alone), display frames (useAsyncGraphLayout) | The computed result or the view settings change |
Edits, history (useEditHistory, useEditTransaction) and snapshots (serializeWeaveSnapshot) hold input only. A task shown on two resource rows is still one task; projected bar IDs map back through origins and are never saved as task IDs. Load, traces and layouts are recalculated from the input instead of being stored or undone. A view projection never feeds a calculation: schedules and load come from the full input, not from a filtered or sorted display.
Plan scenarios follow the same split. A candidate plan is a second input (a draft that records the revision it was derived from); comparePlans is computed from both inputs and their computed results, and keeps input differences and result differences in separate parts; the highlights (planComparisonTargets) and the current plan drawn as a baseline set (planBaselines) are projections. Adopting a candidate replaces the input in one history entry. diffStructure is the generic counterpart for other keyed collections, such as two revisions of a bill of materials or a WBS: it compares two resolved inputs and reports field values and parent changes, and computes nothing else.
The ESM root exports Vue components and core functions. The separate core export supports headless use. Vite externalizes Vue. Declaration files preserve props, slots and exposed methods. Consumers load style.css explicitly.
Graph layout
An iterative Kosaraju traversal finds strongly connected components. The condensed graph supplies ranks; nodes in a component occupy the same rank. Input order determines the order within a column. Curves connect adjacent columns, bypass lanes route long edges, and same-rank edges use a side route. TB transposes the geometry while preserving node sizes.
This is a deterministic layout baseline. Dense edge sets and cycles can produce overlapping routes or labels; the opt-in edgeLabelPlacement prop (placeGraphEdgeLabels) moves labels off nodes, other labels and other edges where there is space, but routes are not changed for labels. Because all nodes of a strongly connected component share one rank, a large cycle becomes one long column (one row in TB and BT): a 5,000-node cycle is about 214 by 410,000 units with the default sizes. Callers that expect large cycles can break or filter them first with findGraphCycles, or use layoutForceGraph. By default crossings are not optimized; set crossingReduction to barycenter or median for opt-in sweeps that reorder nodes within each rank (long edges and same-rank edges are not part of the objective). RL and BT mirror the LR and TB geometry. layoutTreeGraph and layoutRadialGraph use a breadth-first spanning forest and route the remaining edges separately. layoutCircularGraph, layoutGridGraph and layoutConcentricGraph place nodes by position alone (input or sort order, rows, or rings by a metric such as the degree) in linear time and draw straight edges, so they do not avoid crossings or boxes. layoutForceGraph runs a seeded, deterministic force simulation (link springs, Barnes–Hut repulsion over an iterative quadtree and gravity), removes box overlaps with grid-based passes and packs connected components in rows. By default all supplied nodes and edges are rendered; applications can use graphNeighborhood to narrow the input, or opt in to viewport culling with cullOffscreen, which renders only the elements that intersect the visible region plus an overscan margin (layout, routing and the minimap still cover every node). With culling, each saved layout reuses the previous one's work: routing goes through a route cache (createGraphRouteCache), which searches again only the routes whose inputs, or with avoidNodes whose obstacle search area, a change touches, and the culling bounds are measured again only for changed paths and labels; the results equal a full recomputation. Pan/zoom transforms one SVG group without rerunning layout. NetworkGraph builds its geometry in one pipeline: collapseGraphGroups (only with collapsed groups), the layout, the positions and sizes overlays, port routing then routeGraphEdges for the edge styles (the prop and each edge's own), waypoints and parallel edges, and finally, with edgeLabelPlacement, placeGraphEdgeLabels. Each step returns its input unchanged when it has nothing to do, so the default output is the layout's own. Previews of node drags, resizes and waypoint drags do not change props. They reuse the saved geometry and recompute only the boxes of the changed nodes and the routes of their edges, with the same results as rerunning the overlays and routing for the whole graph. With avoidNodes they also reroute the unrelated orthogonal routes a changed box gets in the way of, found with a spatial query (see Obstacle avoidance). With edgeLabelPlacement they place again only the labels of the rerouted edges and those near a changed node, against the nodes and the edges whose saved path bounds (computed once per saved layout) lie near them; the full greedy placement runs once the change is saved, so a preview is not always identical to the saved result for labels away from the change. Port routes are clamped to the layout size, so when a preview changes that size the other port edges whose control points reach past the smaller of the two sizes are rerouted too. Group frames are recomputed only for the groups that hold a changed node, the groups whose own nodes reach past the smaller size, and their ancestors. Each node, edge, minimap rectangle, connection handle and group frame is an internal functional component that reads its box, path or frame from a ref of its own, so a preview re-renders only the items of the changed nodes and edges; the item lists render again only when the rendered set, selection, dimming, the connection draft or other item props change. Still proportional to the graph per move: with groups, one pass over the group list (frame list, content bounds and, with culling, the near-view test), which grows with the number of groups but not with their members; with alignmentGuides, the guide search over the other node boxes; with waypoints, edge styles of their own or parallel spacing, a check of the edges routed that way (and, when a waypoint drag takes an edge out of its parallel group, of the edges between the same two nodes); and any camera move during the drag (auto-pan), which culls and redraws as a pan does.
Swimlanes
layoutSwimlaneGraph reuses the layered ranks (the condensation of the strongly connected components) for the position along the flow and puts each node in a cell of its rank and its lane. Lane bands stack in the caller's order and are never reordered; each band is as thick as its largest cell (at least one node, or minLaneSize), so an empty lane keeps its band. Crossing reduction only reorders nodes inside one cell (barycenter sweeps, keeping the best order by adjacent-rank crossings). The layout is computed left to right and turned into the other directions with the same orientation helper as the tree layout, lanes included, so the header always sits at the flow start.
Lanes are a separate, display-only input of NetworkGraph (lanes) rather than groups: a group frame follows its member nodes, cannot be empty and moves its members when dragged, while a lane band has geometry of its own that spans the whole flow, exists without nodes and never moves anything. The bands are one layer below the group frames, part of the fitted content, the minimap and the export, and never take the pointer. The component does not interpret lane membership; graphSwimlaneAt lets the application map a node-move proposal to a lane and apply its own rules. Lane headers are not obstacles for avoidNodes; they lie before the first rank, outside the routes between nodes.
Flowchart shapes and pools
The flowchart and BPMN shapes share one internal geometry module with the earlier outline shapes (graphShapes.ts), used by the default renderer, edge routing and renderGraphSvg, so all three draw and clip the same outline. Straight-line clipping and the orthogonal end correction intersect the outline as a polygon (curves sampled finely, circles exactly), because these shapes need not touch the middle of every box side. Event borders, markers and labels below the box are decoration of the default renderer only: they change neither the box nor the routes, and markers are aria-hidden. Pools are, like lanes, display-only geometry from layoutSwimlaneGraph: the layout adds a title band per pool before the lane headers and a gap between pools, and NetworkGraph draws each pool as a group around its own lanes.
Asynchronous layouts
The layout prop stays synchronous. useAsyncGraphLayout turns the input into the same requests NetworkGraph would make (buildGraphLayoutRequests: a shown request and, with collapsed groups, an expanded one), each identified by a request ID and an input key that covers nodes, edges, ports, sizes, positions, groups, the collapsed set, direction, settings and a caller revision. A display frame holds one input together with its layouts and changes only when every layout of that input is ready, so nodes are never drawn with another input's geometry; late, cancelled and superseded results are dropped. The layout function it returns reads the displayed frame and keeps its identity, so a new frame neither re-fits the camera nor, while NetworkGraph reports a gesture in flight (gesture-start and gesture-end, bound through gestureListeners), cancels it. Nothing is requested during server rendering; an optional synchronous initialLayout gives the server and the first client render the same frame.
Routing precedence
For each edge NetworkGraph decides its path in this order:
- Explicit waypoints (
GraphEdge.points) are routed through by the built-in router, whatever the policy. - Edges of a node moved by
positionsor resized bysizesare rerouted; other edges keep their paths (withavoidNodes, orthogonal edges without waypoints are then routed around the new boxes in step 4, also during a drag preview; see Obstacle avoidance). - With
routingPolicy: 'preserve', a path the layout drew is kept, also for named ports and in the orthogonal and straight styles, while its ends still fit the boxes, ports and route metadata (isGraphRouteValid). Paths drawn by the core routers themselves count as built-in. - Otherwise (the default
'builtin'), edges with named ports are redrawn from their anchors, and the orthogonal and straight styles redraw every edge; the curve style keeps the layout's other paths. - An edge without any path, for example one just connected while an asynchronous layout is pending, gets a temporary built-in route under
'preserve'(completeGraphLayout); under'builtin'it is an error.
Drag previews apply the same rules to the moved nodes only, and the SVG export draws the routed paths, so screen, preview and export agree. By default routing does not avoid obstacles; a layout engine that needs that owns its routes under 'preserve'.
Obstacle avoidance
With the opt-in avoidNodes prop (avoidNodes option of routeGraphEdges), orthogonal edges without waypoints are routed around the node boxes, collapsed-group proxies included, by findOrthogonalRoute. It fits into step 4 above: the ends and their sides are the ones the plain orthogonal route uses (named ports or the sides facing each other along the direction), each end first leaves its node by the clearance, and the router finds the cheapest axis-aligned path between those two points, counting length plus a penalty per bend. Waypoints, self-loops, 'preserve' and the curve and straight styles are unchanged. When no route exists, the edge keeps the plain orthogonal route, so routing never fails because of obstacles.
The router never builds a pixel grid. Boxes grown by the clearance go into a uniform bucket grid once per routing call (O(n)). Candidate lines run halfway between neighbouring box edges, so a route keeps to the middle of each free channel and never squeezes between boxes closer than twice the clearance, plus the lines through both ends; along an axis with no box edge in the region, the region edges are lines too, so a route can still turn back. A* runs over the crossings of these lines in a region around both ends, which grows fourfold up to the whole area when no route is found; segment tests use the bucket grid, and the search is capped at 200,000 expanded states per region so a boxed-in end cannot scan the whole graph. Equal costs are broken by insertion order, so the result depends only on the geometry. Each edge is routed independently: edges may share segments, and there is no nudging of parallel segments. A drag or resize preview reroutes the edges of the changed nodes and, incrementally, the unrelated edges a changed box gets in the way of: the segments of the saved routes that avoidNodes draws (orthogonal edges without waypoints, not self-loops) go into a bucket grid once per saved layout, and each preview frame queries it with the old and the new clearance area of every changed box. Only the edges with a segment in one of those areas are rerouted, against the preview boxes, so a pointer move costs one obstacle index of the boxes plus the routes of those few edges, not a pass over every edge. When more than 32 edges are hit in one frame, the frame reroutes none of them (a frame budget for large, dense graphs) and they follow when the position is saved. A route that only detoured around the old place, without touching its clearance area, also straightens when the position is saved, since the full routing of the saved layout then runs. Waypoints keep their precedence and are never rerouted, and without avoidNodes nothing of this runs.
Incremental placement
layoutGraphIncrementally serves graphs that grow while the user looks at them (a graph expansion page, a new node). It is placement, not layout: positioned boxes are fixed obstacles in a bucket grid, and new nodes are visited breadth-first from them, each placed on the flow side of its placed neighbours at the nearest free place across the flow, found by jumping past the boxes in the way. Components without a positioned node are laid out as one layered block outside the occupied area. So the result never moves what was there (an optional relaxed mode pushes blocking boxes by a bounded distance, never fixed ones) but does not optimise crossings or edge lengths of the new part the way a full layout does. graphLayoutChangeMetrics reports displacement, overlaps and edges through unrelated boxes of one change, as a diagnostic. External engines get the same information through the optional positions, fixedIds and addedIds request fields.
Quantity bands
layoutFlowGraph is a projection, not a router: it returns a GraphLayout whose paths are centre lines, and the edgeBands prop (or the renderGraphSvg option) only changes how a listed edge's path is painted. A band is the edge path stroked with the band width, without markers, and its hit area is at least that wide, so selection, hover, highlight, culling, toolbars and exports keep working on the same path; no filled outline is computed. Bands are painted widest first and before the other edges, so a thin band is never hidden under a thick one that it crosses. The projection never balances totals or adds quantities of different units, and it turns every edge that closes a cycle into a reference band routed outside the ranks, found by an iterative depth-first search, so a cyclic graph always terminates. Ranks and orders come from layoutLayeredGraph over the remaining acyclic edges.
Rendering virtualisation and data loading
Virtualisation and data loading are separate responsibilities. The components virtualise rendering: GanttChart draws only the rows in the scrolled row window and the bars inside the visible time window, and NetworkGraph can cull what is off screen. They still validate and index everything they are given, so the size of the input, not of the screen, bounds validation, indexing and layout. Loading belongs to the application. GanttChart reports the window it renders through visible-window-change (after mounting, coalesced, only when it changed); the pure request state in windowedData.ts turns windows into chunk-aligned requests, aborts superseded ones, ignores late answers, deduplicates items by ID and keeps a status per cell; useWindowedData wires that state to Vue and to the application's load function, which does the fetching. graphExpansion.ts does the same bookkeeping for a graph loaded one hop at a time. Links to items that are not loaded are kept out of the component input (splitDanglingLinks), because the components reject links to unknown items. Loaded data is projection input, not the plan: schedules, load, deadlines and comparisons are computed from complete inputs, never from the loaded subset.
Tree grid rendering
TreeGrid is a separate renderer, not a mode of GanttChart: it has no time axis, and shares only time-independent parts with the other components (the row tree of createTimelineRowTree, the typed field model of fieldEditing.ts, the tab-separated text of sheetEditing.ts, moveTimelineRow for row moves, WindowedCellStatus for lazy children, and the shared validation, pointer and focus helpers). Its pure model is core/treeGrid.ts: validation and indexing, the displayed lines for a set of expanded rows (an iterative preorder walk with a stack of pending status lines), row and column windows over fixed line heights and cumulative column widths (binary search), the treegrid key mapping, cell resolution and the builders and apply functions of every proposal. The component renders the window lines and columns in keyed lists whose keys are slots of the window, so a scroll patches the elements it keeps. The active line, and inside it the active column, are separate elements between those lists: Vue's keyed diff moves elements only within one list, so the focused element is never moved or removed, and an open editor lives in it. Scope: fixed line heights, one tree column, no column groups, pinning or resizing, and read and edit proposals only; sorting, filtering and aggregation belong to the application (project the rows before passing them, as with projectTimelineRows).
Timeline rendering and editing
A single horizontal/vertical scroll surface contains the fixed header, sticky row labels and positioned bars. Visible row indices plus overscan determine row DOM. Visible time bounds limit bar and tick rendering. Dependency paths are computed in the same coordinate system. The renderer uses fixed row heights and explicit lanes.
Row virtualization bounds DOM size. Input validation, row indexing and dependency scanning still process input collections. Each visible row's bars are filtered against the time window. The included 1,000-row example demonstrates rendering behavior; it is not a performance guarantee for arbitrary data sizes or devices. Browser maximum scroll dimensions also bound very large axes.
A pointer edit records the accepted interval and the initial pointer coordinate. Subsequent movement produces a local preview. Capture keeps the gesture attached to the bar; cancellation clears the preview. Source-data or coordinate changes cancel in-flight edits. On commit, validateEdit runs and an accepted proposal is emitted. The parent owns the resulting state.
Progress drags, bar deletion and the context menu use the same contract. A progress drag previews the fill locally and proposes the snapped value on release; Delete proposes bar IDs; a context menu event only describes its target. The parent applies or ignores each proposal. Tooltips are transient view state that exists only after mounting, so server output never contains them.
Drag to create and cascades follow it too. A create drag captures the pointer on the scroll container, previews a local interval and proposes a TimelineCreate that the parent turns into a bar with its own ID. A cascade callback is application code that the chart calls synchronously when a dragged bar reaches a new snapped interval; its result is only drawn as ghost outlines and attached to the proposal as one batch, so the chart still never schedules or changes bars itself. The previews share one conditional with the link preview and the add buttons share one with the expand toggle, so charts without these props render none of that markup.
Calendar-derived overlays are display data, not scheduling logic. Non-working shading, critical outlines, float lines, deadline indicators and bar segments are drawn from nonWorkingPeriods and optional bar fields that the application computes, typically with invertWorkPeriods and scheduledBarFields. Shading, float lines and deadline indicators are filtered against the visible time window like bars. A move preview shifts a bar's segments by the previewed displacement; a resize preview drops them, since only the scheduler knows the new work pattern.
Scheduling constraints on bars are display data with an editing contract like the progress slider's. The chart draws each constraint, marks the ones that the bar's dates break and, with constraintsEditable, previews a handle drag locally and proposes a TimelineConstraintEdit; it never checks feasibility or moves a bar. The application applies the proposal (applyTimelineConstraintEdit) and reschedules with scheduleTasks, which reports a conflict. Markers and handles share the deadline list and the handle list, so charts without constraints render no constraint markup.
Component internals
The components keep rendering, measurement and gesture handling in their single-file components. Pure arithmetic lives in plain TypeScript modules beside them, which the package does not export, so it can be read and tested without the component.
src/components/networkGraph/: the drag-preview layout (previewLayout(context, change)layers the changed boxes, paths and labels over the saved layout and records which nodes and edges changed, so only those items update), theavoidNodespreview rerouting index, the preview placement of edge labels (edgeLabelPlacement), group frame geometry, port keys, the move, snap and resize arithmetic, and the default node and marker drawings.src/components/ganttChart/: geometry and windowing, prop validation, the edit arithmetic for keys, drag to create andcascade, row hierarchy moves, the time overlays, load rows, bar descriptions and segments, baseline strips, constraint markers and handles, link and reconnect handles, context-menu hit-testing, the visible-window report, and the composables for the tooltip, pinch and wheel zoom (useZoomGestures), header sorting and filtering (useHeaderFilters), cell and field editing (useCellEditing) and spreadsheet mode (useSheet). OneGesturerecord holds the pointer gesture in flight, started bybeginGestureand driven by a table of move, finish and cancel handlers per gesture type; previews stay in their own reactive refs.src/components/treeGrid/: the split of the window around the active line and column, the slot keys and the scroll arithmetic of TreeGrid.src/components/shared/: helpers shared by the components.validation.tsholds the one rule for validator results (rejectionReason: false or a blank string rejects with the default text) anduseValidatedSource, which validates props, reportsvalidation-errorand falls back to the empty state;pointer.tsthe 4 px drag threshold, safe pointer capture and release, and edge auto-scroll during drags;focus.tsthe focus that follows an item after the parent applies a keyboard edit.
Supported scope
The timeline supports fixed-height rows, collapsible row trees, explicit lanes and continuous invertible time scales. Timeline baselines and header bands come from application data. A bar can carry several named baseline sets; up to three are drawn as stacked strips that the bars make room for, so rows keep their fixed height. A collapsed group hides descendant bars and their links. Applications can provide a parent bar or display an aggregated descendant interval with showSummaries. The same rollup feeds extra column values and, with summaryDependencies, anchors dependencies that end at a summary row.
Graph movement applies an overlay of absolute coordinates over the base layout. The SVG and minimap share the same geometry. Incident paths are recomputed during preview. The original node and edge arrays remain owned by the caller. Grouped moves, reconnection and deletion emit proposals, which let the caller accept each edit as one history entry. The context-menu event and the tooltip slot leave the menu and the tooltip content to the application; the component only reports targets and positions the tooltip overlay.
The default renderer handles text, SVG and HTML. Slot authors own content dimensions and accessibility of custom content. Keyboard selection and interval editing are included; assistive-technology testing with dedicated screen readers is still needed before claiming broad accessibility conformance.
Scheduling and resource-load analysis are explicit core operations called by the application. The chart renders accepted results. Explanations (scheduleTasks(input, { explain: true }), toPlanningDiagnostics) are recorded by the same passes that compute the plan and change no result. Saving is the application's: useEditTransaction coordinates one document's saves with a server through an adapter, and snapshots are JSON text that the application stores where it likes. Capacity conflicts are diagnostic. levelResources provides a baseline priority-based leveling heuristic; setup sequencing and optimization policies remain the application's concern. Calendar generation uses a fixed UTC offset or an IANA time zone with daylight-saving rules from Intl. See Scheduling and resource load.
Export
SVG export is a pure core operation. renderGraphSvg and renderTimelineSvg build a standalone document string from data, a layout or time scale and an explicit theme, so they run in Node, workers and tests. The components only gather their current props, collapsed rows, zoom and the computed --vw-* colours and call those builders. PNG export is the one browser-only step: the SVG is loaded into an image, drawn on a canvas and encoded with toBlob, after a size check. Export uses the default rendering because slots render arbitrary DOM that a string builder cannot reproduce.
Right-to-left layout
GanttChart measures every horizontal position from the inline-start edge of the time axis. In right-to-left mode the same offsets are written as right instead of left, the scroll offset is read as the distance from the inline start (-scrollLeft in a right-to-left scroll container), and pointer deltas are negated. The time scale itself is not mirrored, so toX/toTime round trips, snapping and edit proposals are identical in both directions. SVG layers (dependency paths and their hit areas) are flipped with a CSS transform. The SVG exporter has no CSS, so it mirrors the axis with mirrorTimeScale instead. NetworkGraph geometry is direction-independent; only the controls and label alignment change.