Chapter 12 Charts
Funnel chart
How many are left after each step: visits, baskets, orders. Every step says its number and its share of the first, so the width only repeats it. One button shows it as a table.
import { FunnelChartComponent } 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.0Steps
In the order they happen. Press Tab and use the arrow keys to read each one.
From visit to order
const visits = [
{ step: 'Visits', people: 4200 },
{ step: 'Baskets', people: 980 },
{ step: 'Orders', people: 420 },
];
<ui-funnel-chart
label="From visit to order"
[rows]="visits"
name="step"
value="people"
/>One step against the rest
highlight takes its name.
Where people stop
<ui-funnel-chart
label="Where people stop"
[rows]="visits"
name="step"
value="people"
highlight="Baskets"
/>Few steps
A steep drop stays readable: the numbers are beside it.
Hiring
<ui-funnel-chart
label="Hiring"
[rows]="hiring"
name="step"
value="people"
[height]="200"
/>Your own formats
From visit to order, short
<ui-funnel-chart
label="From visit to order, short"
[rows]="visits"
name="step"
value="people"
[formatValue]="compact"
nameLabel="Step"
valueLabel="People"
/>Open a step
Click a step, or press Enter on it, to use its row.
Open a step
Nothing picked yet.
<ui-funnel-chart
label="Open a step"
[rows]="visits"
name="step"
value="people"
(rowSelect)="open($event)"
/>Loading
Keeps its place while the rows arrive.
Loading
Loading
<ui-funnel-chart
label="Loading"
[rows]="none"
name="step"
value="people"
loading
[height]="160"
/>Nothing yet
Says so in words.
Nothing yet
Nothing to show yet
<ui-funnel-chart
label="Nothing yet"
[rows]="none"
name="step"
value="people"
emptyMessage="Nothing to show yet"
[height]="160"
/>In Arabic
The names are on the right, the numbers on the left.
من الزيارة إلى الطلب
<ui-funnel-chart
dir="rtl"
label="من الزيارة إلى الطلب"
[rows]="visitsArabic"
name="step"
value="people"
locale="ar-EG"
/>When to use something else
| If you need | Use |
|---|---|
| Amounts that are not steps | Bar chart |
| Steps the reader goes through | Stepper |
| 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. |
name | string | — | Required. The row field with the step's name. |
value | string | — | Required. The row field with its number. |
highlight | string | — | The name of the step to bring forward; the others turn grey. |
formatValue | (value: number) => string | — | Writes a number. |
nameLabel | string | — | Names the first column of the table. |
valueLabel | string | — | Names the second. Defaults to Value. |
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 number and share of each step are written beside it.