Components/Charts/DonutChart

DonutChart

Charts

Donut / pie chart with centre label slot.

Pie chart rendered as a donut. chartLabel renders arbitrary content in the center hole. Multiple sections with configurable colors.

Usage

import { DonutChart } from "nosible-ux"

const data = [
  { name: "Earnings", value: 38 },
  { name: "Macro", value: 27 },
  { name: "Guidance", value: 20 },
  { name: "Other", value: 15 },
]

export default function Example() {
  return <DonutChart data={data} withLegend withTooltip />
}

Examples

With center label

Props

Name TypeDefaultDescription
aria-label
string | undefinedAccessible label forwarded to the `role="img"` wrapper.
chartLabel
ReactNodeText rendered in the donut hole.
data
DonutChartEntry[]Segment data.
endAngle
number | undefinedEnd angle in degrees. Default: `-270` (full circle).
paddingAngle
number | undefinedGap between segments in degrees. Default: `2`.
size
number | undefinedOuter diameter of the chart in px. Default: `220`.
startAngle
number | undefinedStart angle in degrees. Default: `90` (12 o'clock).
thickness
number | undefinedRing thickness in px (`outerRadius - innerRadius`). Default: `40`.
withLabels
boolean | undefinedShow percentage labels outside each segment. Default: `false`.
withLegend
boolean | undefinedLegend below the chart. Default: `true`.
withTooltip
boolean | undefinedBranded tooltip on hover. Default: `true`.