Trend · Advanced
Candlestick chart
Open, high, low and close for each period in one candle.
- Use when
- Stocks, exchange rates or coins, where the swing within each period matters
- Avoid when
- A trend with only one value (a line chart is cleaner)
Try it
32
Candlestick chart
Daily candles of a sample stock (KRW)
- Up
- Down
- 5-day MA
- 20-day MA
Hover over the chart, or Tab in and use the arrow keys to move between items. The numbers are sample data.
Variants
Named looks for this chart. Each one is the example above with a few options or fields changed. The CLI (ztd-charts example candlestick --variant <id>) and the MCP server know the same names.
Candles only
Daily candles of a sample stock (KRW)
- Up
- Down
Drag to zoom
Daily candles of a sample stock (KRW)
- Up
- Down
- 5-day MA
- 20-day MA
Green up, red down
Daily candles of a sample stock (KRW)
- Up
- Down
- 5-day MA
- 20-day MA
Code
CandlestickChart.tsx
import { ChartCard, CandlestickChart } from "ztd-charts";
const data = [
{"date":"2025-09-01","open":60800,"high":60900,"low":59500,"close":59700,"volume":1079936},
{"date":"2025-09-02","open":59700,"high":60300,"low":59600,"close":60300,"volume":1326769},
{"date":"2025-09-03","open":60900,"high":61100,"low":59200,"close":59500,"volume":1430849},
{"date":"2025-09-04","open":60000,"high":60900,"low":59600,"close":60500,"volume":1434116},
{"date":"2025-09-05","open":61000,"high":62400,"low":60600,"close":61500,"volume":1508602},
{"date":"2025-09-08","open":61600,"high":62400,"low":61500,"close":62000,"volume":1176118},
// … 54 more rows
];
export function Example() {
return (
<ChartCard number="32" title="Candlestick chart" subtitle="Daily candles of a sample stock (KRW)" takeaway="Higher highs since mid-October" level="advanced" replay>
<CandlestickChart
data={data}
x="date"
open="open"
high="high"
low="low"
close="close"
volume="volume"
ma={[5,20]}
brush={true}
/>
</ChartCard>
);
}
Props
<CandlestickChart> takes these props. Rows marked Common work the same on every chart.
36 props
| Prop |
|---|
dataRequiredAn array of objects. Pass CSV, REST or database rows as they areobject[] |
xRequiredDate (period) fieldstring | (d, i) => date |
openRequiredOpen price fieldstring | (d, i) => number |
highRequiredHigh price fieldstring | (d, i) => number |
lowRequiredLow price fieldstring | (d, i) => number |
closeRequiredClose price fieldstring | (d, i) => number |
volumeVolume fieldstring | (d, i) => number |
maMoving average periods on the close. For example [5, 20]number[] |
upColorRising candle color (token name or CSS color)stringDefault "accent" |
downColorFalling candle colorstringDefault "neutralStrong" |
maxCandlesAbove this count, neighboring candles merge. Defaults to plot width / 4number |
brushDrag to select a range. true shows the change and the high and low, "zoom" zooms into the range (keyboard: Shift+arrows, Enter)anyDefault false |
yDomainFixed price axis rangenumber[] |
annotationsNotes drawn on the chart: target band, period, reference line, event, forecast, trend line on the close, weekend shading. [{ type, x, y, from, label }]annotations |
dayFirstReads dates such as "05/03/2024", where either part could be the month, day first (5 March). Without it, a clear date in the column decides (25/03/2024), otherwise month first. true also reads "05.03.24" as day.month.yearboolean |
heightCommonHeight in px. Without it, each chart picks a default that fits its widthnumber |
widthCommonFixed width in px. Without it, the chart fits its parentnumber |
highlightCommonItem to highlight. An index, a name, an array, or "max" | "min" | "first" | "last" | "none"number | string | (number|string)[] | "max" … |
formatCommonValue format. "number" | "integer" | "percent" (values are already percents: 42 → "42%") | "ratio" (0.42 → "42%") | "compact" | "currency" (KRW for Korean locales, otherwise USD; for another currency pass Intl options with currency) | "decimal" or Intl.NumberFormat options"number" | "percent" | "compact" | … |
unitCommonUnit appended to values. For example "%" or "ms"string |
localeCommonLocale for numbers, dates and the text a chart writes itself (tooltips, screen reader sentences). "ko" or "ko-*" switches to Korean. Falls back to the ThemeProvider localestringDefault "en-US" |
animateCommonEntry and update animationbooleanDefault true |
durationCommonAnimation length (ms)number |
easingCommonMotion curve"spring" | "easeOut" | "easeInOut" | "linear"Default "spring" |
staggerCommonDelay between items as they enter (ms)number |
reducedMotionCommon"auto" follows the OS setting. true always turns motion offanyDefault "auto" |
animateOnViewCommonPlay when the chart scrolls into viewbooleanDefault true |
showLabelsCommonLabels drawn on the chart (values and names)booleanDefault true |
tooltipCommonShow tooltips. { template: "{label} · {value} · owner {owner}" } writes them: {label}, {value}, {series} or any other column of the row. \n starts a new line, and a line with an empty value is left outtooltipDefault true |
syncIdCommonCharts with the same syncId show the hovered x together (line, area, bar, candlestick). <ChartGrid sync> sets one for every chart inside itstring |
ariaLabelCommonName for screen readersstring |
descriptionCommonDescription for screen readers. Built from the data when omittedstring |
onHoverCommonRuns when hover or keyboard focus moves to another item(e: ChartEvent | null) => void |
onClickCommonRuns on click, Enter or Space(e: ChartEvent) => void |
replayKeyCommonReplays the entry animation when it changesstring | number |
themeCommonChanges theme tokens for this chart onlyPartial<ChartTheme> |
Also in Trend
- Line chartChange over time
- Area chartRunning totals and a changing mix (stacked, 100% stacked)
- StreamgraphMany series as flowing bands that show size and change
- SparklineA small trend line next to a table cell or KPI
- Calendar heatmapDaily amounts on a weekly grid
- Bump chartRank changes over time
- SkylineStacked volume per period as blocks, with a smaller outcome in the same unit standing in front