Skip to content

Getting started

Lumen Ticks renders financial charts on layered HTML canvases while keeping history, level-of-detail pyramids, and indicator computation inside an asynchronous data engine.

Pick your framework below — your choice stays in sync across the Framework bindings page and every guide on this site.

pnpm add @lumen-ticks/core

Give the container a height in CSS (autoSize is enabled by default and tracks the container’s content box through a shared ResizeObserver). Framework wrappers manage mount, reactive options updates, and unmount cleanup while exposing the ChartApi for series, data, indicators, and live ticks:

import { createChart } from '@lumen-ticks/core';
const container = document.getElementById('chart')!;
const chart = createChart(container, {
theme: 'auto', // 'light', 'dark', or follow prefers-color-scheme
accessibility: { label: 'BTC/USD 1-minute prices' },
});
const candles = chart.addSeries('candlestick', { id: 'BTCUSD' });
// Times are UTC milliseconds. Pass typed-array columns for long histories,
// or an array of { time, open, high, low, close, volume? } objects.
candles.setData({ time, open, high, low, close });
chart.timeScale().fitContent();
// Add indicators computed in the data engine.
candles.addIndicator('bollinger', { params: { period: 20, multiplier: 2 } });
candles.addIndicator('ema', { params: { period: 50 } });
// Stream ticks: updates the bar with the same time, or appends a new bar.
candles.update({
time: Date.now(),
open: 101.0,
high: 102.0,
low: 100.5,
close: 101.4,
});

Both columnar typed arrays and arrays of bar objects work with setData and prepend:

  • Columnar (OhlcColumns / LineColumns): { time: Float64Array, open: Float64Array, high: Float64Array, low: Float64Array, close: Float64Array, volume?: Float64Array }. Fastest path for large histories — avoids allocating millions of objects and transfers cleanly to the worker.
  • Objects (OhlcBar[] / LinePoint[]): [{ time, open, high, low, close }, ...]. Convenient for small datasets and JSON API payloads.

Times must be UTC milliseconds in strictly increasing order.

History lives in the data engine (@lumen-ticks/engine), which runs in a Web Worker by default. Data calls return immediately and apply asynchronously:

candles.setData(history);
await chart.whenIdle(); // resolves once everything handed over so far is painted

If the page’s Content Security Policy blocks workers, Lumen Ticks automatically falls back to running the engine on the main thread in short time slices behind the exact same API.

When a bundler needs the worker declared in application code — or when you want to cap shared workers globally — call configureWorker(...) once at app startup. Every package re-exports its own standalone ./worker entry (so Vite ?worker constructors, ?url strings, URLs, static paths, and custom factories all work without installing @lumen-ticks/engine). You can also override per chart with worker: false, worker: 'dedicated', or an explicit createWorkerPool(...):

import { configureWorker, createChart } from '@lumen-ticks/core';
import ChartWorker from '@lumen-ticks/core/worker?worker'; // Vite (or pass '/assets/lumen-worker.js' / new URL('@lumen-ticks/core/worker', import.meta.url))
// Configure once at app startup — every chart shares the bounded pool automatically:
configureWorker({ source: ChartWorker, maxWorkers: 2 });
const chart = createChart(container);
const dedicatedChart = createChart(mainContainer, { worker: 'dedicated' });
const localChart = createChart(localContainer, { worker: false });

Multiple charts on the same page share a bounded worker pool automatically; see Several charts on one page.

Call chart.destroy() when removing a vanilla chart from the DOM so its canvases, observers, event listeners, and engine slot are released. The React, Vue 3, Svelte 5, and Solid bindings call destroy() automatically on unmount — you only need to clean up external streams (such as WebSockets) or subscriptions you attach yourself.

  • Framework bindings — live tick streaming, crosshair event legends, and wrapper lifecycle patterns for React, Vue 3, Svelte 5, and Solid.
  • Playground — experiment with indicators, mark layers, drawings, and JSON state live.
  • Indicators — built-in indicators, chains, and independent indicator panes.
  • Heatmap and scatter series — GPU-accelerated order books and trade prints.
  • API overview — every exported package, core interface, and framework binding API.