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

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.

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

Terminal
pnpm add @tanstack/charts@1.5.0

Steps

In the order they happen. Press Tab and use the arrow keys to read each one.

From visit to order
Angular
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
Angular
<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
Angular
<ui-funnel-chart
  label="Hiring"
  [rows]="hiring"
  name="step"
  value="people"
  [height]="200"
/>

Your own formats

From visit to order, short
Angular
<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.

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

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

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

من الزيارة إلى الطلب
Angular
<ui-funnel-chart
  dir="rtl"
  label="من الزيارة إلى الطلب"
  [rows]="visitsArabic"
  name="step"
  value="people"
  locale="ar-EG"
/>

When to use something else

If you needUse
Amounts that are not stepsBar chart
Steps the reader goes throughStepper
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.
namestring — Required. The row field with the step's name.
valuestring — Required. The row field with its number.
highlightstring — The name of the step to bring forward; the others turn grey.
formatValue(value: number) => string — Writes a number.
nameLabelstring — Names the first column of the table.
valueLabelstring — Names the second. Defaults to Value.
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 number and share of each step are written beside it.