Charts - Candlestick & OHLC
Financial OHLC chart showing open, high, low, and close prices per time period. Supports candlestick, hollow, and OHLC bar variants.
#Usage
import {
ChartAnnotation,
ChartCandlestick,
ChartCanvas,
ChartCaption,
ChartExportMenu,
ChartHover,
ChartItem,
ChartNavigator,
ChartReferenceBand,
ChartReferenceLine,
ChartSvg,
ChartTitle,
ChartTooltip,
ChartXAxis,
ChartYAxis,
ChartZoom
} from '@primeui/vue-chart';<ChartSvg>
<ChartCandlestick :data="data" category-x-field="date" open-field="openField" high-field="highField" low-field="lowField" close-field="closeField" />
<ChartXAxis />
<ChartYAxis />
</ChartSvg>Candlestick and OHLC charts visualize price movement over time. Each mark encodes open, high, low, and close for a time period. Positive marks rise (close > open), negative marks fall. Set variant to "ohlc" for tick-based bars or "hollow" for hollow candlestick bodies.
#Basic
Map data fields with categoryXField, openField, highField, lowField, and closeField. Positive candles rise (close > open), negative candles fall (close < open).
#OHLC Bars
Set variant="ohlc" to render tick-based bars instead of filled bodies. Each bar shows a vertical line spanning the high-low range with a left tick for the open price and a right tick for the close price. This is a compact representation common in financial charting.
#Hollow
Set variant="hollow" for a style where bullish candles render as stroke-only outlines while bearish candles remain solid. In hollow mode, color is determined by close relative to the previous candle's close rather than the candle's own open. Positive color means price closed higher than the last close; negative color means lower.
#Colors
Set upColor, downColor, and neutralColor to customize candle colors. upColor applies when price rose, downColor when it fell, and neutralColor for doji candles where open equals close. This sample uses a teal and periwinkle pair to show that direction colors can follow a product palette instead of the usual market convention.
#Candle Styling
Set barWidthRatio to control how much of the available category space each candle body fills. 0.7 uses 70% of the space, leaving gaps between candles. Set wickStrokeWidth to adjust the wick line thickness in pixels.
#Declarative
Define candles inline using ChartItem instead of a data array. Each ChartItem accepts open, high, low, close, and category-x for the time period.
#Title & Caption
Add ChartTitle to display a title above the chart and ChartCaption for a descriptive line beneath it. Both reduce the chart area height together.
For full configuration see Title & Caption.
#Hover
Add ChartHover to brighten the hovered candle while non-hovered candles stay at normal opacity. Set dimOpacity below 1 when you want the rest to fade.
For full configuration see Hover.
#Tooltip
Add ChartTooltip to show OHLC details on hover. The tooltip renders open, high, low, and close values in a structured layout with no extra configuration. Use the render prop for custom tooltip content.
For full configuration see Tooltip.
#Axes
Set type="time" on ChartXAxis for continuous date and timestamp data. Tick labels format based on the visible range from minutes up to years. Use type="logarithmic" on ChartYAxis for long-term price data that spans multiple orders of magnitude.
For full configuration see Axes.
#Data Labels
Add ChartDataLabels to print a value above each candle. By default the label shows the close. Set formatter to build custom text; the callback receives the close, the percentage, the category, and the row datum, so a field such as the high or low can drive the label. Set display to value, percentage, or both, though percentage is rarely meaningful for prices. Labels sit clear of the high wick and auto-hide on candles too narrow to fit the text.
For full configuration see Data Labels.
#Zoom & Navigator
Add ChartZoom to enable drag-to-zoom on the time axis and ChartNavigator to show a mini overview chart below. The navigator uses the close price for its mini chart.
For full configuration see Zoom & Pan and Navigator.
#Annotation
Use ChartAnnotation to render custom content overlaid on the chart area. The render callback receives chartArea, center, xScale, yScale, textColor, isDark, and ctx (Canvas mode only). Use xScale to position event markers at specific dates, such as earnings releases, splits, and news events. On multi-axis charts use getScale('y2') to position against a secondary axis by its ID. In SVG mode return a VNode. In Canvas mode draw to ctx and return null.
For full configuration see Annotation.
#Reference Lines & Bands
Add ChartReferenceLine to mark price levels such as support, resistance, and moving averages. Add ChartReferenceBand to highlight consolidation zones and trading ranges. Set y for horizontal price levels, x for vertical time markers.
For full configuration see Reference Lines & Bands.
#Animation
Pass the chart-root animation prop (<ChartSvg> / <ChartCanvas>) to control entrance and update transitions. Candles grow from zero height on entrance.
For full configuration see Animation.
#Export
Add ChartExportMenu to let users download the chart as PNG, SVG, or PDF.
See Export for format options and programmatic export.
#Responsive
See Responsive for container sizing, aspect ratio, and breakpoint configuration.
#Accessibility
See Accessibility for ARIA labels, keyboard navigation, and screen reader support.
#API
#ChartCandlestick
Visual styling props with type accessor → R accept a static value, a per-candle array, a field name (keyof T), or a callback (ctx: ItemContext<T>) => R | undefined. Color-family arrays cycle modulo length; other accessor arrays clip and fall back to the series default.
| Prop | Type | Default | Description |
|---|---|---|---|
data | T[] | - | Data array. Mutually exclusive with ChartItem children |
categoryXField | accessor → string | - | Category or date field for the X axis. Use categoryYField for horizontal candlesticks |
openField | accessor → number | 'open' | Opening price field |
highField | accessor → number | 'high' | Highest price field |
lowField | accessor → number | 'low' | Lowest price field |
closeField | accessor → number | 'close' | Closing price field |
variant | 'candlestick' | 'hollow' | 'ohlc' | 'candlestick' | Visual rendering style |
color | accessor → FillValue | - | Per-candle color override. When set, overrides the direction color (upColor/downColor) for that candle. Accepts a field name, static value, or callback |
upColor | FillValue | theme | Candle color when price rose (direction-keyed, series-level). In hollow mode, when close > previous close |
downColor | FillValue | theme | Candle color when price fell (direction-keyed, series-level). In hollow mode, when close < previous close |
neutralColor | FillValue | theme | Candle color for doji (open === close) |
hoverColor | accessor → FillValue | - | Per-candle fill color on hover. Overrides the global ChartHover.brightness cascade for this series |
hoverBorderColor | accessor → FillValue | - | Per-candle border color on hover |
borderColor | accessor → FillValue | - | Candle body border color |
borderStrokeWidth | accessor → number | 1 | Candle body border stroke width (px) |
borderDash | accessor → number[] | - | Candle body border dash pattern. Also accepts named shortcuts |
borderDashOffset | accessor → number | 0 | Offset into the border dash pattern |
borderRadius | accessor → BorderRadius | 0 | Candle body corner radius |
borderAlign | 'center' | 'inner' | 'center' | Border alignment relative to the candle body edge |
borderJoinStyle | 'round' | 'bevel' | 'miter' | 'miter' | How border segments connect at candle body corners |
borderUpColor | FillValue | - | Border color override when price rose (direction-keyed, series-level) |
borderDownColor | FillValue | - | Border color override when price fell (direction-keyed, series-level) |
borderNeutralColor | FillValue | - | Border color override for doji (direction-keyed, series-level) |
barWidthRatio | 0–1 | 0.7 | Candle body width as a fraction of available category space |
wickStrokeWidth | accessor → number | 1 | Wick and shadow line thickness (px). Per-candle via array/callback/field-name |
name | string | - | Series name, used in tooltip |
id | string | auto | Unique dataset identifier |
xAxisId | string | - | Bind to a specific X-axis by ID |
yAxisId | string | - | Bind to a specific Y-axis by ID |
order | number | auto | Rendering z-order |
#ItemContext
Passed to every accessor → R callback. Return undefined to fall back to the series-level default for that candle.
| Field | Type | Description |
|---|---|---|
datum | T | Original data row |
value | number | null | Resolved numeric value (when applicable) |
index | number | Candle position within the dataset |
seriesIndex | number | Order of this dataset within the chart |
seriesId | string | Dataset id |
#Variant Behavior
Per-candle color overrides the direction color for that specific candle across all variants.
| Variant | Body | Wick | Color Logic |
|---|---|---|---|
candlestick | Filled rectangle | High → Low line | close > open → upColor, close < open → downColor, close === open → neutralColor |
hollow | Stroke-only when bullish, filled when bearish | High → Low line | close > prevClose → upColor, close < prevClose → downColor. First candle falls back to own open/close |
ohlc | None | High → Low line with open tick (left) and close tick (right) | Same as candlestick |
#ChartItem
Use ChartItem as children of ChartCandlestick instead of a data array for inline candle definitions.
| Prop | Type | Description |
|---|---|---|
category-x | string | Time period on the X axis |
category-y | string | Time period on the Y axis for horizontal candlesticks |
open | number | Opening price |
high | number | Highest price |
low | number | Lowest price |
close | number | Closing price |
color | string | Per-candle color override. Overrides the direction color for this candle |