Chart parts
The legend, the sparkline, number and stat card variants, the center-value gauge and the five chart tokens.
Gauge with a count-up center
A notched radial meter that counts up its center value.
Ring chart and Legend
Concentric rings with a legend that hovers in step, progress bars included.
- Organic 4,25085%
- Paid 3,12062%
- Email 2,10042%
- Social 1,58032%
Legend on its own
Progress bars, percentages, hover dim and keyboard focus.
Traffic by channel
- Organic 4,25085%
- Paid 3,12062%
- Email 2,10042%
- Social 1,58032%
Sparkline
A trendline the width of whatever holds it.
showLast: end-cap dot and inline value
0 to 23. v: first 50, last 33.491, low 30.822, high 76.186.
| i | v |
|---|---|
| 0 | 50 |
| 1 | 66.589 |
| 2 | 70.829 |
| 3 | 70.95 |
| 4 | 76.186 |
| 5 | 66.969 |
| 6 | 54.822 |
| 7 | 51.984 |
| 8 | 40.864 |
| 9 | 33.449 |
| 10 | 30.822 |
| 11 | 42.889 |
| 12 | 48.412 |
| 13 | 55.302 |
| 14 | 71.14 |
| 15 | 73.76 |
| 16 | 71.787 |
| 17 | 74.97 |
| 18 | 64.242 |
| 19 | 51.497 |
| 20 | 39.12 |
| 21 | 39.406 |
| 22 | 34 |
| 23 | 33.491 |
bare: no chrome, for the foot of a card that links
Chart tokens
Theme charts globally with five CSS custom properties.
Number chart
A figure on its own, with or without a scale under it.
size=lg: count-up, direction-aware delta
Total cash
across 4 accounts
share: the scale a lone number can't carry
Expenses
38% of revenue
bare: no chrome, for a figure inside a band or a panel
Net income
62% of revenue
Stat card
A figure over a chart, on a card: three chart kinds, a gauge form and a bare chart.
variant=area: edge-to-edge chart, trend pill, count-up value
variant=line: denser series
variant=bar: negative trend, down state
variant=gauge: figure left, radial gauge right
figureOnly: the bare edge-to-edge chart, no labels
Installation
pnpm add @heyramzi/uiUsage
import {
GaugeChart,
Legend,
NumberChart,
RingChart,
Sparkline,
StatCard,
} from "@heyramzi/ui/charts";Keyboard and accessibility
- A Legend is a list of each row's label and value. Its rows take no focus, and hovering one highlights its series.
API reference
itemsrequiredLegendItem[]titlestringlayout"vertical" | "horizontal"- Default
"vertical" - Stacked rows vs inline wrap.
showProgressboolean- Default
false - Render a progress bar under each row (needs maxValue).
showValueboolean- Default
true - Show the value beside each label.
showPercentageboolean- Default
false - Append a percentage (needs maxValue).
formatValue(v: number) => string- Default
(v) => v.toLocaleString() formatPercentage(p: number) => string- Default
(p) => `${p.toFixed(0)}%` hoveredIndexbindablenumber | null- Default
null - Hovered index, bindable for chart hover-sync.
onHoveredIndexChange(index: number | null) => voidclassstring
| Prop | Type | Default |
|---|---|---|
items required | LegendItem[] | |
title | string | |
layout Stacked rows vs inline wrap. | "vertical" | "horizontal" | "vertical" |
showProgress Render a progress bar under each row (needs maxValue). | boolean | false |
showValue Show the value beside each label. | boolean | true |
showPercentage Append a percentage (needs maxValue). | boolean | false |
formatValue | (v: number) => string | (v) => v.toLocaleString() |
formatPercentage | (p: number) => string | (p) => `${p.toFixed(0)}%` |
hoveredIndex bindable Hovered index, bindable for chart hover-sync. | number | null | null |
onHoveredIndexChange | (index: number | null) => void | |
class | string |