Blocks / Donut

Donut

A pixel ring cut into slices, each with its own pattern. The key gives value and share.

import { Donut, dashboardRing } from "@forgeron/ui";
/01 → Default
Leads by source
850Total
Leads by source
SliceValueShare
Website41248%
Referral23828%
Events12615%
Outbound749%
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 },
      ]}
    />
  );
}
/02 → Highlight
Spend by category
€95kQ4
Spend by category
SliceValueShare
Software€48k51%
Travel€21k22%
Hardware€17k18%
Other€9k9%
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
PropTypeDefaultDescription
titlestring—Names the chart; also its caption.
items{ label, value }[]—One slice each.
format(value: number) => stringStringWrites a value.
highlightstring—The label of the slice drawn in ember; the others share the greys.
sizenumber160Width of the ring, in px.
thicknessnumber12Of the ring, in chart pixels (two px each).
centerReactNode—In the hole; the total by default.
classNamestring—Extra classes.