DonutChart
Ring sweeps in segment by segment. Hover swells a segment and swaps the center. Charts.
Open playground10,000
Visits
- Direct42%
- Search31%
- Social18%
- Email9%
About
DonutChart is a React component in the Charts category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { DonutChart } from "@ashutoshswamy/smoui" and set data, size, totalLabel among its 4 props.
Install
npm i @ashutoshswamy/smouiUsage
import { DonutChart } from "@ashutoshswamy/smoui";
<DonutChart data={[{ label: "Direct", value: 4200 }, { label: "Search", value: 3100 }]} totalLabel="Visits" />Props 4
- data
Segments. Colors are tones of the accent.
{ label: string; value: number }[]- size / thickness
Ring size and stroke in px.
numberdefault168 / 18- totalLabel
Caption under the total.
stringdefault"Total"- prefix / suffix
Wrap the value. Or pass `format` as a function.
string
More charts components
- AreaChartDraws itself in. A guide, dot and tooltip follow the pointer on springs.
- BarChartBars grow in a wave. The pointed bar lights up and its value pops above it.
- BulletChartProgress against a goal. The bar fills on a spring, a tick marks the target, and rows that beat it turn solid.
- BumpChartWho was ahead of whom, step by step. Lines swap places the way rankings do; point at one and it comes forward.
- ContributionGraphA calendar of days as squares, darker for busier ones. They pop in column by column; point at one for its date and count.
- DumbbellChartBefore and after per row. The bar stretches between the dots, then the change lands in green or red.