Skip to content

Donut chart ​

A donut with a legend and an optional center label, over plain name and value data.

Open in demo
Open in demo

Usage ​

data is DonutSlice[], which is { name, value, color? }. Slice colors come from the themed categorical palette unless you set one, so the chart follows the brand color and dark mode without being told.

It is a donut rather than a pie on purpose: the hole makes room for the center label and keeps the slices reading as a ring.

ECharts is heavy, so the template's dashboards import their charts with defineAsyncComponent. Do the same on a page where the chart is below the fold, and ECharts stays out of that page's first chunk.

The chart fills a wrapper of a definite height rather than being sized itself. vue-echarts ships .echarts { height: 100% }, which beats a height utility on the component and collapses the canvas.

Examples ​

A center label ​

centerValue and centerLabel print over the hole. They take no pointer events, so hovering the middle still reaches the slice underneath.

Explicit colors ​

A slice with its own color keeps it. Use that where a color carries meaning, such as healthy, degraded and down.

Loading ​

loading swaps the chart for a skeleton of the same height, so the card does not change size when the data arrives.

API ​

Source: src/shared/components/common/charts/DonutChart.vue

Props ​

PropTypeDefaultDescription
dataDonutSlice[]required{ name, value, color? }.
loadingbooleanfalseRenders a skeleton of the same height.
heightnumber280The wrapper height in pixels.
centerLabelstring—The small line in the hole.
centerValuestring | number—The large line in the hole.

Emits ​

None.

Slots ​

None.

Accessibility ​

  • The tooltip is keyboard-inert, so the legend and the numbers beside the chart carry the values. Where a donut is the only source of a figure, print it as text too, which is what centerValue is for.
  • Tooltip values are formatted in the app's language, read when the tooltip renders, so they follow the language switcher.
  • Slice separators are drawn in the card's own surface color, so neighboring slices stay distinguishable in both color modes.