DonutChart
A `PieChart` with its middle opened up and filled with the number the chart is actually about — a total, a headline share — as ordinary DOM rather than SVG text.
<UiDonutChart :data="..." :categoryKey="..." :valueKey="..." :ariaLabel="..." />Needs the charts module
This component ships in @jgastager/bundy-ui/charts, a separate module so projects that never draw a chart don't carry the paint classes these need. Nothing extra to install — just add the module entry. See Charts.
Data
requireddata is one object per slice, all values non-negative. The hole in the middle is what a donut adds over a pie: room for the total the slices add up to.
- Chrome · 6,400
- Safari · 2,800
- Firefox · 1,200
- Edge · 780
A donut is a pie with the middle opened up, and the hole is the only reason to pick one — it's somewhere to put the number the chart is actually about. If you don't need that, PieChart is the same chart without the extra prop.
The hover fade is a CSS transition over the library's own 250ms duration, so it costs nothing and honours prefers-reduced-motion. There's no animate prop and nothing tweens on a data change — the marks are plain SVG elements Vue patches directly.
Category key
requiredcategoryKey sets which field on each row labels the slice.
- Chrome
- Safari
- Firefox
- Edge
Value key
requiredvalueKey sets which field holds its numeric size.
- Chrome
- Safari
- Firefox
- Edge
ARIA label
requiredariaLabel is required, and worth writing carefully — slice angles are the hardest thing on any chart to read back, so a screen reader gets nothing at all without it.
- Chrome
- Safari
- Firefox
- Edge
ARIA description
ariaDescription is the detail the label shouldn't carry.
- Chrome
- Safari
- Firefox
- Edge
Label
label names what the center number counts. Without it the number sits there unexplained.
- Chrome · 6,400
- Safari · 2,800
- Firefox · 1,200
- Edge · 780
- Chrome · 6,400
- Safari · 2,800
- Firefox · 1,200
- Edge · 780
Colors are the library's own semantic ones — primary, secondary, success, warning, error, info, pending, neutral — and any shade of them, primary-400 through primary-950, exactly as the bg-* utilities spell them. Set color per series (or per item) to pin one; leave it unset to take the next slot of the default sequence. neutral and secondary are never handed out automatically, so an unlabelled series never lands on them.
Value
value overrides the center number, which otherwise sums every slice. Use it when the headline isn't the total — a leading share, a budget remaining.
- Chrome
- Safari
- Firefox
- Edge
The default centre value is the sum of every slice. Pass value when the headline is something else — a share, a delta, a target.
Everything the PieChart notes say about sorting, non-negative values and slice counts applies here too; the two share their slice allocation and geometry.
Inner radius
innerRadius is the size of the hole, as a fraction of the radius — and the whole difference between a donut and a PieChart. Shrink it toward zero and you get a pie with a caption in it.
Radius
radius rounds the corners of each slice. A little softens the ring; too much starts eating into thin slices, which is how a small share disappears.
Gap
gap is the space between slices, in degrees. Zero gives an unbroken ring; a degree or two is enough to separate neighbouring slices that share a similar colour.
Sort
sort orders the slices largest-first by default, which is what makes a donut readable at a glance. Turn it off when the rows already have a meaningful order — a rating scale, a funnel.
- Medium
- Low
- High
- Critical
- Critical
- High
- Medium
- Low
Colors
colors pins a paint per slice, matched positionally to data before any sorting — so the colours follow your rows rather than the rendered order.
- Critical
- High
- Medium
- Low
Value format
valueFormat covers the tooltip, the legend, and the default center total together.
- Chrome · 6,400
- Safari · 2,800
- Firefox · 1,200
- Edge · 780
Tooltip
tooltip shows the tooltip on hover.
- Chrome
- Safari
- Firefox
- Edge
Legend
legend shows the legend.
The centre is real DOM positioned over the plot, not SVG text — so it can hold any Bundy component, and the number stays selectable and searchable. It's pinned to whichever edge the plot occupies so the legend doesn't push it off-centre.
Legend position
legendPosition sets where the legend sits relative to the plot.
- Chrome
- Safari
- Firefox
- Edge
Legend align
legendAlign places the key horizontally. Centre reads well under a ring, which is itself centred, where start would leave it visibly off-axis.
- Chrome
- Safari
- Other
- Chrome
- Safari
- Other
- Chrome
- Safari
- Other
Legend orientation
legendOrientation flows the entries in a row or a column. vertical reads well beside the ring — one slice per line, in the same order as the arcs.
- Chrome · 6,400
- Safari · 2,800
- Firefox · 1,200
- Edge · 780
Hovering dims every slice except the focused one to 0.7 rather than drawing a ring on it — a ring is a dot, which reads as a stray mark sitting on the arc. The hit test is polar: the angle and distance under the pointer, not a bounding box.
Height
height is the plot's height in pixels; the ring is sized to fit inside it. It's ignored once aspectRatio is set.
- Chrome
- Safari
- Other
- Chrome
- Safari
- Other
Aspect ratio
aspectRatio sizes the chart from its container's width instead of a fixed height.
- Chrome
- Safari
- Firefox
- Edge
Loading
loading is a skeleton at the chart's exact height; an empty data array gets the empty state instead.
API Reference
Generated from the component's source — props, slots and emits as the component actually declares them.
Props
number0.62(value: number) => stringSlots
defaultEmits
focusChange[label: string | null]Types
type ChartColorName = ChartColorFamily | `${ChartColorFamily}-${ChartColorShade}`;