Calm motion: animations on this site only fade, with no movement
Donut chart
Parts of one whole, as a ring or a pie
Shows how one total splits into a few parts, for example storage by type. Use it for up to about six parts. For more parts, or parts that you compare with each other, use the bar chart. For parts in a row, use the meter group.
Basic
- Raw audio412 GB51.1%
- Video268 GB33.2%
- Episodes96 GB11.9%
- Artwork31 GB3.8%
datais a list of{ label, value, color }. Each slice is its share of the total, from the top and clockwise. A value of 0 or less has no slice, but it stays in the legend.- The total is in the center.
piedraws a full pie, with no hole and no total. - The legend shows each part with its value and its share. It is real text, so screen readers read it, and the ring is hidden from them.
labelnames the chart. - A hover on a slice shows its label, value, and share. Colors go through the chart colors in order. Set
colorto a token name or any CSS color. sizesets the width of the ring in pixels (default 180). The legend goes beside the ring, or below it when there is no room.formatsets the text of a value. Change the word under the total withlabelsor a label pack:total.- The chart is drawn as plain SVG. There is no chart library to install.
Usage
ts
import { BlessDonutChart, type BlessDonutSlice } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
data* | BlessDonutSlice[] | — | |
pie | boolean | — | a full pie, with no hole and no total |
size | number | 180 | the width of the circle in pixels |
format | ((v: number) => string) | — | text for one value, for example `(v) => v + " GB"` |
label | string | "Chart" | names the chart for screen readers |
labels | Partial<{ total: string; }> | — |