LCLiveCharts
Guides

Candlestick

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

Basic setup

<script setup lang="ts">
import { aggregateCandles } from "livecharts/data";
import { LiveChart } from "livecharts/vue";
import { computed, ref } from "vue";

const width = 60; // seconds per candle
const mode = ref<"line" | "candle">("line");
const ticks = ref(/* your tick history */);

const bucket = computed(() => aggregateCandles(ticks.value, width));
</script>

<template>
  <LiveChart
    :data="ticks"
    :value="ticks.at(-1)?.value ?? 0"
    :mode="mode"
    :candles="bucket.candles"
    :live-candle="bucket.live ?? undefined"
    :candle-width="width"
    :momentum="mode === 'line'"
    @mode-change="(m) => (mode = m)"
  />
</template>

Live preview uses the shared engine via React bindings; copy the Vue snippet above.

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

Props / events

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

When candle data is present and you listen for @mode-change, LiveCharts shows a line / candle control. Prefer controlled mode — morph follows mode === "line" (no lineMode prop needed).

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 / @mode-change
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