Building Vela charts
Install @luxalgo/vela (its UI kit, @luxalgo/vela-ui, comes with it). Vela runs in the
browser: in a server-rendered app, create the chart in client-only code.
Pick the entry point
| Need | Use |
|---|---|
| A chart app: topbar, symbol search, timeframes, indicators, drawings, settings | VelaWorkspace from @luxalgo/vela/workspace with layout: false |
| Several synchronized charts under one chrome | VelaWorkspace with layout: '2h', '4', … |
| Only the chart surface, your own UI around it | Vela from @luxalgo/vela |
Default to VelaWorkspace: it is the batteries-included app, and the same options configure
a bare chart.
A complete chart app
import { VelaWorkspace } from '@luxalgo/vela/workspace';
import { BinanceProvider } from '@luxalgo/vela/providers/binance';
const ws = new VelaWorkspace('#chart', {
layout: false, // one chart
symbol: 'BTCUSDT',
timeframe: '60', // minutes; '4h', '1d', 'D', 'W', 'M' also parse
live: true, // stream the forming bar
providers: { binance: () => new BinanceProvider() }, // public API, no key
theme: 'dark', // or 'light', or a createTheme(...) result
persist: true, // save layout, indicators, drawings
});
await ws.chart.ready();The container needs a size: give #chart a height (the workspace fills it).
The bare chart, offline
import { Vela } from '@luxalgo/vela';
// time: the bar's open time in epoch milliseconds
const bars = [{ time: 1730419200000, open: 100, high: 104, low: 99, close: 103, volume: 1200 } /* … */];
const chart = new Vela('#chart', { data: bars, timeframe: '1h', theme: 'dark', height: 480 });
await chart.ready();data and provider fetching are exclusive: with data, symbol is ignored. To fetch instead,
set symbol and register a provider: chart.data.registerProvider('binance', new BinanceProvider()).
Indicators
Built-in studies need nothing: chart.addNativeIndicator('rsi'), or the Indicators menu in
the workspace. Scripts need an engine, and Vela ships none. For Pine Script install
@luxalgo/vela-pinets and pinets, then:
import { VelaWorkspace } from '@luxalgo/vela/workspace';
import { PineWorkerEngine } from '@luxalgo/vela-pinets';
// workspace: one engine per chart, off the main thread
new VelaWorkspace('#chart', { /* … */ engines: { pine: () => new PineWorkerEngine() } });
// bare chart
chart.registerEngine('pine', new PineWorkerEngine());
const ema = chart.addIndicator(`//@version=5
indicator("EMA", overlay=true)
plot(ta.ema(close, 20))`);
ema.on('ready', () => console.log('computed'));addIndicator returns its handle at once; values arrive later (ready). Use
runScript(source) when you need the computed values and a clean failure instead.
Rules that prevent the common bugs
- An empty chart usually means no provider serves the symbol (the load waits, the
data:unresolvedevent fires), the provider refuses that timeframe for the symbol (data:unavailablefires with itsfinesttimeframe), or the container has no height. - A script that never shows means no engine is registered for its language.
- Read state through the chart, not from your copies.
chart.marketis the current market; switch it in place withchart.setMarket({ symbol, timeframe })(indicators and drawings survive), and listen tomarket:changed. - Do not remove the bottom-left Vela mark unless the page shows an equivalent visible
attribution ("Vela" linking to the project): the license requires one.
chart.renderer.set('attribution', false)turns it off. - Tear down with
ws.destroy()orchart.destroy(); callchart.resize()after the container changes size without a window resize. - Themes:
createTheme,checkThemeandregisterThemecome from@luxalgo/vela, thecsstag for part restyles from@luxalgo/vela/ui; thetheming-vela-uiskill (shipped with@luxalgo/vela-ui) covers restyling in depth.
Check your work
await ws.chart.ready()(orchart.ready()) resolves, and candles are visible.chart.inspect()lists the series and drawings the chart generated, a check that does not depend on pixels.- For indicators, the handle's
readyevent fires and its legend row appears.
Further reading
The docs ship with the package, matching the installed version:
node_modules/@luxalgo/vela/docs/user/workspace.md: layouts, cells, sync, persistence, composing the topbar and the sidebar.node_modules/@luxalgo/vela/docs/user/options.md: every option.node_modules/@luxalgo/vela/docs/user/api-reference.md: the chart's methods, events and control surfaces (renderer,panes,data,drawings,marks,replay).- Related skills:
using-vela-data-providers(venues, symbols, writing a provider),adding-vela-indicators(built-in studies, Pine Script®, custom indicators and engines),using-vela-drawing-tools(the toolbar, drawings from code, saving them),extending-vela-with-plugins(buttons, menus, panels and chart types).