ComponentAdded in v15.1

Candlestick Chart

Prices over time (OHLC): a candle per period, its wick from the low to the high and its body from the open to the close.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrCandlestickChart } from 'ngwr/charts/candlestick-chart';

@Component({ imports: [WrCandlestickChart] })
export class MyComponent {}

Basic

One candle per period, evenly spaced. The y axis fits the lows and highs and is not forced to zero.

<wr-candlestick-chart ariaLabel="ACME, daily" [data]="days" />
days: WrCandlestickDatum[] = [
  { label: 'Jan 2', open: 120.4, high: 122.9, low: 119.8, close: 122.1 },
  { label: 'Jan 5', open: 122.3, high: 123.0, low: 118.6, close: 119.2 },
  // …
];

Up and down

A rising candle is hollow, a falling one filled, so the fill tells them apart without colour. increaseColor and decreaseColor swap the colours for a market that draws rises in red. The fill stays.

<wr-candlestick-chart
  [data]="days"
  increaseColor="var(--wr-color-danger)"
  decreaseColor="var(--wr-color-success)"
/>

Many candles

Bodies narrow with the room they have. Under 4px a rising body is dotted rather than hollow. The labels thin out to what fits.

<wr-candlestick-chart ariaLabel="ACME, 2026" [data]="year" />

Number format

Prices follow LOCALE_ID. valueFormat replaces it for the ticks, the tooltip and the data table.

<wr-candlestick-chart [data]="days" [valueFormat]="format" />
const usd = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });

format = (value: number): string => usd.format(value);

Data table

dataTable renders every price as a table only screen readers reach: a row per period. Nothing changes on screen.

<wr-candlestick-chart ariaLabel="ACME, daily" dataTable [data]="days" />
ACME, daily, with a table
OpenHighLowClose
Jan 2120.19120.91118.34118.91
Jan 5119.33122.11117.57120.8
Jan 6121.31121.33118.46119.03
Jan 7118.9121.16118.22119.41
Jan 8119.87122.57119.47122.01
Jan 9121.9124.28121.56124.05
Jan 12124.31127.71122.92126.23
Jan 13125.73127.21124.74127.11
Jan 14127.48128.21125.5125.76
Jan 15126126.09125.61125.73
Jan 16125.2126.43123.21123.66
Jan 19123.46124.68123.05124
Jan 20124.27124.56120.97122.54
Jan 21122.5125.82121.97124.58
Jan 22124.35126.6123.05126.02
Jan 23126.45126.49124.69125.66
Jan 26126.02126.42123.71125.22
Jan 27125.18126123.32123.71
Jan 28123.17126.15122.29124.98
Jan 29125.34126.02122.99123.2

Accessibility

PartBehaviour
PlotOne role="img", named by ariaLabel. No tab stop.
PricesOnly in the tooltip, unless dataTable is on.
Up and down Told apart by fill as well as colour: hollow or dotted up, filled down. Every body is drawn tall enough to show its fill, even when the price barely moved.
TooltipPointer only. Escape closes it.
Forced coloursCandles keep their colours and their fill.

Very many candles

Past one candle per pixel the candles overlap. Aggregate the periods first: weeks instead of days.

API

NameDescriptionTypeDefault
dataThe periods, oldest first: one evenly spaced slot each. A period whose four prices are not all finite keeps its slot and its label, and draws no candle.readonly WrCandlestickDatum[][]
ariaLabelAccessible name of the chart. The prices are nowhere in text unless dataTable puts them there, so say what the chart shows: the instrument and the period. Falls back to candlestickChart.label ("Candlestick chart"). It is also the data table's caption.string | nullnull
increaseColorThe colour of a rising candle, any CSS colour. null keeps --wr-candlestick-chart-increase-color, which is var(--wr-color-success). A rising candle is hollow whatever its colour.string | nullnull
decreaseColorThe colour of a falling candle, any CSS colour. null keeps --wr-candlestick-chart-decrease-color, which is var(--wr-color-danger). A falling candle is filled whatever its colour.string | nullnull
valueFormatWrites every price the chart shows: the y-axis ticks, the tooltip and the data table. null uses Intl.NumberFormat in LOCALE_ID: compact ticks (1.2K) unless the full numbers are shorter, and in the tooltip and the table every price at the data's own precision — as many fraction digits as the most precise price given, up to ten, and never fewer than the axis step needs — so a forex quote of 1.08345 is not written 1.083.((value: number) => string) | nullnull
heightThe plot's height in px, at least 80.number240
showGridShow the gridlines and the y-axis ticks. The period labels under the candles are the time axis, so they stay either way, as the line chart's xLabels do.booleantrue
tooltipShow a tooltip with the period's open, high, low and close under the pointer. Pointer only.booleantrue
dataTableRender every period's prices as a table only assistive technology reaches, beside the drawing: a row per period, headed by its label, and a column each for the open, the high, the low and the close. A price that is not a finite number is an empty cell. The drawing is one named image, so without it the prices are nowhere a screen reader can walk.booleanfalse

Types

interface WrCandlestickDatum {
  label: string;
  open: number;
  high: number;
  low: number;
  close: number;
}
NameDescriptionTypeDefault
WrCandlestickDatumOne period and its four prices.interface—
labelrequiredThe period, as text. Printed under the candle when there is room.string—
openrequiredThe first price: one end of the body.number—
highrequiredThe highest price: the top of the wick.number—
lowrequiredThe lowest price: the bottom of the wick.number—
closerequiredThe last price. At or above open the candle is rising.number—

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/charts/candlestick-chart's own element.

VariableDefaultDeclared on
--wr-candlestick-chart-body-border-width1px.wr-candlestick-chart
--wr-candlestick-chart-body-max-width1.5rem.wr-candlestick-chart
--wr-candlestick-chart-colorvar(--wr-color-on-surface).wr-candlestick-chart
--wr-candlestick-chart-cursor-bgvar(--wr-color-hover).wr-candlestick-chart
--wr-candlestick-chart-decrease-colorvar(--wr-color-danger).wr-candlestick-chart
--wr-candlestick-chart-font-familyvar(--wr-font-family-base).wr-candlestick-chart
--wr-candlestick-chart-grid-colorcolor-mix(in srgb, var(--wr-border-base) 70%, transparent).wr-candlestick-chart +1 variant override
--wr-candlestick-chart-increase-colorvar(--wr-color-success).wr-candlestick-chart
--wr-candlestick-chart-plot-inset-yvar(--wr-space-sm).wr-candlestick-chart
--wr-candlestick-chart-tick-colorvar(--wr-color-on-surface-muted).wr-candlestick-chart
--wr-candlestick-chart-tick-font-sizevar(--wr-text-xs).wr-candlestick-chart
--wr-candlestick-chart-tick-gapvar(--wr-space-xs).wr-candlestick-chart
--wr-candlestick-chart-tick-line-heightvar(--wr-text-xs-leading).wr-candlestick-chart
--wr-candlestick-chart-wick-width1px.wr-candlestick-chart

Dependencies

Built onPopover

See also