Node appearance — shapes, size and style precedence
Three independent things decide what a node looks like: its outline, its size, and which of the three style layers currently owns each of its visual attributes. This page covers all three, because most surprises come from mixing them.
Built-in shapes
A node is a unit box, y up, centred on the node's position. Eight outlines are built in, and the one you pick drives everything about the node — fill, selection / highlight ring, icon clipping, where incident edges and arrowheads stop, and the click hitbox:
| Name | Notes |
|---|---|
circle |
the default; renders exactly as it always has |
rect |
|
roundRect |
|
diamond |
|
triangle |
apex up |
hexagon |
|
star |
five points, tip up |
ring |
an annulus — the fill is hollow |
Each shape also takes an aspect (width / height). Size stays a single
scalar: width = size, height = size / aspect. aspect: 1 (the default) is
square.
// Give one subset a shape, with a 2:1 box.
api.store.setNodeShape(["n1", "n2"], "hexagon");
api.store.setNodeShape(selectedIds, "rect", 2);
Shapes are also data-driven, per category, through the category's visual
configuration — the same place defaultColor, defaultSize and the various
*Mapping entries live:
// Every Account node is a diamond …
api.store.visualMapper.setCategoryConfig({
category: "Account",
defaultShape: "diamond",
});
// … or pick the shape from a property.
api.store.visualMapper.setCategoryConfig({
category: "Device",
shapeMapping: {
property: "kind",
shapeMap: { server: "rect", phone: "roundRect", router: "hexagon" },
defaultShape: "circle", // value missing or unmapped
},
});
api.store.visualMapper.apply();
An unknown shape name, or a non-positive aspect, throws rather than silently drawing a circle.
Shapes are not yet part of a saved snapshot, and the WebGPU render path draws circles only. An icon or image inside a non-circular shape is clipped by the outline but still laid out as if the node were round.
A node's outline and a panel drawn over it by
MediaLayer or
NodeCardLayer use the same shape code, so a
hexagonal photo and a hexagonal node dot have the same silhouette.
NodeProps.shape on <GraphCanvas node={{ shape }} /> is a different,
older switch ("circle" | "square") that configures the node cloud as a whole.
Prefer the per-node and per-category routes above.
Size
Four things multiply into the diameter a node finally draws at:
| Knob | Scope | Where |
|---|---|---|
| per-node size | one node | api.style.setNodeSize(id, px), setNodeSizes([...]), sizeNodesByProperty(prop) |
| category default | one category | CategoryConfig.defaultSize, or api.style.setDefaultNodeSize(px) for all |
| global scale | every node | api.renderer.setNodeSizeScale(value) — and the node={{ nodeScale }} prop |
| screen-fraction cap | every node | api.renderer.setMaxScreenFraction(f) |
setNodeSizeScale
api.renderer.setNodeSizeScale(4); // everything four times its configured size
api.renderer.getNodeSizeScale(); // → 4
api.renderer.setNodeSizeScale(1); // back to configured sizes
Outside map mode apparent size goes as size × scale × 50 / depth: 50 scene
units is the depth at which a node draws at exactly its configured size in CSS
pixels. That matters as soon as the view travels. A
cinematic flight holds at a distance in the
hundreds — several times that reference depth — so a 15 px node arrives on
screen a couple of pixels wide, and a route that reads well in the overview
reads as a field of dust in flight. Raising the scale on take-off and restoring
it on landing keeps both legible without touching the layout, the shot, or any
configured size.
The scale moves the node quad, the edge endpoint, the arrow back-off, self-loop radii, caption sizing and the pick hitbox together — nothing drifts out from under the dot.
It is deliberately not undoable: it is a view preference, like the theme, not a graph edit. A flight that raised and restored the scale through the recorded command path would leave two entries on the undo stack per flight.
<GraphCanvas node={{ nodeScale }} /> seeds the value on mount; an imperative
call overrides it until the prop changes.
setMaxScreenFraction
A perspective projection has no upper bound: fly close enough to any node and its quad fills the frame. The cap keeps that bounded.
api.renderer.setMaxScreenFraction(0.5); // the default
api.renderer.setMaxScreenFraction(0.2); // stricter — good for a flythrough
api.renderer.setMaxScreenFraction(Infinity); // off
0.5 means a node's diameter never exceeds half the smaller viewport
dimension. The curve is a soft knee: below half the cap it is the identity, so
anything that was not already blowing up renders exactly as before, and above it
size asymptotes instead of stopping dead. The value reaches the node, picking,
edge and arrow shaders alike, so the hitbox, the edge endpoint and the arrow tip
stay attached to the capped quad.
Values outside (0, 1] (other than Infinity) warn and fall back to the
default.
Style precedence — imperative style is sticky
Three layers decide a node's colour, size, shape and icon, in this order:
- mapping — data-driven:
CategoryConfigdefaults and*Mappingentries, re-evaluated whenever the data or the config changes; - imperative — what a user or your code set on purpose:
api.style.setNodeColor,setNodeSize,setNodeIcon, the style commands, styling carried in by an import; - transient — selection, hover and animation, resolved at draw time.
Setting an attribute imperatively claims it for that node. A later re-map —
on an add, on a config change, or an explicit apply() — no longer overwrites a
claimed attribute.
This was not always true. Code that set a colour and relied on the next
apply() to replace it must now hand the attribute back explicitly. Likewise, a
category config with a defaultColor no longer recolours nodes that were
coloured by hand.
await api.style.setNodeColor("n1", "#ff5f56"); // n1's colour is now claimed
// hand specific attributes back to the mapping (re-maps those nodes at once)
api.store.clearNodeOverrides("n1", ["color"]);
// hand everything back for a set of nodes
api.store.clearNodeOverrides(selectedIds);
Undo restores ownership as well as value, so undoing a colour change also releases the claim it made.
See also
api.style— every colour, size, icon, caption and badge method.api.renderer— scale, screen-fraction cap, theme, mode, screenshot.- Node media and Node cards — when the node should be a picture or a record rather than a dot.