Donut
Use it for a handful of parts that add up to one whole, when the share matters more than the exact amounts. Fold small slices into Other; more than six or seven slices want a bar list or treemap instead.
How to use it
Paste the toolkit from Get the code into your page first, then call the chart like this.
const chart = donut({
parts: [
{ name: 'Housing', value: 1210, colour: catColor('Housing') },
{ name: 'Groceries', value: 438, colour: catColor('Groceries') },
{ name: 'Other', value: 164, colour: 'var(--c9)' }
],
centre: { value: '£1,812', label: 'September' },
size: 240,
onClick: part => openCategory(part.name),
label: 'Spending by category, September'
});Options
What you can pass to this chart.
parts
[{ name, value, colour }]. Order is drawn clockwise from 12 o'clock.
centre
{ value, label } shown in the hole until a slice is hovered or focused.
size
Pixel size of the square (default 220).
fmt
Formatter for the aria-label of each slice.
onClick
(part) => void.
More charts like this
Other charts in the “Parts of a whole” group.
Want charts or dashboards like these in your own product?
Tell me what you are trying to see and I can help work out the right approach, from the data behind it to the screen in front of people.