Charts
Sparkline and Gauge
A tiny trend line for tables and stat cards, and a half-circle meter for one measure.
Ant Design: Tiny charts, Gauge
import { Sparkline, Gauge } from '@alea/ui';
Examples
Sparklines and gauges
Small trends for stat cards, and a meter for one score.
Visits
9,612
Errors
23
92Accessibility score
64%Storage used
In a table
Sparklines next to the numbers they summarize.
Plugin | Users | Last 7 days |
|---|---|---|
| Contrast Checker | 3,410 | |
| Palette Generator | 1,240 | |
| Type Scale | 860 |
Props
Sparkline props
A tiny trend line for tables and stat cards (MUI SparkLineChart, Mantine Sparkline).
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | - | What it shows, read by screen readers ("Visits, last 14 days"). |
valuesrequired | number[] | - | The numbers, oldest first. |
color | string | 'var(--alea-chart-1)' | Line or bar color. Default the first chart color. |
height | number | 32 | Height in px. Default 32. |
type | "area" | "line" | "bar" | 'line' | line (default), area or bar. |
width | number | 120 | Width in px. Default 120. |
Gauge props
A half-circle meter for a single measure: score, load, quota (MUI Gauge, Mantine SemiCircleProgress).
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | - | The visible label under the number. |
valuerequired | number | - | The current value. |
max | number | 100 | The top of the scale. Default 100. |
min | number | 0 | The bottom of the scale. Default 0. |
size | number | 200 | Width in px. Default 200. |
thresholds | { upTo: number; tone: "danger" | "success" | "warning" | "accent"; }[] | - | Colors by range: [{ upTo: 60, tone: 'success' }, ...]. |
valueFormat | ((v: number) => string) | - | Formats the number in the middle, e.g. v => `${v}%`. |
Accessibility
- Sparkline is an image named with the trend; Gauge is a meter with its value.
Do and don't
Do
- Pair a sparkline with the current number (Statistic).
- Use the same scale for sparklines you compare.
Don't
- Don't add axes or tooltips: use LineChart for that.
- Don't use a gauge for values without a meaningful maximum.