effects

Animations & emphasis

These are the built-in effects (rung 1 — no layer authoring). They decorate the nodes and edges you already have:

  • api.animations — decorative GPU motion: ripples, edge flow, glow, breathe, entrance/explosion, metric pulse.
  • api.emphasis — attention and focus: highlight a path, cascade a wave through a network, dim everything outside a focus set.

All of it runs in shaders with zero per-frame CPU work, and none of it is recorded in history (effects are transient — not undoable).

The effect-ID model

Every start method returns an opaque effect ID. Keep it to stop the effect later; or stop a whole family / everything at once:

const id = api.animations.edgeFlow(edgeIds, { speed: 2.0 });
api.animations.stop(id);            // stop this one
api.animations.stopAll('edgeFlow'); // stop every edge-flow effect
api.animations.stopAll();           // stop everything

The effect manager is shared across api.animations, api.emphasis, api.overlays, and api.playback, so an ID from any of them is a valid argument to stop.

Loop semantics

Five persistent effects — nodeRipple, nodeBreathe, edgeFlow, edgeGlow, metricPulse — take a loop flag:

  • loop: true (default) — runs until you stop it. Combine with duration > 0 to make it self-terminate after N ms.
  • loop: false — one-shot; self-terminates after duration (which must be > 0).

The remaining effects (nodeEntrance, nodeExplosion, edgeDraw, pathHighlight, cascadeHighlight) are one-shot by nature and end on their own.

Animations

Method Effect
nodeRipple(ids, cfg?) Expanding concentric rings out of nodes.
nodeBreathe(ids, cfg?) Sinusoidal size oscillation.
nodeEntrance(ids, cfg?) Scale-up + fade-in (one-shot).
nodeExplosion(ids, cfg?) Nodes fly from a center to their positions (one-shot "big bang").
edgeFlow(ids, cfg?) Particles travel along edge paths.
edgeGlow(ids, cfg?) Pulsating luminosity along edges.
edgeDraw(ids, cfg?) Edges fade in from 0 to their opacity (one-shot).
metricPulse(ids, cfg?) Pulse amplitude scaled to a node metric.

Edge effects

edgeFlow and edgeGlow are the workhorses for showing material / data moving through a network — the supply-chain flow scenario layers them: flow on every lane, glow on the heavy ones.

const edgeIds = api.edges.getAll().map(e => e.id);
const flowId = api.animations.edgeFlow(edgeIds, { speed: 0.1, color: [0.45, 0.85, 1.0] });

// add a glow accent on the high-volume lanes
const heavy = api.edges.getAll().filter(e => e.properties.volume > 800).map(e => e.id);
const glowId = api.animations.edgeGlow(heavy);

// stop when done
api.animations.stop(flowId);
api.animations.stop(glowId);

Node ripple

A bounded shockwave is great for marking an event — an impact, an alert, a node coming online. The disruption scenario fires one when a supplier goes offline:

api.animations.nodeRipple([targetId], {
  loop: false, duration: 850, color: [1, 0.45, 0.12], speed: 0.6, rings: 2,
});

Emphasis

Method Effect
pathHighlight(path, cfg?) Sequentially illuminate an alternating node/edge path.
cascadeHighlight(sourceIds, cfg?) BFS wave of size+glow expanding hop by hop.
focusContext(nodeIds, cfg?) Keep a focus set bright; dim everything else.
retargetFocusContext(nodeIds, cfg?) Move an existing focus set without a flicker.
dimNeighborhood(nodeId, hops?) Dim everything outside an N-hop neighborhood.
dimExcept(keepIds, opts?) Dim everything outside an explicit keep set.
clearDim() Release a programmatic dim.

The Les Misérables focus & context scenario combines them — select Valjean, dim the rest, then ripple a cascade through his network:

api.selection.selectNodes(['valjean']);
api.emphasis.focusContext(['valjean'], { contextOpacity: 0.12 });
api.emphasis.cascadeHighlight('valjean');   // wave expands hop by hop
// ...
api.emphasis.clearDim();

Click-to-dim

The engine can dim automatically on click — clicking a node keeps it and its 1-hop neighborhood bright and fades the rest; clicking again or the background clears it. Opacity only: no node changes size. Off by default, controlled by the clickDim prop on <GraphCanvas> and by api.emphasis.setClickDimEnabled(...). The hover ring is independent (setEmphasisGlowEnabled). See the click-to-dim scenario.

api.emphasis.setClickDimEnabled(true);   // click a node → focus + dim the rest
api.emphasis.setEmphasisGlowEnabled(true); // hover ring (on by default)

See also