Doughnut Chart

Doughnut charts show proportional data as slices of a ring with a hollow center. They offer a cleaner look than pie charts and work well in dashboards where the center space can provide additional context.

Similar to pie charts but with an empty center.

For advanced configuration such as custom plugins and direct Chart.js access, see <wa-chart>.

Examples

Link to This Section

Providing Data with JavaScript

Link to This Section

For dynamic data, set the config property directly. The chart will re-render automatically.

Note that config is shallowly reactive. If you mutate the existing object in place, you must reassign it to trigger a re-render!

Providing Data with JSON

Link to This Section

Place a <script type="application/json"> tag inside the component with your chart data. Each value in the data array corresponds to a label.

Custom Slice Colors

Link to This Section

Override the default color palette using the --fill-color-* and --border-color-* CSS custom properties to apply custom colors to each slice.

Cutout Size

Link to This Section

Control the size of the center hole through the Chart.js cutout option. The default is '50%'. Use a higher percentage for a thinner ring or a lower one for a thicker ring.

Legend

Link to This Section

Use the legend-position attribute to control where the legend appears. Add without-legend to hide it entirely.

Disabling Tooltips

Link to This Section

Use the without-tooltip attribute to hide the tooltips that appear when hovering over slices.

Disabling Animations

Link to This Section

Use the without-animation attribute to disable chart transitions.

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/doughnut-chart/doughnut-chart.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/doughnut-chart/doughnut-chart.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/doughnut-chart/doughnut-chart.js';

To import this component for React 18 or below, use the following code:

import WaDoughnutChart from '@awesome.me/webawesome/dist/react/doughnut-chart/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

Need a hand? Report a bug Ask for help