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.
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.
pnpm add @tanstack/charts@1.5.0Days
Press Tab and use the arrow keys: all four prices are read.
Price of gold
- Rising
- Falling
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
<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
<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
<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
<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
<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.
<ui-candlestick-chart
label="Open a day"
[rows]="days"
x="date"
(rowSelect)="open($event)"
/>Loading
Keeps its place while the rows arrive.
Loading
Loading
<ui-candlestick-chart
label="Loading"
[rows]="none"
x="date"
loading
[height]="160"
/>Nothing yet
Says so in words.
Nothing yet
Nothing to show yet
<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
<ui-candlestick-chart
dir="rtl"
label="سعر الذهب"
[rows]="week"
x="date"
locale="ar-EG"
/>When to use something else
| If you need | Use |
|---|---|
| Only the closing price | Line chart |
| How values spread in groups | Box plot |
| Exact values to read and sort | Data table |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
label | string | — | Required. Names the chart, above it and for screen readers. |
rows | object[] | — | Required. The data. |
x | string | — | Required. The row field along the bottom: a Date or text. |
open | string | 'open' | The row field with the price at the start. |
high | string | 'high' | With the highest price. |
low | string | 'low' | With the lowest price. |
close | string | 'close' | With the price at the end. |
average | number | — | A line through the average of this many closing prices. |
references | ChartReference[] | [] | Named levels: value and label. |
xLabel | string | — | Names the bottom axis, and the first table column. |
yLabel | string | — | Names the side axis. |
formatX | (x) => string | — | Writes a day. |
formatY | (y: number) => string | — | Writes a price. |
description | string | — | A line of text under the name. |
hideLabel | boolean | false | Keeps the name for screen readers only. |
height | number | 280 | In pixels. The width follows the box around it. |
legend | boolean | — | Shows the names and their colours. |
table | boolean | true | The button that shows the numbers as a table. |
loading | boolean | false | Shows that the rows are on their way. |
emptyMessage | string | — | The words when there is nothing to draw. |
locale | string | — | 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
| Keys | What 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.