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.
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.
pnpm add @tanstack/charts@1.5.0One shape
Press Tab and use the arrow keys to read each measure.
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
- Giza
<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.
- Cairo
- Giza
- Tanta
<ui-radar-chart
label="Three branches"
[rows]="skills"
x="skill"
[series]="three"
[height]="320"
[max]="100"
[filled]="false"
/>Lines only
- Cairo
- Giza
<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.
- Cairo
- Giza
- Tanta
<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.
<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.
<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.
Nothing picked yet.
<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
<ui-radar-chart
label="Loading"
[rows]="none"
x="skill"
[series]="one"
[height]="160"
loading
/>Nothing yet
Says so in words.
Nothing to show yet
<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.
- القاهرة
- الجيزة
<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 need | Use |
|---|---|
| To compare the values exactly | Bar chart |
| How two numbers go together | Scatter chart |
| 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. |
x | string | — | Required. The row field with the measure. |
series | ChartSeries[] | — | Required. The shapes: key, label, and optionally color. |
max | number | — | The value at the rim. Defaults to the highest, rounded up. |
levels | number | 4 | How many rings. |
filled | boolean | true | A soft fill inside each shape. |
highlight | string | — | The key of the shape to bring forward; the others turn grey. |
xLabel | string | — | Names the first column of the table. |
formatX | (x) => string | — | Writes a measure. |
formatY | (y: number) => string | — | Writes a 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. |
toggle | boolean | false | The names become buttons that switch parts on and off. |
legend | boolean | — | Shows the names and their colours. |
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.
- Shapes differ by the dash of their line as well as colour.