Demo
Financial series
Documented in Chart.
Financial series
Candle, OHLC and high-low series over daily prices, with hollow candles and volume columns in the candle colors.
Candlestick chart: ACME daily prices. No data.
| x | ACME |
|---|---|
| Jan 5 | O 100 H 101.5 L 98.8 C 100 V 1,200 |
| Jan 6 | O 102.98 H 108.45 L 101.28 C 105.95 V 1,577 |
| Jan 7 | O 105.84 H 109.34 L 102.87 C 105.07 V 1,954 |
| Jan 8 | O 108.45 H 109.95 L 102.98 C 105.68 V 1,431 |
| Jan 9 | O 110.73 H 114.71 L 109.53 C 112.21 V 1,808 |
| Jan 10 | O 107.59 H 113.49 L 105.89 C 109.99 V 1,285 |
| Jan 11 | O 108.98 H 110.48 L 104.68 C 106.88 V 1,662 |
| Jan 12 | O 109.87 H 112.37 L 105.32 C 108.02 V 2,039 |
| Jan 13 | O 110.27 H 116.35 L 109.07 C 112.85 V 1,516 |
| Jan 14 | O 110.22 H 112.91 L 108.52 C 111.41 V 1,893 |
| Jan 15 | O 104.79 H 107.29 L 99.7 C 101.9 V 1,370 |
| Jan 16 | O 104.05 H 107.55 L 100.91 C 103.61 V 1,747 |
| Jan 17 | O 103.13 H 107.63 L 101.93 C 106.13 V 1,224 |
| Jan 18 | O 102.13 H 104.63 L 100.11 C 101.81 V 1,601 |
| Jan 19 | O 101.19 H 104.69 L 96.08 C 98.28 V 1,978 |
| Jan 20 | O 95.43 H 98 L 92.73 C 96.5 V 1,455 |
| Jan 21 | O 94.95 H 100.08 L 93.75 C 97.58 V 1,832 |
| Jan 22 | O 94.84 H 98.34 L 91.38 C 93.08 V 1,309 |
| Jan 23 | O 95.18 H 96.68 L 90.79 C 92.99 V 1,686 |
| Jan 24 | O 96.01 H 100.83 L 93.31 C 98.33 V 2,063 |
| Jan 25 | O 92.33 H 97.42 L 91.13 C 93.92 V 1,540 |
| Jan 26 | O 94.13 H 95.63 L 89.7 C 91.4 V 1,917 |
| Jan 27 | O 96.36 H 98.86 L 93.27 C 95.47 V 1,394 |
| Jan 28 | O 98.93 H 105.39 L 96.23 C 101.89 V 1,771 |
| Jan 29 | O 101.76 H 103.39 L 100.56 C 101.89 V 1,248 |
| Jan 30 | O 99.73 H 102.23 L 95.05 C 96.75 V 1,625 |
| Jan 31 | O 102.72 H 106.87 L 100.52 C 103.37 V 2,002 |
| Feb 1 | O 105.6 H 109.92 L 102.9 C 108.42 V 1,479 |
| Feb 2 | O 108.26 H 110.76 L 105.68 C 106.88 V 1,856 |
| Feb 3 | O 110.58 H 114.08 L 106.42 C 108.12 V 1,333 |
Demo.tsx
'use client';
import { useState } from 'react';
import { Checkbox } from '@salmonui/inputs/checkbox';
import { Select } from '@salmonui/dropdowns/select';
import { Chart } from '@salmonui/charts/chart';
// 30 trading days of deterministic prices (UTC dates, so server and client agree).
const prices = Array.from({ length: 30 }, (_, i) => {
const open = 100 + 8 * Math.sin(i / 4) + (i % 5);
const close = open + 3 * Math.sin(i * 1.7);
return {
date: new Date(Date.UTC(2026, 0, 5 + i)),
open: Math.round(open * 100) / 100,
close: Math.round(close * 100) / 100,
high: Math.round((Math.max(open, close) + 1.5 + (i % 3)) * 100) / 100,
low: Math.round((Math.min(open, close) - 1.2 - (i % 4) * 0.5) * 100) / 100,
volume: 1200 + ((i * 377) % 900),
};
});
type Kind = 'candle' | 'ohlc' | 'hilo';
export default function ChartFinancialDemo() {
const [type, setType] = useState<Kind>('candle');
const [hollow, setHollow] = useState(false);
const [volume, setVolume] = useState(true);
return (
<div className="demo-stack">
<div className="demo-toolbar">
<label>
Series type
<Select aria-label="Series type" data={[{ value: 'candle', label: 'candle' }, { value: 'ohlc', label: 'ohlc' }, { value: 'hilo', label: 'hilo' }]} value={type} onValueChange={(value) => value != null && setType(value as Kind)} />
</label>
<Checkbox checked={hollow} onCheckedChange={(checked) => setHollow(checked)} disabled={type !== 'candle'}>Hollow candles</Checkbox>
<Checkbox checked={volume} onCheckedChange={(checked) => setVolume(checked)} disabled={type !== 'candle'}>Volume</Checkbox>
</div>
<Chart
title="ACME daily prices"
data={prices}
height={340}
timeZone="UTC"
locale="en-US"
xAxis={{ format: 'MMMd' }}
yAxis={{ format: 'c0' }}
tooltip
series={[
{
type,
name: 'ACME',
xField: 'date',
openField: 'open',
highField: 'high',
lowField: 'low',
closeField: 'close',
hollow,
volumeField: type === 'candle' && volume ? 'volume' : undefined,
},
]}
/>
</div>
);
}
One series reads openField, highField, lowField and closeField;
switch its type between 'candle', 'ohlc' and 'hilo'. Candles use
the success / danger seeds for up and down days, hollow draws rising
candles as outlines, and volumeField adds volume columns in the bottom
fifth of the plot (also listed in the tooltip).