LCLiveCharts
Guides

Candlestick

OHLC candles, live forming candle, and line ↔ candle morph

Basic setup

import { aggregateCandles } from "livecharts/data";
import { LiveChart } from "livecharts/react";

const width = 60; // seconds per candle
const { candles, live } = aggregateCandles(ticks, width);

<LiveChart
  data={ticks}
  value={ticks.at(-1)?.value ?? 0}
  mode={mode} // "line" | "candle"
  candles={candles}
  liveCandle={live ?? undefined}
  candleWidth={width}
  onModeChange={setMode}
  momentum={mode === "line"}
/>

Same data, two views. The toggle morphs between line and candlestick.

Props

PropTypeRole
mode"line" | "candle"Active view; drives morph
candlesCandlePoint[]Closed candles
liveCandleCandlePointForming candle (wicks update live)
candleWidthnumberBucket width in seconds
onModeChange(mode) => voidFired by the built-in mode toggle

When candle data is present, control the view with mode + onModeChange (controlled). Morph state is derived from mode === "line" — you do not need lineMode.

aggregateCandles

import { aggregateCandles } from "livecharts/data";

const { candles, live } = aggregateCandles(ticks, 60);
// candles — completed buckets
// live — current open bucket, or null

Prefer this helper over hand-rolled OHLC loops so buckets stay MECE and aligned to candleWidth.

Deprecated aliases

PropStatus
lineModeDeprecated — prefer mode / onModeChange
lineData / lineValueLegacy overrides; use data / value

Alternative: LiveChartTransition

If you prefer two separate chart instances with a cross-fade instead of the built-in morph, use LiveChartTransition.

On this page