Candlestick Chart
Plot open, high, low, and close prices per period, with optional volume and a zoom brush.
Overview
Use a candlestick chart to show how a price moved within each period: where it opened and closed, shown by the body, and how far it ranged, shown by the wick. Rising periods take the up color and falling periods the down color. It suits prices, exchange rates, and any measure with a meaningful open, high, low, and close.
When only the closing value matters, a line chart is easier to read.
Anatomy
CandlestickChart reads four fields per row (open, high, low, and close by default) and owns the category axis, zoom, and loading. Candles draws the bodies and wicks. Volume adds translucent volume bars along the bottom of the same plot, so they line up exactly with their candles; the price scale is lifted so the tallest volume bar never reaches the lowest wick. Add XAxis, YAxis, Grid, Tooltip, and Brush as needed.
The price axis sits on the right by default, as is usual for financial charts, and follows the zoomed window so the visible candles always fill the plot.
Accessibility
Up and down are encoded by color, which some readers cannot tell apart. The hollow variant adds a second cue: rising bodies are open and falling bodies are filled. The default ariaLabel reports the range, the first open, the last close, and the high and low, but readers who need individual periods need a nearby table. The crosshair, tooltip, and brush are pointer-operated.
Installation
Usage
import { CandlestickChart, type ChartConfig } from "honestui/charts";const chartConfig = {
up: { label: "Up", colors: { light: ["#16a34a"], dark: ["#22c55e"] } },
down: { label: "Down", colors: { light: ["#dc2626"], dark: ["#ef4444"] } },
} satisfies ChartConfig;
<CandlestickChart data={data} config={chartConfig} xDataKey="date">
<CandlestickChart.Grid />
<CandlestickChart.XAxis />
<CandlestickChart.YAxis />
<CandlestickChart.Tooltip />
<CandlestickChart.Candles />
</CandlestickChart>Rename the price fields with openDataKey, highDataKey, lowDataKey, and closeDataKey when your data uses other names. The tooltip lists the change with its percentage, then open, high, low, close, and volume. The crosshair labels both axes with the formatted date and price.
Examples
Volume and Brush
Pass volumeDataKey and add CandlestickChart.Volume to draw volume bars in the period's direction color. CandlestickChart.Brush adds a closing-price preview strip; dragging it zooms the candles and volume together. This example also uses the hollow variant.
Zoom and Reference Line
CandlestickChart.Zoom zooms inside the plot: pinch, or scroll with Ctrl held, and drag to pan. The price axis refits to the visible candles, and a Reset zoom button appears while zoomed. It shares its window with the brush. A ReferenceLine marks a support or resistance level; see Brush and Zoom and Reference Lines.
Give the chart a syncId to move its crosshair with other charts over the same dates, such as a combo chart of trading activity below it.
Loading State
isLoading reserves the layout with neutral candles and the shared loading label.
API Reference
CandlestickChart.Zoom takes the props listed in Brush and Zoom. The reference parts take the props listed in Reference Lines; a y value is a price.