Concepts
Architecture
Engine, React wrapper, overlays, and performance boundaries
Layers
┌─────────────────────────────────────┐
│ React: <LiveChart /> │ props → EngineConfig
│ LiveChartTransition (optional) │
│ useLiveChartEngine (low-level) │
├─────────────────────────────────────┤
│ LiveChartEngine (livecharts) │ rAF loop, state, draw
├─────────────────────────────────────┤
│ Canvas 2D + badge DOM overlay │
└─────────────────────────────────────┘LiveChartEngineowns animation state, drawing, badge DOM, orderbook particles, and hover.<LiveChart />maps React props toEngineConfig, manages window/mode UI chrome, and series toggle state.livecharts/datais optional helpers with no canvas dependency.
Why the badge and value overlay are not React state
The live value badge and showValue overlay update every frame via direct DOM writes. That avoids React re-renders at 60fps while keeping numbers in sync with the canvas.
Host responsibilities
Your app owns:
- Fetching / streaming data
- Trimming history (walkers do this for demos; production feeds should bound memory)
- Passing fresh
data+value(orseries/ candles) each update
The engine owns: interpolation, range, scrubbing, theming palette derivation, and drawing.
Framework-agnostic core
Anything that can host a canvas can drive LiveChartEngine:
import { LiveChartEngine, resolveTheme } from "livecharts";
const engine = new LiveChartEngine({ canvas, container });
engine.setConfig({ /* EngineConfig */ });
engine.start();
// later
engine.destroy();See LiveChartEngine and useLiveChartEngine. Vue bindings: livecharts/vue.
Performance notes
- Prefer updating props at your feed rate (e.g. 4–20 Hz); the engine paints at display refresh.
- Keep history bounded (
createWalkertrims viatrimAfter; do the same for WebSockets). - Multi-series and orderbook add draw cost — still one canvas, but more paths per frame.
pauseWhenOffscreenkeeps background tabs cheaper.
Attribution
Drawing and animation core started from Liveline (Benji Taylor, MIT). This package splits that engine from React, adds Vue / data entries, and documents the public API. Notices ship in the published LICENSE.