Component

Donut Chart

Ring chart with optional center label / value. Set thickness="0" for a solid pie.

Installation

import { WrDonutChart } from 'ngwr/donut-chart';

@Component({ imports: [WrDonutChart] })
export class MyComponent {
  protected readonly segments = [
    { label: 'Used', value: 60 },
    { label: 'Reserved', value: 25 },
    { label: 'Free', value: 15 },
  ];
}

With center label

<wr-donut-chart [segments]="segments" centerLabel="Disk" centerValue="60%" />
60%
Disk
  • Used60
  • Reserved25
  • Free15

Solid pie

<wr-donut-chart [segments]="segments" thickness="0" />
  • Used60
  • Reserved25
  • Free15

API

NameDescriptionTypeDefault
segmentsSlices to render.readonly WrDonutSegment[][]
ariaLabelAccessible name of the chart. The ring itself is aria-hidden, so with showLegend off this is all a screen reader gets. Falls back to the donutChart.label catalog key.string | nullnull
sizeDiameter in CSS pixels (min 48).number200
thicknessInner-ring thickness as a % of radius. 0 = solid pie.number30
showLegendShow the legend under the chart.booleantrue
centerValueBold value text in the center.string''
centerLabelSmaller label under the center value.string''

Types

Data shapes used by the inputs and outputs above.

interface WrDonutSegment {
  label: string;
  value: number;
  color?: string;
}
NameDescriptionTypeDefault
WrDonutSegmentOne slice of the ring.interface
labelrequiredLegend label.string
valuerequiredSlice magnitude — share of the total.number
colorCSS color for the slice.stringpalette