Skip to content
Charts

Ring Chart

Donut with a hub total. Default and Motion variants.

Examples

Installation

Default is a ready-made wrapper from the registry. Motion is the composable engine at @cronus-ui/ui/charts (peer visx + motion).

bash
npx cronus-ui add ring-chart
tsx
import { RingChart } from "@cronus-ui/ui";

Usage

tsx
import { RingChart, Ring, RingCenter, Legend, LegendItem, LegendMarker, LegendLabel } from "@cronus-ui/ui/charts";
<RingChart data={rings} hoveredIndex={hovered} onHoverChange={setHovered}>
{rings.map((_, i) => <Ring index={i} key={i} />)}
<RingCenter defaultLabel="Total" />
</RingChart>

Components

Motion API — compose these under the chart root. Default wrapper props are in Default API below.

RingChart

Concentric progress rings. Each datum has value / maxValue.

Skip RingChartProps props table
PropTypeDefaultDescription
data*
RingData[]label, value, maxValue, optional color.
strokeWidth
number12Ring thickness.
ringGap
number6Gap between rings.
baseInnerRadius
number60Innermost inner radius.
hoveredIndex
number | nullControlled hover.

Ring

One progress arc. Hover scales the ring; others dim.

Skip RingProps props table
PropTypeDefaultDescription
index*
numberIndex in data.
color
stringOverride color.
lineCap
"round" | "butt""round"Arc end cap.
showGlow
booleantrueGlow on hover.

RingCenter

Hub total / hovered value.

Skip RingCenterProps props table
PropTypeDefaultDescription
defaultLabel
string"Total"Label when nothing is hovered.
prefix
stringPrefix before the number.
children
(ctx) => ReactNodeCustom hub renderer.

Legend

Composable side legend. Map `LegendItem` (marker, label, value, optional progress) over `items`. Share `hoveredIndex` with the chart for bidirectional highlight.

Skip LegendProps props table
PropTypeDefaultDescription
items*
LegendItemData[]Label, value, color, optional maxValue.
hoveredIndex
number | nullControlled hover.
onHoverChange
(index: number | null) => voidHover callback.
title
stringHeading above the list.
children*
ReactElementA single LegendItem template, cloned per item.

Hover + legend

Same bidirectional hoveredIndex pattern as PieChart.

Data format

ts
type RingData = { label: string; value: number; maxValue: number; color?: string };
const rings: RingData[] = [
{ label: "Storage", value: 68, maxValue: 100 },
{ label: "Bandwidth", value: 42, maxValue: 100 },
];

Theming

Motion charts read `--chart-*` aliases that map onto Cronus semantic tokens (`--cronus-chart-1`…`--cronus-chart-5`, `--cronus-border`, `--cronus-fg`, surfaces). Override the aliases or the tokens — never palette scales (`bg-zinc-900`). Default wrappers use `ChartConfig` with `var(--cronus-chart-*)` / `var(--cronus-primary)`. Track background is `--border`. defaultRingColors cycles `--chart-1`…`--chart-5`.

Full token reference: Theming.

Dependencies

Default needs the recharts peer. Motion needs visx (and sometimes d3) as optional peers — install only what this chart uses.

bash
bun add recharts
bash
bun add @visx/shape @visx/responsive motion

Default API

Generated from the Default wrapper's exported types. Motion subcomponents are documented above.

RingChartProps

Extends HTMLAttributes<HTMLDivElement>

Skip RingChartProps props table
PropTypeDefaultDescription
data*
RingChartItem[]
series*
ChartSeries[]
centerLabel
string"Total"