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.
Install
Section titled “Install”pnpm add @lumen-ticks/corenpm install @lumen-ticks/coreyarn add @lumen-ticks/corebun add @lumen-ticks/corepnpm add @lumen-ticks/react reactnpm install @lumen-ticks/react reactyarn add @lumen-ticks/react reactbun add @lumen-ticks/react reactpnpm add @lumen-ticks/vue vuenpm install @lumen-ticks/vue vueyarn add @lumen-ticks/vue vuebun add @lumen-ticks/vue vuepnpm add @lumen-ticks/svelte sveltenpm install @lumen-ticks/svelte svelteyarn add @lumen-ticks/svelte sveltebun add @lumen-ticks/svelte sveltepnpm add @lumen-ticks/solid solid-jsnpm install @lumen-ticks/solid solid-jsyarn add @lumen-ticks/solid solid-jsbun add @lumen-ticks/solid solid-jsCreate your first chart
Section titled “Create your first chart”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,});import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/react';import { useEffect, useState } from 'react';
const options: DeepPartial<ChartOptions> = { theme: 'auto', // 'light', 'dark', or follow prefers-color-scheme accessibility: { label: 'BTC/USD 1-minute prices' },};
export function FirstChart({ bars }: { bars: OhlcColumns }) { // Passing setChart as the ref runs effects as soon as the chart mounts (and under StrictMode). const [chart, setChart] = useState<ChartApi | null>(null);
useEffect(() => { if (chart === null) return; const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(bars); 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, });
return () => chart.removeSeries(candles); }, [chart, bars]);
return <LumenChart ref={setChart} options={options} style={{ height: 420 }} />;}<script setup lang="ts">import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/vue';import { onMounted, useTemplateRef } from 'vue';
const props = defineProps<{ bars: OhlcColumns }>();const chartEl = useTemplateRef<{ chart: ChartApi | null }>('chartEl');const options: DeepPartial<ChartOptions> = { theme: 'auto', // 'light', 'dark', or follow prefers-color-scheme accessibility: { label: 'BTC/USD 1-minute prices' },};
onMounted(() => { const chart = chartEl.value?.chart; if (!chart) return;
const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(props.bars); 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, });});</script>
<template> <LumenChart ref="chartEl" :options="options" style="height: 420px" /></template><script lang="ts"> import type { OhlcColumns } from '@lumen-ticks/core'; import { lumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/svelte';
let { bars }: { bars: OhlcColumns } = $props(); const options: DeepPartial<ChartOptions> = { theme: 'auto', // 'light', 'dark', or follow prefers-color-scheme accessibility: { label: 'BTC/USD 1-minute prices' }, };
function onReady(chart: ChartApi) { const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(bars); 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, }); }</script>
<div style="height: 420px" use:lumenChart={{ options, onReady }}></div>import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/solid';
const options: DeepPartial<ChartOptions> = { theme: 'auto', // 'light', 'dark', or follow prefers-color-scheme accessibility: { label: 'BTC/USD 1-minute prices' },};
export function FirstChart(props: { bars: OhlcColumns }) { const handleReady = (chart: ChartApi) => { const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(props.bars); 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, }); };
return <LumenChart class="chart-box" options={options} onReady={handleReady} />;}Columnar vs. object input
Section titled “Columnar vs. object input”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.
Asynchronous engine & workers
Section titled “Asynchronous engine & workers”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 paintedIf 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 });// main.tsx — configure once at app entry:import { configureWorker } from '@lumen-ticks/react';import ChartWorker from '@lumen-ticks/react/worker?worker';
configureWorker({ source: ChartWorker, maxWorkers: 2 });// BundledChart.tsx — components stay free of worker boilerplate:import { LumenChart, type ChartOptions, type DeepPartial } from '@lumen-ticks/react';
const localOptions: DeepPartial<ChartOptions> = { worker: false };
export function BundledChart({ useWorker = true }: { useWorker?: boolean }) { return <LumenChart options={useWorker ? undefined : localOptions} style={{ height: 420 }} />;}// main.ts — configure once at app entry:import { configureWorker } from '@lumen-ticks/vue';import ChartWorker from '@lumen-ticks/vue/worker?worker';
configureWorker({ source: ChartWorker, maxWorkers: 2 });<script setup lang="ts">import { LumenChart, type ChartOptions, type DeepPartial } from '@lumen-ticks/vue';
// Omit `worker` to use the configured pool, or pass `false` / `'dedicated'` per chart.const options: DeepPartial<ChartOptions> = { theme: 'auto' };</script>
<template> <LumenChart :options="options" style="height: 420px" /></template>// main.ts — configure once at app entry:import { configureWorker } from '@lumen-ticks/svelte';import ChartWorker from '@lumen-ticks/svelte/worker?worker';
configureWorker({ source: ChartWorker, maxWorkers: 2 });<script lang="ts"> import { lumenChart, type ChartOptions, type DeepPartial } from '@lumen-ticks/svelte';
// Omit `worker` to use the configured pool, or pass `false` / `'dedicated'` per chart. const options: DeepPartial<ChartOptions> = { theme: 'auto' };</script>
<div style="height: 420px" use:lumenChart={{ options }}></div>// index.tsx — configure once at app entry:import { configureWorker } from '@lumen-ticks/solid';import ChartWorker from '@lumen-ticks/solid/worker?worker';
configureWorker({ source: ChartWorker, maxWorkers: 2 });import { LumenChart, type ChartOptions, type DeepPartial } from '@lumen-ticks/solid';
// Omit `worker` to use the configured pool, or pass `false` / `'dedicated'` per chart.const options: DeepPartial<ChartOptions> = { theme: 'auto' };
export function BundledChart() { return <LumenChart class="chart-box" options={options} />;}Multiple charts on the same page share a bounded worker pool automatically; see Several charts on one page.
Clean up
Section titled “Clean up”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.
Next steps
Section titled “Next steps”- 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.