Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 12 Charts

Candlestick chart

Where a price opened and closed, and how far it went, each day. A rising day is hollow and a falling one filled, so colour only repeats it. One button shows the four prices as a table.

Use it in Angular
import { CandlestickChartComponent } from '@okaapi-ui/angular/charts';

Add charts to your app

Charts have their own import, so apps without charts download nothing. They draw with TanStack Charts, installed next to the kit.

Terminal
pnpm add @tanstack/charts@1.5.0

Days

Press Tab and use the arrow keys: all four prices are read.

Price of gold
  • Rising
  • Falling
Angular
const days = [
  { date: new Date('2026-11-01'), open: 100, high: 108, low: 96, close: 105 },
];

<ui-candlestick-chart label="Price of gold" [rows]="days" x="date" />

A week

Price of gold, one week
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  label="Price of gold, one week"
  [rows]="week"
  x="date"
/>

An average

A line through the average of the last five closing prices.

Price of gold, with the average
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  label="Price of gold, with the average"
  [rows]="days"
  x="date"
  [average]="5"
/>

A limit

A named level.

Price of gold and the limit
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  label="Price of gold and the limit"
  [rows]="days"
  x="date"
  [references]="limit"
/>

Your own fields

When the rows have other names for the prices.

Price of gold, other fields
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  label="Price of gold, other fields"
  [rows]="rates"
  x="date"
  open="o"
  high="h"
  low="l"
  close="c"
/>

Named axes and formats

Price of gold, named
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  label="Price of gold, named"
  [rows]="days"
  x="date"
  xLabel="Day"
  yLabel="Price"
  [formatY]="pounds"
/>

Open a day

Click a day, or press Enter on it, to use its row.

Open a day
  • Rising
  • Falling

Nothing picked yet.

Angular
<ui-candlestick-chart
  label="Open a day"
  [rows]="days"
  x="date"
  (rowSelect)="open($event)"
/>

Loading

Keeps its place while the rows arrive.

Loading

Loading

Angular
<ui-candlestick-chart
  label="Loading"
  [rows]="none"
  x="date"
  loading
  [height]="160"
/>

Nothing yet

Says so in words.

Nothing yet

Nothing to show yet

Angular
<ui-candlestick-chart
  label="Nothing yet"
  [rows]="none"
  x="date"
  emptyMessage="Nothing to show yet"
  [height]="160"
/>

In Arabic

Time runs from right to left.

سعر الذهب
  • Rising
  • Falling
Angular
<ui-candlestick-chart
  dir="rtl"
  label="سعر الذهب"
  [rows]="week"
  x="date"
  locale="ar-EG"
/>

When to use something else

If you needUse
Only the closing priceLine chart
How values spread in groupsBox plot
Exact values to read and sortData table

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the chart, above it and for screen readers.
rowsobject[] — Required. The data.
xstring — Required. The row field along the bottom: a Date or text.
openstring'open'The row field with the price at the start.
highstring'high'With the highest price.
lowstring'low'With the lowest price.
closestring'close'With the price at the end.
averagenumber — A line through the average of this many closing prices.
referencesChartReference[][]Named levels: value and label.
xLabelstring — Names the bottom axis, and the first table column.
yLabelstring — Names the side axis.
formatX(x) => string — Writes a day.
formatY(y: number) => string — Writes a price.
descriptionstring — A line of text under the name.
hideLabelbooleanfalseKeeps the name for screen readers only.
heightnumber280In pixels. The width follows the box around it.
legendboolean — Shows the names and their colours.
tablebooleantrueThe button that shows the numbers as a table.
loadingbooleanfalseShows that the rows are on their way.
emptyMessagestring — The words when there is nothing to draw.
localestring — For numbers and dates. Defaults to the language of the page.
dir'ltr' | 'rtl' — Defaults to the direction of the page around it.
[(hidden)]string[][]Keys of the parts that are off.
(rowSelect)row — The row under a click, Enter or Space.

Keyboard and screen readers

KeysWhat they do
Tab Reach the chart, then its next control.
Arrow keys Move to the next or previous value.
Home or End Go to the first or last value.
Enter or Space Pin the value, and open its row if the page uses it.
Escape Unpin the value.
  • A named graphic. Each value is announced as you reach it.
  • The same numbers are always there as a real table.
  • Rising days are hollow and falling days filled, as well as two colours.