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

Chapter 12 Charts

Gauge chart

One level inside a known range, as a ring. The value is written in the middle and read with the name, so the colour only repeats it. For a list of levels use Meter: it takes less room.

Use it in Angular
import { GaugeChartComponent } 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

A level

Three quarters of a ring, with the ends of the scale.

Delivery score
Angular
<ui-gauge-chart label="Delivery score" [value]="72" />

Half a ring

For a short, wide box.

Delivery score, half
Angular
<ui-gauge-chart
  label="Delivery score, half"
  [value]="72"
  shape="half"
  [height]="220"
/>

A whole ring

For progress towards all of something.

Orders delivered
Angular
<ui-gauge-chart
  label="Orders delivered"
  [value]="86"
  shape="ring"
  valueText="86%"
  tone="success"
/>

Zones

Named parts of the scale. The name of the zone is written under the value.

Delivery score, in zones
  • Low: 0 – 50
  • Fair: 50 – 80
  • Good: 80 – 100
Angular
const zones = [
  { from: 0, to: 50, label: 'Low', tone: 'danger' },
  { from: 50, to: 80, label: 'Fair', tone: 'warning' },
  { from: 80, to: 100, label: 'Good', tone: 'success' },
];

<ui-gauge-chart
  label="Delivery score, in zones"
  [value]="64"
  [zones]="zones"
/>

A target

A mark across the ring.

Delivery score and the target
Angular
const goal = { value: 80, label: 'Target' };

<ui-gauge-chart
  label="Delivery score and the target"
  [value]="64"
  [target]="goal"
/>

Zones and a target

Delivery score, zones and target
  • Low: 0 – 50
  • Fair: 50 – 80
  • Good: 80 – 100
Angular
<ui-gauge-chart
  label="Delivery score, zones and target"
  [value]="91"
  [zones]="zones"
  [target]="goal"
  shape="half"
  [height]="240"
/>

Your own range

Any range and any words.

Storage
Angular
<ui-gauge-chart
  label="Storage"
  [value]="7.2"
  [max]="10"
  valueText="7.2 GB"
  [formatValue]="gigabytes"
  tone="warning"
/>

Tones

You choose the tone from the value: the gauge does not guess.

SMS credit
Angular
<ui-gauge-chart
  label="SMS credit"
  [value]="12"
  tone="danger"
  [height]="220"
/>

Without the ends

Delivery score, plain
Angular
<ui-gauge-chart
  label="Delivery score, plain"
  [value]="72"
  [ends]="false"
  [height]="220"
/>

Side by side

For two or three levels.

Cairo
Giza
Tanta
Angular
<ui-gauge-chart label="Cairo" [value]="91" [height]="180" />

A value that changes

Live score
  • Low: 0 – 50
  • Fair: 50 – 80
  • Good: 80 – 100
Angular
<ui-gauge-chart label="Live score" [value]="score" [zones]="zones" />

Loading

Keeps its place while the value arrives.

Score, loading

Loading

Angular
<ui-gauge-chart label="Score, loading" [value]="0" loading [height]="160" />

In Arabic

Fills from right to left, with Arabic digits.

تقييم التوصيل
  • منخفض: ٠ – ٥٠
  • متوسط: ٥٠ – ٨٠
  • جيد: ٨٠ – ١٠٠
Angular
<ui-gauge-chart
  dir="rtl"
  label="تقييم التوصيل"
  [value]="64"
  [zones]="zonesArabic"
  locale="ar-EG"
/>

In Arabic, half a ring

تقييم التوصيل، نصف دائرة
Angular
<ui-gauge-chart
  dir="rtl"
  label="تقييم التوصيل، نصف دائرة"
  [value]="64"
  shape="half"
  [height]="220"
  locale="ar-EG"
/>

When to use something else

If you needUse
Several levels, or little roomMeter
Work that is still goingProgress
One number and how it changedStat

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the chart, above it and for screen readers.
valuenumber — Required. The level now.
minnumber0The lowest level.
maxnumber100The highest level.
shape'arc' | 'half' | 'ring''arc'Three quarters of a ring, half, or all of it.
valueTextstring — The value in words. Defaults to the number.
tone'neutral' | 'success' | 'warning' | 'danger''neutral'Colour of the fill, when there are no zones.
zonesGaugeZone[][]Named parts of the scale: from, to, label and tone.
target{ value, label } — A mark across the ring.
endsbooleantrueThe lowest and highest value at the ends.
formatValue(value: number) => string — Writes a value.
valueLabelstring — Names the column of the table. 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.
legendboolean — Shows the names and their colours.
tablebooleantrueThe button that shows the numbers as a table.
loadingbooleanfalseShows that the rows are on their way.
localestring — For numbers and dates. Defaults to the language of the page.
dir'ltr' | 'rtl' — Defaults to the direction of the page around it.

Keyboard and screen readers

KeysWhat they do
Tab Reach the gauge, then its next control.
  • A named graphic, read in one go.
  • The same numbers are always there as a real table.
  • The value and its zone are part of the name, so they are read at once.