# Radial Chart

> React radial bar chart of concentric progress rings with labels, a legend and a rolling center total that animate on data change, or one progress ring.

- Kind: Component (Charts)
- Docs: https://ui.minidev.pro/docs/radial-chart
- Source (registry JSON with the full file): https://ui.minidev.pro/r/radial-chart.json
- License: MIT. One file, yours to edit after install.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/radial-chart
```

Writes `components/ui/radial-chart.tsx` plus the MiniDev files it is built from (segmented-control) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/radial-chart.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { RadialChart } from "@/components/ui/radial-chart"
```

From the npm package:

```tsx
import { RadialChart } from "minidev-ui-kit/ui/radial-chart"
```

## Usage

```tsx
import { RadialChart } from "@/components/ui/radial-chart"

export function Example() {
  return (
    <RadialChart />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `data` | `RadialDatum[]` | - | no | Rings, outermost first. One item renders a single radial progress ring. |
| `periods` | `RadialPeriod[]` | `PERIODS` | no | Datasets to switch between with a segmented control. Ignored when `data` is set. |
| `title` | `string` | `"Goals progress"` | no |  |
| `centerLabel` | `string` | - | no | Label under the centre total. |
| `centerValue` | `React.ReactNode` | - | no | Override the centre value. Defaults to the average progress of all rings. |
| `thickness` | `number` | - | no | Ring thickness in chart units (the chart is 240 wide). |
| `gap` | `number` | `6` | no | Gap between rings in chart units. |
| `showLegend` | `boolean` | `true` | no |  |
| `className` | `string` | - | no |  |

## Examples

### Single ring

One item turns the chart into a full radial progress ring with the value and its max written under the percentage.

```tsx
<RadialChart
  title="Storage"
  data={[{ label: "Used", value: 164, max: 250, format: (n) => `${n} GB` }]}
/>
```

### Fixed data with a custom centre

Passing data removes the period switcher; centerValue and centerLabel replace the average when a count reads better.

```tsx
<RadialChart
  title="Quarter goals"
  centerValue="3 of 4"
  centerLabel="on track"
  data={[
    { label: "New ARR", value: 1.84, max: 2, format: (n) => `$${n}M` },
    { label: "Net retention", value: 112, max: 110, format: (n) => `${n}%` },
    { label: "Hires", value: 9, max: 12 },
    { label: "Uptime", value: 99.97, max: 99.95, format: (n) => `${n}%` },
  ]}
/>
```

### Thin rings, no legend

thickness and gap shrink the rings and showLegend false leaves a compact widget for a dashboard tile.

```tsx
<RadialChart
  title="Team capacity"
  centerLabel="allocated"
  thickness={12}
  gap={4}
  showLegend={false}
  data={[
    { label: "Design", value: 86 },
    { label: "Platform", value: 72 },
    { label: "Payments", value: 94 },
    { label: "Support", value: 58 },
  ]}
  className="max-w-64"
/>
```

### Period switch

Pass periods instead of data and a segmented control above the rings swaps datasets; the rings sweep to the new values.

```tsx
<RadialChart
  title="Collections"
  periods={[
    {
      label: "This month",
      data: [
        { label: "Collected", value: 84200, max: 120000, format: (n) => `$${(n / 1000).toFixed(1)}k` },
        { label: "Paid on time", value: 91, max: 100, format: (n) => `${n}%` },
      ],
    },
    {
      label: "Last month",
      data: [
        { label: "Collected", value: 112400, max: 120000, format: (n) => `$${(n / 1000).toFixed(1)}k` },
        { label: "Paid on time", value: 86, max: 100, format: (n) => `${n}%` },
      ],
    },
  ]}
/>
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Tab` | Moves focus to the period switch, when `periods` has more than one entry. |
| `ArrowLeft` or `ArrowRight` | In the period switch, selects the previous or next period. |

## Accessibility

- The SVG is `role="img"`. Its `aria-label` is the title followed by each ring's label, percentage and "value of max".
- The centre total is `aria-hidden`, because the name already holds every value.
- Legend rows dim the other rings on pointer hover only; they are not focusable.
- Under reduced motion the rings and centre number jump straight to new values instead of sweeping and rolling.

## FAQ

### How do I make a single radial progress ring?

Pass one item: `<RadialChart title="Storage" data={[{ label: "Used", value: 38, max: 50 }]} />`. It draws a full ring, shows the percentage in the centre with the item's label and "38 of 50" under it, and hides the legend.

### How do I let people switch between periods?

Pass `periods`, an array of `{ label, data }`, and leave out `data`. With more than one period a [`SegmentedControl`](https://ui.minidev.pro/docs/segmented-control) appears in the header. `data` always wins over `periods`, so set only one of them.

### What does the number in the middle mean?

With several rings it is the average progress across them, labelled "of goals". Override it with `centerValue` and `centerLabel`, for example a revenue total. Each ring's own value and `max` go through its `format` in the legend.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`
- Built from: [segmented-control](https://ui.minidev.pro/docs/segmented-control/md)

## Related

- [Donut Chart](https://ui.minidev.pro/docs/donut-chart/md): Single value donut chart in SVG that fills an accent ring to a percentage of max and prints the percent in the middle. Labelled as an image for screen readers.
- [Goal Ring](https://ui.minidev.pro/docs/goal-ring/md): A circular progress ring that shows how far along a goal is, with the percentage in the middle and a caption below. Handy for fitness, sales or weekly targets.
- [Progress Circle](https://ui.minidev.pro/docs/progress-circle/md): A compact circular progress indicator drawn in SVG with a configurable size, an accent arc, an accessible label and the percentage in monospace below it.
- [Radar Chart](https://ui.minidev.pro/docs/radar-chart/md): SVG radar chart that plots normalized 0 to 1 values on labelled axes over four concentric grid rings. Themed with currentColor and labelled for screen readers.
- [Area Chart](https://ui.minidev.pro/docs/area-chart/md): Dependency free SVG area chart for React with a smoothed line, dashed grid, gradient fill and an optional highlighted point. Strokes stay crisp at any size.
- [Bar Chart](https://ui.minidev.pro/docs/bar-chart/md): Lightweight React bar chart with rounded bars, dashed gridlines and labels. Hovering a bar dims the rest and shows its value; the peak is highlighted first.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
