Ring chart
Concentric progress rings with a hover glow and a counting center value.
553 Today
12 days to race
Installation
pnpm add @heyramzi/uiUsage
import { RingChart } from "@heyramzi/ui/charts";<RingChart
data={[{ label: "Move", value: 520, maxValue: 600, color: "var(--chart-4)" }]}
size={240}
defaultLabel="Today"
/>Keyboard and accessibility
- The chart is an image named "Total" and the sum, unless you pass ariaLabel. The rings aren't in the name.
- With reduced motion on, the rings show without sweeping in.
API reference
datarequiredRingData[]sizenumber- Fixed square size in px. Omit to fill the parent (responsive).
strokeWidthnumber- Default
11 - Ring thickness in viewBox units.
ringGapnumber- Default
6 - Gap between concentric rings in viewBox units.
baseInnerRadiusnumber- Default
48 - Inner radius of the innermost ring in viewBox units.
lineCap"round" | "butt"- Default
"round" defaultLabelstring- Default
"Total" - Center label when nothing is hovered.
formatValue(v: number) => string- Default
(v) => v.toLocaleString() animateboolean- Default
true - Animate arcs on mount.
showGlowboolean- Default
true - Glow the hovered ring.
hoveredIndexbindablenumber | null- Default
null - Hovered ring index, bindable for legend hover-sync.
onHoveredIndexChange(index: number | null) => voidminWidthnumber- Default
170 ariaLabelstringchildrenSnippet- Replaces the center readout, for a number that isn't the ring's own value.
classstring
| Prop | Type | Default |
|---|---|---|
data required | RingData[] | |
size Fixed square size in px. Omit to fill the parent (responsive). | number | |
strokeWidth Ring thickness in viewBox units. | number | 11 |
ringGap Gap between concentric rings in viewBox units. | number | 6 |
baseInnerRadius Inner radius of the innermost ring in viewBox units. | number | 48 |
lineCap | "round" | "butt" | "round" |
defaultLabel Center label when nothing is hovered. | string | "Total" |
formatValue | (v: number) => string | (v) => v.toLocaleString() |
animate Animate arcs on mount. | boolean | true |
showGlow Glow the hovered ring. | boolean | true |
hoveredIndex bindable Hovered ring index, bindable for legend hover-sync. | number | null | null |
onHoveredIndexChange | (index: number | null) => void | |
minWidth | number | 170 |
ariaLabel | string | |
children Replaces the center readout, for a number that isn't the ring's own value. | Snippet | |
class | string |