Donut
A pixel ring cut into slices, each with its own pattern. The key gives value and share.
import { Donut, dashboardRing } from "@forgeron/ui";850Total
| Slice | Value | Share |
|---|---|---|
| Website | 412 | 48% |
| Referral | 238 | 28% |
| Events | 126 | 15% |
| Outbound | 74 | 9% |
import { Donut } from "@forgeron/ui";
export default function Default() {
return (
<Donut
title="Leads by source"
items={[
{ label: "Website", value: 412 },
{ label: "Referral", value: 238 },
{ label: "Events", value: 126 },
{ label: "Outbound", value: 74 },
]}
/>
);
}€95kQ4
| Slice | Value | Share |
|---|---|---|
| Software | €48k | 51% |
| Travel | €21k | 22% |
| Hardware | €17k | 18% |
| Other | €9k | 9% |
import { Donut } from "@forgeron/ui";
export default function Highlight() {
return (
<Donut
title="Spend by category"
size={140}
thickness={10}
highlight="Software"
format={(n) => `€${n}k`}
items={[
{ label: "Software", value: 48 },
{ label: "Travel", value: 21 },
{ label: "Hardware", value: 17 },
{ label: "Other", value: 9 },
]}
center={
<>
<b>€95k</b>
<small>Q4</small>
</>
}
/>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Names the chart; also its caption. |
items | { label, value }[] | — | One slice each. |
format | (value: number) => string | String | Writes a value. |
highlight | string | — | The label of the slice drawn in ember; the others share the greys. |
size | number | 160 | Width of the ring, in px. |
thickness | number | 12 | Of the ring, in chart pixels (two px each). |
center | ReactNode | — | In the hole; the total by default. |
className | string | — | Extra classes. |