Skip to content

Your first chart

This walks through a static chart end to end. For streaming data, see Live data.

The chart fills its container and observes it for resizes, so give the element a height:

<div id="chart" style="height: 420px"></div>
import { createChart } from '@lightfin/core'
const chart = createChart(document.querySelector('#chart')!, {
volumeVisible: true, // show the volume sub-pane
})

A Bar is { time, open, high, low, close, volume? }, where time is a UTC timestamp in seconds:

const series = chart.addCandlestickSeries()
series.setData([
{ time: 1704067200, open: 100, high: 104, low: 99, close: 103, volume: 1200 },
{ time: 1704070800, open: 103, high: 106, low: 102, close: 101, volume: 980 },
// …
])

setData replaces the series and refits the viewport. For incremental updates use series.update(bar).

The series type is just the starting renderer — switch it in place without touching the data:

series.setChartType('line') // 'candlestick' | 'bar' | 'line' | 'area'