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

Chapter 12 Charts

Radar chart

Several measures of one thing, or of two or three, around a circle. For the shape, not for exact values: bars compare better. Lines differ by dash as well as colour, and one button shows the numbers as a table.

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

One shape

Press Tab and use the arrow keys to read each measure.

Cairo branch
Angular
const skills = [
  { skill: 'Speed', cairo: 82 },
  { skill: 'Price', cairo: 60 },
  { skill: 'Choice', cairo: 74 },
];
const one = [{ key: 'cairo', label: 'Cairo' }];

<ui-radar-chart
  label="Cairo branch"
  [rows]="skills"
  x="skill"
  [series]="one"
  [height]="320"
  [max]="100"
/>

Two shapes

The second is dashed.

Cairo and Giza
  • Cairo
  • Giza
Angular
<ui-radar-chart
  label="Cairo and Giza"
  [rows]="skills"
  x="skill"
  [series]="two"
  [height]="320"
  [max]="100"
/>

Three shapes

Three at most: more hide each other.

Three branches
  • Cairo
  • Giza
  • Tanta
Angular
<ui-radar-chart
  label="Three branches"
  [rows]="skills"
  x="skill"
  [series]="three"
  [height]="320"
  [max]="100"
  [filled]="false"
/>

Lines only

Cairo and Giza, lines only
  • Cairo
  • Giza
Angular
<ui-radar-chart
  label="Cairo and Giza, lines only"
  [rows]="skills"
  x="skill"
  [series]="two"
  [height]="320"
  [max]="100"
  [filled]="false"
/>

One against the rest

highlight takes the key of the series.

Giza among the rest
  • Cairo
  • Giza
  • Tanta
Angular
<ui-radar-chart
  label="Giza among the rest"
  [rows]="skills"
  x="skill"
  [series]="three"
  [height]="320"
  [max]="100"
  highlight="giza"
/>

Shapes that switch on and off

The names become buttons.

Pick the branches
Angular
<ui-radar-chart
  label="Pick the branches"
  [rows]="skills"
  x="skill"
  [series]="three"
  [height]="320"
  [max]="100"
  toggle
/>

Your own rings

How many rings, and where the rim is.

Cairo branch, two rings
Angular
<ui-radar-chart
  label="Cairo branch, two rings"
  [rows]="skills"
  x="skill"
  [series]="one"
  [height]="320"
  [max]="100"
  [levels]="2"
/>

Open a value

Click a point, or press Enter on it, to use its row.

Cairo branch, open a measure

Nothing picked yet.

Angular
<ui-radar-chart
  label="Cairo branch, open a measure"
  [rows]="skills"
  x="skill"
  [series]="one"
  [height]="320"
  [max]="100"
  (rowSelect)="open($event)"
/>

Loading

Keeps its place while the rows arrive.

Loading

Loading

Angular
<ui-radar-chart
  label="Loading"
  [rows]="none"
  x="skill"
  [series]="one"
  [height]="160"
  loading
/>

Nothing yet

Says so in words.

Nothing yet

Nothing to show yet

Angular
<ui-radar-chart
  label="Nothing yet"
  [rows]="none"
  x="skill"
  [series]="one"
  [height]="160"
  emptyMessage="Nothing to show yet"
/>

In Arabic

Runs the other way round, with Arabic digits.

القاهرة والجيزة
  • القاهرة
  • الجيزة
Angular
<ui-radar-chart
  dir="rtl"
  label="القاهرة والجيزة"
  [rows]="skillsArabic"
  x="skill"
  [series]="twoArabic"
  [height]="320"
  [max]="100"
  locale="ar-EG"
/>

When to use something else

If you needUse
To compare the values exactlyBar chart
How two numbers go togetherScatter 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.
xstring — Required. The row field with the measure.
seriesChartSeries[] — Required. The shapes: key, label, and optionally color.
maxnumber — The value at the rim. Defaults to the highest, rounded up.
levelsnumber4How many rings.
filledbooleantrueA soft fill inside each shape.
highlightstring — The key of the shape to bring forward; the others turn grey.
xLabelstring — Names the first column of the table.
formatX(x) => string — Writes a measure.
formatY(y: number) => string — Writes a 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.
togglebooleanfalseThe names become buttons that switch parts on and off.
legendboolean — Shows the names and their colours.
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.
  • Shapes differ by the dash of their line as well as colour.