g3-toolkit API Reference
    Preparing search index...

    Interface CytoscapeCanvasProps

    interface CytoscapeCanvasProps {
        animate?: boolean;
        animationDuration?: number;
        className?: string;
        containment?: ContainmentOptions;
        edgeStyle?: "taxi" | "straight" | "bezier";
        encodingSpec?: EncodingSpec;
        graphUpdate?: "rebuild" | "additive";
        hidden?: ReadonlySet<string>;
        interactionOptions?: CanvasInteractionOptions;
        labelCollision?: "none" | "hide" | "shorten";
        labelMaxLength?: number;
        labelPriority?: (ele: SingularElementArgument) => number;
        layout?: string;
        layoutOptions?: Record<string, unknown>;
        menuManager?: ContextMenuManager;
        onReady?: (cy: Core) => void;
        structural?: { geometry: StructuralGeometry; input: StructuralGraphInput };
        structuralDecorations?: StructuralDecorations;
        structuralEdgeLayer?: "svg-overlay" | "cytoscape";
        stylesheet?: CyStylesheet[];
        ugm: UGM;
    }
    Index

    Properties

    animate?: boolean

    F1: Animate layout transitions. Default true. Never applied to a preset layout (issue #27): preset positions are already decided, and an animated preset tweened nodes back toward the positions captured at construction, undoing whatever onReady placed.

    animationDuration?: number

    F1: Animation duration in ms. Default 400.

    className?: string

    CSS class for the container div.

    containment?: ContainmentOptions

    RELAYOUT CONTRACT (upstream round-6, 2026-07-28): a full re-init (layout re-run, positions discarded unless the same-graph preset replay applies) is triggered ONLY by CONTENT changes to: ugm identity, containment, layout, layoutOptions, interactionOptions, edgeStyle, animate. stylesheet and encodingSpec changes are STYLE REFRESHES and preserve positions.

    edgeStyle?: "taxi" | "straight" | "bezier"

    F8: Edge curve style override. When set, applies the given style to ALL edges regardless of their topology. When NOT set (default), edges auto-select straight vs bezier based on whether the curve is actually needed (see bugfix 21 in ugmToCytoscapeElements): straight for the common single-edge case, bezier for self-loops, parallel multi-edges, and bidirectional pairs.

    encodingSpec?: EncodingSpec

    Optional encoding spec; when present, element visual data is patched through applyEncodingSpec on mount and on every spec change (roadmap/design/encoding-controls.md application milestone). Spec changes RESTYLE ONLY: element data patches do not re-run layout, so visual edits never move nodes (given a stable ugm reference, above).

    graphUpdate?: "rebuild" | "additive"

    How a NEW ugm identity reaches a live instance (issue #26). "rebuild" (default): a new identity is a different graph; the instance is re-created and laid out from scratch (positions and camera reset), as the ugm contract above says. "additive": when the new ugm shares at least one node with the live instance (the same scene, grown by an explorer's expansion or shrunk by its collapse or a type filter, issues #26 and #64), the instance is kept: nodes the new ugm lacks are removed in place with their incident edges, new nodes and edges are added, edges the new ugm no longer has are removed, existing elements take the new ugm's data, every surviving node keeps its position, and ONLY the new nodes are laid out, seeded at the centroid of their already-placed neighbors and settled by fcose with every existing node held by fixedNodeConstraint (which fcose honors; locked it does not). A pure removal runs no layout at all. The camera is untouched (no fit). animate and animationDuration apply to the growth pass. A ugm that shares NO node with the drawn one (an empty ugm included: there is no scene to keep), a containment change that re-parents a surviving node (a removed parent's surviving children are moved to the top level, which is not a re-parent), or a structural scene falls back to the rebuild path. Edge ids must be stable across steps (pass key to UGM.addEdge) for the diff to add only the new edges; generated ids differ per UGM instance, so every edge is then replaced (correct, but a churn). The spec, hidden set, pins, overrides and overlays are re-applied to the updated instance; store entries naming a removed id are the host's and are left as they are (the re-apply passes skip ids the instance no longer has, exactly as a rebuild does).

    hidden?: ReadonlySet<string>

    Node ids to hide on the canvas (a visibility filter). Hidden nodes get a g3t-hidden class (display: none), so Cytoscape drops them from layout and auto-hides their incident edges, WITHOUT a re-init: applied as a batched class toggle, so positions and the instance survive. Use this for type/facet filtering instead of feeding a pre-filtered UGM (which would re-create the instance and re-run layout on every toggle). Must be referentially stable across renders where it has not changed; rebuild it only when the hidden set does.

    interactionOptions?: CanvasInteractionOptions

    Interaction knobs forwarded into the cytoscape constructor. Content-keyed: changing values re-initializes the instance (they are init-time-only in cytoscape).

    labelCollision?: "none" | "hide" | "shorten"

    Label collision handling (issue #40). Cytoscape draws every label at its element and never moves one out of another's way, so dense graphs overprint. "none" (default): current behavior. "hide": after layout settles, after a zoom ends, after a node is dropped, and on every selection/hover change, each visible element's rendered label box is measured and lower-priority overlapping labels are hidden (class g3t-label-hidden, rule label: ""). "shorten": the same, but a loser is first truncated to labelMaxLength characters with an ellipsis (data field _labelShort, read by a [_labelShort]-scoped rule) and hidden only if the shortened box still overlaps. Priority: selected (an edge counts as selected when either endpoint is) > hovered (hoveredNodeId in the selection store; incident edges count) > labelPriority / _labelPriority > node before edge > node degree or edge weight. An overlay pass, restyle only: never re-inits, refits, or moves nodes, and never writes label (the spec and converter own that field). The pure rule is exported as resolveLabelCollisions for hosts with their own renderer.

    labelMaxLength?: number

    "shorten" mode: maximum characters of a truncated label, ellipsis included. Default 16.

    labelPriority?: (ele: SingularElementArgument) => number

    Host rank for the collision pass (higher wins within the selected / hovered tiers). Read through a ref, so an inline arrow is fine; a changed accessor takes effect on the next pass. When omitted, the _labelPriority element data field is used (0 if absent).

    layout?: string

    Optional layout name (default: "fcose" if available, else "cose").

    layoutOptions?: Record<string, unknown>

    Extra options merged into the layout object AFTER the built-in tuning, so callers can adjust spacing and fit (review 5.11: idealEdgeLength, nodeRepulsion, padding, ...) without forking the canvas. Keyed by CONTENT (like structuralDecorations), so an inline literal does not re-init the instance every render; a content change re-runs layout. Structural (preset) scenes ignore the fit-related keys: the camera policy there is explicit.

    menuManager?: ContextMenuManager

    Optional ContextMenuManager. If omitted, a default is created whose base menu is FUNCTIONAL with zero config: one copy item wired to the clipboard, labeled "Copy IRI" or "Copy ID" from the element's id shape. "Inspect properties" appears only when a manager built with createDefaultMenuManager({ onInspect }) is passed (an unwired Inspect is omitted, never rendered dead); app-specific items go through manager.register().

    onReady?: (cy: Core) => void

    Callback when the Cytoscape core is ready. ORDERING GUARANTEE (issue #27): fires synchronously after construction and after the initial layout was STARTED. A preset layout (the layout prop, a structural scene, or the LR-45 same-graph replay) is never animated and has therefore FINISHED by then, so positions set here hold; nothing moves them afterwards. A force layout (fcose, cose) is asynchronous and still running when this fires, so positions set here are overwritten when it settles; do post-layout work on cy.one("layoutstop", ...) instead.

    structural?: { geometry: StructuralGeometry; input: StructuralGraphInput }

    Owner ruling 2026-07-28: use StructuralSvgView for structural scenes. The cytoscape structural path (compound containers + eports + drag attachment) is behind the SVG view and will be removed once remaining consumers migrate. A dev-only warning fires on first use.

    structuralDecorations?: StructuralDecorations

    Optional render-time decorations for a structural scene (SHACL B3: closed-shape borders, per-row validation severity). Ignored unless structural is set.

    structuralEdgeLayer?: "svg-overlay" | "cytoscape"

    Which layer draws ROUTED structural edges (G3L:RND-002, the ruled per-surface opt-in). "cytoscape" (default): the shipped segments projection. "svg-overlay": an SVG layer above the canvas draws the true absolute polylines (arrowheads, dashes, labels included); the underlying Cytoscape edges stay mounted but fully transparent so hover/context-menu interaction is UNCHANGED (parity by construction). Declared-port edges keep their Cytoscape taxi rendering in both modes (the ruled perpendicular-exit behavior). Ignored unless structural is set.

    stylesheet?: CyStylesheet[]

    Optional additional stylesheet rules to merge.

    ugm: UGM

    The UGM instance to render. MUST be referentially stable across renders: a new identity means "different graph" and triggers a full re-init INCLUDING layout. Memoize in the parent; do not rebuild per render.