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

Chapter 12 Charts

Heatmap

Where a number is high or low across two lists, such as days and hours. Five steps of one colour, light to dark, with the number in each cell where there is room. One button shows it as a table.

Use it in Angular
import { HeatmapChartComponent } 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 and hours

The number is in each cell, so the colour only repeats it. Press Tab and use the arrow keys.

Orders by day and hour
  • 9 – 16
  • 16 – 22
  • 22 – 28
  • 28 – 34
  • 34+
Angular
const week = [
  { day: 'Sat', hour: '9:00', orders: 12 },
  { day: 'Sat', hour: '11:00', orders: 18 },
];

<ui-heatmap-chart
  label="Orders by day and hour"
  [rows]="week"
  x="hour"
  y="day"
  value="orders"
/>

Without numbers

Defaults to off above 60 cells. The legend gives the range of each step.

Orders by day and hour, colour only
  • 9 – 16
  • 16 – 22
  • 22 – 28
  • 28 – 34
  • 34+
Angular
<ui-heatmap-chart
  label="Orders by day and hour, colour only"
  [rows]="week"
  x="hour"
  y="day"
  value="orders"
  [valueLabels]="false"
/>

Half a year

One cell a day, one column a week.

Orders each day, half a year
  • 0 – 8
  • 8 – 15
  • 15 – 22
  • 22 – 29
  • 29+
Angular
<ui-heatmap-chart
  label="Orders each day, half a year"
  [rows]="year"
  x="week"
  y="day"
  value="orders"
  [height]="240"
  [formatX]="everyFourth"
/>

Branches and months

Your own words for the number.

Share of target by branch
  • 0% – 18%
  • 18% – 36%
  • 36% – 54%
  • 54% – 72%
  • 72%+
Angular
<ui-heatmap-chart
  label="Share of target by branch"
  [rows]="branches"
  x="month"
  y="branch"
  value="share"
  [formatValue]="percent"
  [height]="240"
/>

Your own steps

Where each step starts, when the limits mean something.

Orders, by limits
  • 0 – 10
  • 10 – 20
  • 20 – 30
  • 30+
Angular
<ui-heatmap-chart
  label="Orders, by limits"
  [rows]="week"
  x="hour"
  y="day"
  value="orders"
  [steps]="steps"
/>

Missing cells

An empty cell is missing, never zero.

Orders, with missing hours
  • 9 – 16
  • 16 – 22
  • 22 – 28
  • 28 – 34
  • 34+
Angular
<ui-heatmap-chart
  label="Orders, with missing hours"
  [rows]="gaps"
  x="hour"
  y="day"
  value="orders"
/>

Named axes

Orders, with named axes
  • 9 – 16
  • 16 – 22
  • 22 – 28
  • 28 – 34
  • 34+
Angular
<ui-heatmap-chart
  label="Orders, with named axes"
  [rows]="week"
  x="hour"
  y="day"
  value="orders"
  xLabel="Hour"
  yLabel="Day"
  [height]="340"
/>

Open a cell

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

Orders, open an hour
  • 9 – 16
  • 16 – 22
  • 22 – 28
  • 28 – 34
  • 34+

Nothing picked yet.

Angular
<ui-heatmap-chart
  label="Orders, open an hour"
  [rows]="week"
  x="hour"
  y="day"
  value="orders"
  (rowSelect)="open($event)"
/>

Loading

Keeps its place while the rows arrive.

Orders, loading

Loading

Angular
<ui-heatmap-chart
  label="Orders, loading"
  [rows]="none"
  x="hour"
  y="day"
  value="orders"
  loading
  [height]="160"
/>

Nothing yet

Says so in words.

Orders, none yet

No orders yet

Angular
<ui-heatmap-chart
  label="Orders, none yet"
  [rows]="none"
  x="hour"
  y="day"
  value="orders"
  emptyMessage="No orders yet"
  [height]="160"
/>

In Arabic

The first hour is on the right.

الطلبات حسب اليوم والساعة
  • ٩ – ١٥
  • ١٥ – ٢٠
  • ٢٠ – ٢٥
  • ٢٥ – ٣٠
  • ٣٠+
Angular
<ui-heatmap-chart
  dir="rtl"
  label="الطلبات حسب اليوم والساعة"
  [rows]="weekArabic"
  x="hour"
  y="day"
  value="orders"
  locale="ar-EG"
/>

When to use something else

If you needUse
Exact values to read and sortData table
One list of amountsBar chart
A day to chooseCalendar

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the chart, above it and for screen readers.
rowsobject[] — Required. The data.
xstring — Required. The row field with the column of a cell.
ystring — Required. The row field with its line.
valuestring — Required. The row field with its number.
valueLabelsboolean — Writes the number in each cell. Defaults to on for up to 60 cells.
stepsnumber[] — Where each step starts, up to five. Defaults to five equal steps.
xOrderstring[] — The order of the columns. Defaults to the order they come in.
yOrderstring[] — The order of the lines.
xLabelstring — Names the bottom axis.
yLabelstring — Names the side axis.
formatX(x: string) => string — Writes a column.
formatY(y: string) => string — Writes a line.
formatValue(value: number) => string — Writes a number.
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.
  • The number is written in the cell at 7:1 on its colour, or in the table.