Themes and display options
Hollow candles, dashed grid lines, step average, crosshair modes and watermark, following this site’s color mode.
const chart = createChart(element, { theme: 'auto', // 'light' (default), 'dark', or follow the system setting grid: { vertLines: { visible: false }, horzLines: { style: 'dashed' } }, crosshair: { mode: 'magnet' }, // or 'nearest', 'normal', 'hidden' priceScale: { position: 'left', scaleMargins: { top: 0.1, bottom: 0.2 } }, watermark: { visible: true, text: 'BTCUSD · 1m' },});
// Nested options merge: this changes one color and keeps everything else.chart.applyOptions({ layout: { textColor: '#8a93a6' } });
const candles = chart.addSeries('candlestick', { upColor: 'rgba(0, 0, 0, 0)', // hollow up candles borderVisible: true, priceLineStyle: 'dotted',});const average = chart.addSeries('line', { color: '#f5b83d', lineType: 'step', lineStyle: 'dashed' });import { LumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/react';import { useEffect, useMemo, useState } from 'react';
export function ThemedChart({ textColor = '#8a93a6' }: { textColor?: string }) { const [chart, setChart] = useState<ChartApi | null>(null);
// Nested options merge when updated; memoize so unrelated renders skip applyOptions. const options = useMemo<DeepPartial<ChartOptions>>( () => ({ theme: 'auto', // 'light' (default), 'dark', or follow the system setting grid: { vertLines: { visible: false }, horzLines: { style: 'dashed' } }, crosshair: { mode: 'magnet' }, // or 'nearest', 'normal', 'hidden' priceScale: { position: 'left', scaleMargins: { top: 0.1, bottom: 0.2 } }, watermark: { visible: true, text: 'BTCUSD · 1m' }, layout: { textColor }, }), [textColor], );
useEffect(() => { if (chart === null) return; const candles = chart.addSeries('candlestick', { upColor: 'rgba(0, 0, 0, 0)', // hollow up candles borderVisible: true, priceLineStyle: 'dotted', }); const average = chart.addSeries('line', { color: '#f5b83d', lineType: 'step', lineStyle: 'dashed' }); return () => { chart.removeSeries(average); chart.removeSeries(candles); }; }, [chart]);
return <LumenChart ref={setChart} options={options} style={{ height: 420 }} />;}<script setup lang="ts">import { LumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/vue';import { computed, onMounted, useTemplateRef } from 'vue';
const props = withDefaults(defineProps<{ textColor?: string }>(), { textColor: '#8a93a6' });const chartEl = useTemplateRef<{ chart: ChartApi | null }>('chartEl');
// Reactive options are forwarded to chart.applyOptions() automatically.const options = computed<DeepPartial<ChartOptions>>(() => ({ theme: 'auto', grid: { vertLines: { visible: false }, horzLines: { style: 'dashed' } }, crosshair: { mode: 'magnet' }, priceScale: { position: 'left', scaleMargins: { top: 0.1, bottom: 0.2 } }, watermark: { visible: true, text: 'BTCUSD · 1m' }, layout: { textColor: props.textColor },}));
onMounted(() => { const chart = chartEl.value?.chart; if (!chart) return; chart.addSeries('candlestick', { upColor: 'rgba(0, 0, 0, 0)', // hollow up candles borderVisible: true, priceLineStyle: 'dotted', }); chart.addSeries('line', { color: '#f5b83d', lineType: 'step', lineStyle: 'dashed' });});</script>
<template> <LumenChart ref="chartEl" :options="options" style="height: 420px" /></template><script lang="ts"> import { lumenChart, type ChartApi, type ChartOptions, type DeepPartial } from '@lumen-ticks/svelte';
let { textColor = '#8a93a6' }: { textColor?: string } = $props();
const options = $derived<DeepPartial<ChartOptions>>({ theme: 'auto', grid: { vertLines: { visible: false }, horzLines: { style: 'dashed' } }, crosshair: { mode: 'magnet' }, priceScale: { position: 'left', scaleMargins: { top: 0.1, bottom: 0.2 } }, watermark: { visible: true, text: 'BTCUSD · 1m' }, layout: { textColor }, });
function onReady(chart: ChartApi) { chart.addSeries('candlestick', { upColor: 'rgba(0, 0, 0, 0)', // hollow up candles borderVisible: true, priceLineStyle: 'dotted', }); chart.addSeries('line', { color: '#f5b83d', lineType: 'step', lineStyle: 'dashed' }); }</script>
<div style="height: 420px" use:lumenChart={{ options, onReady }}></div>import { LumenChart, type ChartApi } from '@lumen-ticks/solid';
export function ThemedChart(props: { textColor?: string }) { const handleReady = (chart: ChartApi) => { chart.addSeries('candlestick', { upColor: 'rgba(0, 0, 0, 0)', // hollow up candles borderVisible: true, priceLineStyle: 'dotted', }); chart.addSeries('line', { color: '#f5b83d', lineType: 'step', lineStyle: 'dashed' }); };
return ( <LumenChart class="chart-box" options={{ theme: 'auto', grid: { vertLines: { visible: false }, horzLines: { style: 'dashed' } }, crosshair: { mode: 'magnet' }, priceScale: { position: 'left', scaleMargins: { top: 0.1, bottom: 0.2 } }, watermark: { visible: true, text: 'BTCUSD · 1m' }, layout: { textColor: props.textColor ?? '#8a93a6' }, }} onReady={handleReady} /> );}A theme sets only colors. Colors you set yourself take precedence and survive a theme change, so
applyOptions({ theme: 'dark' }) flips the chart while keeping, say, a custom grid color. The
presets are exported as themes for building your own. Every option and its default is documented
in ChartOptions, PriceScaleOptions, CandlestickOptions, LineOptions and HistogramOptions.
Redrawing on ticks
Section titled “Redrawing on ticks”const chart = createChart(element, { redraw: 'full' }); // default: 'auto'chart.applyOptions({ redraw: 'auto' });import { LumenChart } from '@lumen-ticks/react';import { useMemo } from 'react';
export function SoftwareSafeChart({ redraw = 'full' }: { redraw?: 'auto' | 'full' }) { const options = useMemo(() => ({ redraw }), [redraw]); return <LumenChart options={options} style={{ height: 420 }} />;}<script setup lang="ts">import { LumenChart } from '@lumen-ticks/vue';import { computed } from 'vue';
const props = withDefaults(defineProps<{ redraw?: 'auto' | 'full' }>(), { redraw: 'full' });const options = computed(() => ({ redraw: props.redraw }));</script>
<template> <LumenChart :options="options" style="height: 420px" /></template><script lang="ts"> import { lumenChart } from '@lumen-ticks/svelte';
let { redraw = 'full' }: { redraw?: 'auto' | 'full' } = $props();</script>
<div style="height: 420px" use:lumenChart={{ options: { redraw } }}></div>import { LumenChart } from '@lumen-ticks/solid';
export function SoftwareSafeChart(props: { redraw?: 'auto' | 'full' }) { return <LumenChart class="chart-box" options={{ redraw: props.redraw ?? 'full' }} />;}A frame drawn for new data alone, with the view, the price scales and every option as they were,
redraws only the pixel columns the data changed (redraw: 'auto'). Where the browser rasterizes the
canvas on the GPU, which is the default, the result is the full redraw’s, pixel for pixel, dashed
and dotted lines included.
Set redraw: 'full' on pages whose canvases are rasterized in software: a browser without GPU
rasterization (a blocklisted driver, a virtual machine, --disable-gpu), or a page that creates 2D
contexts with willReadFrequently. A software rasterizer antialiases a line by its whole path, so
there a frame that redraws some columns differs from a full redraw in a few antialiased pixels
along the lines; the differences do not add up from frame to frame. With full every such frame
draws the whole series layer,
as a frame that pans or zooms does, at that cost: with 20 indicators over a million bars in view,
about 4 ms of JavaScript a frame instead of 0.5 ms. The chart does not detect the rasterizer itself:
nothing a page can ask tells how its 2D canvases are rasterized without reading one back, and reading
a canvas back is what makes a browser rasterize it in software.