Sparkline
The shape of a trend beside its number, as a line, an area or bars, read by that number.
import { Sparkline } from "@arcadia/ui/charts"111ms
line: response time9,100
area: requests9
bars: deploysTSX
Anatomy
- Line
- One stroke of
--chart-line-inline, 1.5px: monotone, with round joins and caps, from the series' lowest value at the bottom to its highest at the top. It shows the shape; the number beside it gives the size. - Area
- The line and a wash under it,
--chart-washat its highest point fading to nothing at zero, where the area starts. - Bars
- One to a row, square, 1px apart, from zero. A zero keeps a 1px sliver and a missing value leaves its place empty.
- Size
- 16px tall in a table or list row, 24px beside a number, 32px in a
Stat. It fills its container or takes a fixed width, at least 2px to each row. - Colour
- One series, painted
chartColor(1)unless its entity owns a slot. Never green or red by its sign: the number beside it says which way it went. - Reading
- A dot on the read row, 3px in radius in the series' colour, ringed by
--chart-surfaceas wide as the line; the bars beside a read bar set back to--chart-dim. No card: the number beside it reads the row.
Examples
Reading
Requests9,100Today
- Tab
- Moves to the sparkline: the reading starts on the newest row, or on the row read last.
- ←→
- Step a row; right to left, the arrows follow the page.
- ↑↓
- Step a row, as on any slider.
- HomeEnd
- The first row and the newest.
- Esc
- Hides the reading until the next key. Leaving the sparkline clears it.
States
--sparkline-h- Ref<Space>Default var(--space-6)
--space-4in a row,--space-6beside a number,--space-8in aStat.--chart-surface- ChartKnobs["--chart-surface"]Default var(--card-bg, var(--bg-app))
- What the read dot's ring cuts to, as on a
Chart.
Sparkline
labelrequired- string
- What it counts ("Requests per day"): its name starts with it.
xrequired- readonly (string | number | Date)[]
- The rows, oldest first: days as
yyyy-mm-dd, timestamps, or names. valuesrequired- readonly (number | null | undefined)[]
- A value per row;
nullis a gap. kind- "line" | "area" | "bars"Default "line"
size- "sm" | "md" | "lg"
- 16, 24 or 32px;
lgin aStat. color- stringDefault chartColor(1)
- The paint of the slot its entity owns.
curve- "monotone" | "straight" | "step"Default "monotone"
unit- string
- A symbol every number carries (
ms,%). format- (value: number) => string
- How a read value is written:
fmtCount,fmtPercent. onRead- (point: SparkPoint | null) => void
- Turns the reading on: called with each point read, then
nullwhen the reading ends. rootStyle- RootStyle<SparklineKnobs>
Rest props go to HTMLAttributes<HTMLDivElement>.