GraphCanvasProps

type GraphCanvasProps = GraphRendererProps

Choosing your renderer mode

<GraphCanvas> ships with three orthogonal feature flags. Pick the one that matches the kind of graph you are drawing.

  • map — set to true or a MapConfig to anchor nodes by latitude / longitude on a tiled basemap. The engine auto-mounts a FlatLayer or GlobeLayer depending on MapConfig.is3D and pins matching nodes by their geo properties. Use for geographic data.
  • forceLayout — set to true or a ForceLayoutConfig to run the built-in GPU force simulation. The engine constructs an internal LayoutController and steps it on every frame until alpha decays. Use for relational graphs without geographic structure.
  • layoutController — pass an external LayoutControllerInterface if you want to drive layout yourself (CPU d3-force, a server-side layout, a static snapshot). When set, both forceLayout and map's geo-pinning are bypassed.

An explicit layoutController always wins over forceLayout. map is independent of layout — you can use map with any layout source, but the default geo-pinning will pin matching nodes regardless of what your layout produces.

nodeCloud / edgeCloud vs custom children

By default (nodeCloud: true, edgeCloud: true), GraphCanvas auto-mounts a <NodeCloud> and <EdgeCloud> inside its scene. Pass false and use the children slot when you need to drive instancing yourself — for example, to render custom marker geometry or to layer multiple clouds.

cameraZ and initialPosition

The defaults (cameraZ: 0.001, initialPosition: [0, 0, -15]) target a centred 3D scene with the camera close to the origin. Map layers shift the ideal camera distance — when map: true is on, set cameraZ to roughly 6 to allow deeper map zoom-out without clipping. For 2D scenes a smaller initialPosition.z (closer to -3) tightens the framing.

Global visual scalars

antialias boolean
true
Enable anti-aliasing on the WebGL renderer.
backgroundColor number
`0x000000` (black)
Background color as a hex integer (e.g. 0x1a1a2e). Overridden by theme when that prop is set.
clickDim boolean
`false` — a plain click just selects; pass `clickDim` to
Click-DIM: when true, clicking a node or edge fades all OTHER instances (and their labels) to make the local neighborhood stand out. Clicking a node keeps it + its 1-hop neighborhood bright; clicking an edge keeps its two endpoints bright; clicking the same target again, or the background, clears. The dim does NOT resize anything — kept nodes stay their own size. opt in. Independent of the hover ring. The ring/halo on the hovered node is governed separately and is on by default (see the engine's glowEnabled, api.emphasis.setEmphasisGlowEnabled). Setting clickDim only toggles the click-driven dimming of non-neighbors. Equivalent to api.emphasis.setClickDimEnabled(value).
edgeTextScale number
0.6
Global text scale for edge labels.
iconFonts IconFontConfig | IconFontConfigExt[]Icon font configurations. Fonts are loaded at runtime (no bundle impact).
mapProvider FreeProviderName | string & objectTile provider key for the world map. When omitted, the engine derives a provider from theme: - string preset key → DEFAULT_THEME_TO_PROVIDER[theme] - object theme with isDark: true → "cartoDark" - object theme with isDark: false → "cartoLight" - undefined → "cartoDark" Explicit mapProvider always wins. Setting mapProvider while map is disabled is a no-op for the user but pre-arms the active provider for the next enableMap() call.
pixelRatio number
`window.devicePixelRatio`
Device pixel ratio passed to renderer.setPixelRatio().
textScale number
0.6
Global text scale for node labels.
theme GraphThemeConfig | "dark" | "light" | "midnight" | "forest" | "warm"Canvas theme. Sets background color, text color, and node ring mode automatically. Can be a preset key ('dark' | 'light' | 'midnight' | 'forest' | 'warm') or a custom GraphThemeConfig. When set, overrides backgroundColor.

API / refs

apiOptions ApiOptionsOptions for the RenderEngineApi (undo stack size, auto-commit delay).
apiRef RefObject<RenderEngineApi>Imperative ref to the RenderEngineApi instance.
onReady (context: GraphContextValue) => voidFired once when the renderer has fully initialized and the GraphContextValue is available. Useful for grabbing imperative refs to scene / camera / store at startup. Called at most once per component lifetime.

Performance / debug / loading

autoStartLayout boolean
true
Auto-start layout when layoutController provided

Controlled state

cameraZ number
0.001
Camera Z position. Set to ~6 for map layers to allow deeper zoom.
defaultDim 2 | 3
undefined (effective dimension is derived from `is3D`, which defaults to `3`)
Initial dimension on mount. Uncontrolled: only applied once on first mount via engineApi.setDimensions(). Subsequent prop changes are ignored. If is3D is also provided, is3D takes precedence and defaultDim is ignored. Use engineApi.setDimensions() to change dimensions at runtime.
defaultHidden HiddenStateUncontrolled initial hidden set. Applied once on mount.
defaultIs3D booleanUncontrolled initial 3D mode. Applied once on mount. Ignored if is3D is also set. Legacy defaultDim: 2 | 3 (Phase 1 deprecated) maps to this when defaultIs3D is unset (handled in the wiring step).
defaultPinned PinnedStateUncontrolled initial pinned set. Applied once on mount.
defaultSelection SelectionStateUncontrolled initial selection. Applied once on mount (via the same engine path as selection). Ignored if selection is also set.
defaultTheme GraphThemeConfig | "dark" | "light" | "midnight" | "forest" | "warm"Uncontrolled initial theme. Applied once on mount. Ignored if theme is also set.
defaultViewState ViewStateUncontrolled initial view state. Applied once on mount. Ignored if viewState is also set. Folds the legacy cameraZ and initialPosition props — those are now @deprecated aliases.
hidden HiddenStateControlled hidden state. hidden.nodes is the set of node IDs to hide; the engine reconciles via api.nodes.hide / api.nodes.show. Edge hiding is not yet supported (the field is accepted for forward-compat but the engine ignores it). Pair with onVisibilityChange.
hoveredId HoverTargetControlled hover target. When set, the engine snaps the hovered node to this value (via api.hover.set). null clears. Edge targets are forward-compat — the engine ignores them today. Note: programmatic hover does NOT trigger the hover-emphasis dim effect (which is reserved for real pointer events). It only updates the store's hovered-node id. No defaultHoveredId — mount-time hover is incoherent (spec Rule 4 carve-out).
initialPosition [number, number, number]
[0, 0, -2]
Initial cloudScene position [x, y, z]. Use for centering on a region.
is3D boolean
true
3D mode. When false, rotation is disabled and view angle resets to flat.
onHoverChange (next: HoverTarget, prev: HoverTarget) => voidFired when the hovered target changes. Receives (next, prev).
onIs3DChange (next: boolean, prev: boolean) => voidFired when 3D mode toggles. Receives (next, prev) as booleans.
onPinnedChange (next: PinnedState, prev: PinnedState) => voidFired when pinned changes. Receives (next, prev) with the authoritative pinned-id set read from the engine after the change.
onSelectionChange (next: SelectionState, prev: SelectionState) => voidFired when the selection changes. Receives (next, prev). In controlled mode, echoes of programmatic writes (source: "api") are suppressed — only user-driven selections trigger the callback.
onThemeChange (next: "dark" | "light", prev: "dark" | "light") => voidCalled when the canvas theme changes (toolbar toggle, api.renderer.setTheme(...), etc.). Use this to sync the host application's theme (CSS variables, dark-mode class, etc.) with the canvas. Only fires when the theme actually changes. Signature was extended from (theme) → void to (next, prev) → void in Phase 4. JS callers that ignore the second arg continue to work; TS callers' (theme) → void signatures also still type-check (TypeScript allows discarding extra parameters).
onViewStateChange (next: ViewState, prev: ViewState) => voidFired when the view state changes. The hook RAF-polls the engine for camera updates only when this callback is registered (no per-frame cost when omitted). In controlled mode, echoes of our own writes are suppressed.
onVisibilityChange (next: HiddenState, prev: HiddenState) => voidFired when visibility changes. Receives (next, prev) where next.nodes is the authoritative hidden-id set read from the engine after the change.
pinned PinnedStateControlled pinned-node state. The engine reconciles via api.nodes.pin / api.nodes.unpin. Edge pinning is forward-compat (the field is accepted but ignored by the engine).
selection SelectionStateControlled selection state. When provided, the host owns selection and the engine syncs to this value every render (via clear + selectNodes + selectEdges). Pair with onSelectionChange to read user-driven changes.
viewState ViewStateControlled view state — cloudScene position, camera z, and (for 3D) scene rotation. When set, the engine snaps to this state every render via api.camera.setViewState. Pair with onViewStateChange to read user-driven camera moves.

Subsystem mount toggles

caption boolean | CaptionPropsSimplified node caption config. Auto-creates TextLayer when set and no children provided. - true: enable with defaults - false / undefined: disabled - CaptionProps object: enable with custom config
controlConfig GraphControlConfig
controls boolean | GraphControlConfig
true
Enable scene controls (pan/zoom/rotate). - true: enable with defaults - false: disabled - GraphControlConfig object: enable with custom config
drag boolean
true
Enable node dragging.
edge boolean | EdgePropsSimplified edge config. Auto-creates EdgeCloud when set and no children provided. - true: enable with defaults - false / undefined: disabled - EdgeProps object: enable with custom config
edgeCaption boolean | EdgeCaptionPropsSimplified edge caption config. Auto-creates EdgeTextLayer when set and no children provided. - true: enable with defaults - false / undefined: disabled - EdgeCaptionProps object: enable with custom config
edgeCloud boolean | EdgeCloudConfigEdge cloud configuration. - true: enable with default config - false/undefined: disable (or use children) - object: enable with custom config
enableControl booleanEnable scene controls.
enableDrag booleanEnable node dragging.
enableWebGPURenderPath booleanAllows the engine to use the WebGPU render path. Default false. true only means "host allows it" — the path also needs a capable/available device and no prior fault. Setting it back to false is a switch, not a fallback, and never triggers renderFault. Once a device loss or shader-compile failure has occurred, this engine instance is permanently stuck on WebGL; recovering requires recreating the whole engine instance.
forceLayout boolean | ForceLayoutConfigEnable built-in GPU force-directed layout without constructing a controller. - true: enable with sensible defaults - ForceLayoutConfig object: enable with custom params - false / undefined: disabled (default) Ignored when layoutController is explicitly provided — that wins. The engine constructs an internal controller using its own WebGLRenderer and syncs topology automatically as the GraphStore changes.
layoutController LayoutControllerInterfaceGPU Layout Controller interface for position texture integration.
legend boolean | objectLegend panel configuration. - true: enable with default config - false/undefined: disable - object: enable with custom config
locale stringUI language for all built-in panels (toolbar, legend, node-info overlay). One of the bundled locales: 'en' (default), 'zh', 'es'. Unknown values fall back to English. Each subsystem ships its own translation bundle (see toolbar/i18n/*.json, legend/i18n.*.json, layers/i18n/nodeInfo.*.json); set this once and every panel follows. Hosts needing strings beyond the bundled locales can still override individual subsystems (e.g. toolbar={{ messages }}), and a per-toolbar locale override wins over this canvas-level value.
map boolean | MapConfigMap mode configuration. When set, GraphCanvas auto-mounts FlatLayer (is3D=false) or GlobeLayer (is3D=true) and (by default) auto-pins nodes by lat/lng. See MapConfig. - true: enable with defaults (cartoDark tiles, auto geo-detection) - MapConfig object: customize tile provider, projection, geoLayout - undefined / omitted: no map (host can still manually mount layers)
mapProjection MapProjection
`"spherical"` when `is3D=true`, `"planar"` when `is3D=false`
Override the map projection.
minimap boolean | MinimapConfigMinimap configuration. - true: enable with default config - false/undefined: disable - object: enable with custom config (width, height, position, margin)
node boolean | NodePropsSimplified node config. Auto-creates NodeCloud when set and no children provided. - true: enable with defaults - false / undefined: disabled - NodeProps object: enable with custom config
nodeCloud boolean | NodeCloudConfigNode cloud configuration. - true: enable with default config - false/undefined: disable (or use children) - object: enable with custom config
toolbar boolean | Partial<Omit<ToolbarProps, "children">>Toolbar auto-mount configuration. The toolbar is hidden by default — opt in by setting true (auto-mount with the built-in registry) or by passing a config object to override individual Toolbar props (registry, locale, messages, theme, controlled state pairs). You may also render your own <Toolbar> as a child instead. - undefined / false: do not mount (default) - true: auto-mount with createDefaultRegistry() and internal state - object: auto-mount, but use the provided Toolbar props as overrides

DOM / host integration

children ReactNodeChildren components (NodeCloud, EdgeCloud, etc.) - for advanced/custom rendering.
className stringCSS class forwarded to GraphCanvas's internal host div, used when container is not provided. Ignored (with a one-time dev-mode console.warn) when container is provided — in that case the host caller owns styling.
container HTMLElementContainer element or ref.
style CSSPropertiesInline styles forwarded to GraphCanvas's internal host div. Shallow-merged with the default { width: "100%", height: "100%", position: "relative" }. Ignored (with dev-mode warn) when container is provided.

Data

data GraphDataDirect graph data input. Creates internal GraphStore + calls setData().
store GraphStoreCustom GraphStore (for sharing between components).

Lifecycle / data callbacks

onAlgorithmEnd (info: AlgorithmInfo) => voidFired when an algorithm completes successfully. durationMs is wall-clock time since onAlgorithmStart for this jobId. result is the algorithm payload (varies by algo); cast via (info as AlgorithmInfo<MyResult>).
onAlgorithmError (info: AlgorithmInfo) => voidFired when an algorithm throws. info.error is the underlying Error. Also dispatched to the general onError with ctx.source === "algorithm".
onAlgorithmProgress (info: AlgorithmInfo) => voidFired periodically during an algorithm run. info.progress is 0..1 (normalised from the engine's pct: 0..100).
onAlgorithmStart (info: AlgorithmInfo) => voidFired when a graph algorithm begins (centrality, community detection, pathfinding, etc.). jobId is stable across start → end / start → error for correlation; nodeCount / edgeCount are the input sizes.
onDelta (delta: GraphDelta, result: GraphDeltaResult) => voidFired once per batched graph mutation (api.nodes.add, api.edges.add, api.data.setData, etc.). Carries the input delta (what the host requested) and the result (what the engine actually applied — may differ when IDs collide or nodes were rejected). Use to mirror the graph into an external store (Redux, server roundtrip, URL state, etc.). Fires AFTER the engine has applied the change.
onDestroy () => voidFired once just before the engine tears down (component unmount or api.destroy()). Use to release host-side resources tied to the engine (event subscriptions on api.events, custom GPU resources, etc.).
onError (err: Error, ctx: ErrorContext) => voidFired when the engine catches an internal async error. v1 covers algorithm-worker errors (source: "algorithm"); render / layout / data / map sources will be wired incrementally as their emit sites are audited. The callback is informational — the engine continues running where it can. Hosts should log + surface a user-visible message but not assume the engine is dead unless ctx.recovered === false.
onHistoryChange (info: HistoryChangeInfo) => voidFired after every undo-able mutation, after api.history.undo(), and after api.history.redo(). Use to update host UI for undo/redo button disabled state.
onLayoutEnd (info: LayoutEndInfo) => voidFired when a layout finishes (force simulation converged, geometric layout returned). Carries the type and how long it ran.
onLayoutProgress (info: object) => voidFired on every layout tick during force simulation. progress is the engine's internal completion estimate (typically 1 - alpha for force layouts, 0..1). Throttle in userland if you don't want per-frame updates. NOTE: layout:tick is not yet wired in the engine's LayoutEventBridge — the callback is bridged but inert until that emission lands.
onLayoutStart (info: object) => voidFired when a layout begins (force simulation start, geometric layout invocation, etc.). info.type matches the engine's layout-type tag (e.g. "force", "circle", "grid").
onStyleChange (info: object) => voidFired after a style change (category color, relationship color, etc.). target distinguishes node-category styling from edge-relationship styling; name is the category / relationship identifier.
onViewChange (view: object) => voidCalled whenever any view-state field emits via view:changed (theme / mode / minimap visibility). Thin wrapper over api.events.on("view:changed", ...) for hosts that prefer prop-style callbacks. Each call only includes the fields that changed.

Interaction callbacks

onBackgroundClick (event: BackgroundPointerEvent) => voidFired when the user clicks the empty canvas background (no node or edge under the pointer).
onBackgroundContextMenu (event: BackgroundPointerEvent) => voidFired on right-click of the empty canvas background.
onEdgeClick (event: EdgePointerEvent) => voidFired when the user clicks an edge.
onEdgeContextMenu (event: EdgePointerEvent) => voidFired on right-click of an edge. See onNodeContextMenu for default-menu suppression.
onEdgeDoubleClick (event: EdgePointerEvent) => voidFired when the user double-clicks an edge.
onEdgeHover (event: EdgePointerEvent) => voidFired when the pointer enters an edge. null payload on leave; see onNodeHover for the controlled-vs-pointer distinction.
onNodeClick (event: NodePointerEvent) => voidFired when the user clicks a node. Payload includes nodeId, canvas pixel position, world-space [x,y,z], modifier-key state, and the underlying MouseEvent.
onNodeContextMenu (event: NodePointerEvent) => voidFired on right-click of a node. The engine's ContextMenuManager still shows its own menu by default; call originalEvent.preventDefault() from this handler to suppress that menu and own the gesture entirely.
onNodeDoubleClick (event: NodePointerEvent) => voidFired when the user double-clicks a node. Default browser behaviour: a dblclick always fires a preceding click, so onNodeClick will also fire once.
onNodeDrag (event: NodeDragEvent) => voidFired on every frame during an active drag. Throttled to the render cadence (not the raw pointer-move rate). deltaWorld is cumulative from the drag-start position.
onNodeDragEnd (event: NodeDragEvent) => voidFired once when the drag gesture ends (pointer up). Use this to commit positions to your host's state — onNodeDrag mid-drag deltas are not meant to be persisted on every frame.
onNodeDragStart (event: NodeDragEvent) => voidFired once when the user begins dragging one or more nodes. Carries the full set of node IDs in the drag gesture (multi-select drag yields draggedNodeIds.length > 1). Only fires when drag !== false (the engine doesn't compute drag at all when drag is disabled).
onNodeHover (event: NodePointerEvent) => voidFired when the pointer enters a node. The argument is null when the pointer leaves the last hovered node without entering another node. Use for tooltip-style highlights of the hovered node's neighborhood. For programmatic "as if hovered" highlighting (e.g. when the user hovers an external list row), use the controlled hoveredId prop coming in Phase 4 — that is a different mechanism with a different payload.