Chapter 12 Charts
Box plot
How values spread in each group. The box is the middle half, the thick line the median, the thin lines the rest, and a ring each value far from it. One button shows every number as a table.
import { BoxChartComponent } 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.0Groups
One row per value; the chart finds the boxes. Press Tab and use the arrow keys.
Delivery times by branch
const times = [
{ branch: 'Cairo', minutes: 24 },
{ branch: 'Giza', minutes: 31 },
];
<ui-box-chart
label="Delivery times by branch"
[rows]="times"
group="branch"
value="minutes"
/>One group against the rest
highlight takes its name.
Delivery times, Giza
<ui-box-chart
label="Delivery times, Giza"
[rows]="times"
group="branch"
value="minutes"
highlight="Giza"
/>Without far values
They stay in the table.
Delivery times, without far values
<ui-box-chart
label="Delivery times, without far values"
[rows]="times"
group="branch"
value="minutes"
[outliers]="false"
/>Your own range
Delivery times, from zero
<ui-box-chart
label="Delivery times, from zero"
[rows]="times"
group="branch"
value="minutes"
[yMin]="0"
[yMax]="90"
/>Named axes and formats
Delivery times, named
<ui-box-chart
label="Delivery times, named"
[rows]="times"
group="branch"
value="minutes"
xLabel="Branch"
yLabel="Minutes"
[formatValue]="minutes"
/>Open a group
Click a box, or press Enter on it. The row has the group and its values.
Open a branch
Nothing picked yet.
<ui-box-chart
label="Open a branch"
[rows]="times"
group="branch"
value="minutes"
(rowSelect)="open($event)"
/>Loading
Keeps its place while the rows arrive.
Loading
Loading
<ui-box-chart
label="Loading"
[rows]="none"
group="branch"
value="minutes"
loading
[height]="160"
/>Nothing yet
Says so in words.
Nothing yet
Nothing to show yet
<ui-box-chart
label="Nothing yet"
[rows]="none"
group="branch"
value="minutes"
emptyMessage="Nothing to show yet"
[height]="160"
/>In Arabic
The first group is on the right.
أوقات التوصيل حسب الفرع
<ui-box-chart
dir="rtl"
label="أوقات التوصيل حسب الفرع"
[rows]="timesArabic"
group="branch"
value="minutes"
locale="ar-EG"
/>When to use something else
| If you need | Use |
|---|---|
| One list of values | Histogram |
| One amount for each group | Bar chart |
| 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. |
group | string | — | Required. The row field with the group. |
value | string | — | Required. The row field with the number. |
outliers | boolean | true | A ring for each value far from the rest. |
highlight | string | — | The group to bring forward; the others turn grey. |
xLabel | string | — | Names the axis of groups, and the first table column. |
yLabel | string | — | Names the axis of values. |
yMin | number | — | Where the values start. |
yMax | number | — | Where the values end. |
formatValue | (value: number) => string | — | Writes a number. |
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. |
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.
- The five numbers of each box are announced together.