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

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.

Use it in Angular
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.

Terminal
pnpm add @tanstack/charts@1.5.0

Groups

One row per value; the chart finds the boxes. Press Tab and use the arrow keys.

Delivery times by branch
Angular
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
Angular
<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
Angular
<ui-box-chart
  label="Delivery times, without far values"
  [rows]="times"
  group="branch"
  value="minutes"
  [outliers]="false"
/>

Your own range

Delivery times, from zero
Angular
<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
Angular
<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.

Angular
<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

Angular
<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

Angular
<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.

أوقات التوصيل حسب الفرع
Angular
<ui-box-chart
  dir="rtl"
  label="أوقات التوصيل حسب الفرع"
  [rows]="timesArabic"
  group="branch"
  value="minutes"
  locale="ar-EG"
/>

When to use something else

If you needUse
One list of valuesHistogram
One amount for each groupBar chart
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.
groupstring — Required. The row field with the group.
valuestring — Required. The row field with the number.
outliersbooleantrueA ring for each value far from the rest.
highlightstring — The group to bring forward; the others turn grey.
xLabelstring — Names the axis of groups, and the first table column.
yLabelstring — Names the axis of values.
yMinnumber — Where the values start.
yMaxnumber — Where the values end.
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.
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 five numbers of each box are announced together.