Browse Components
Donut Chart
Show how categories contribute to a whole.
Basic
Compare the parts of a total. Hover, tap or focus a segment to inspect its value and share.
View Data
| Source | Visits |
|---|---|
| Direct | 420 |
| Search | 350 |
| Referral | 150 |
| Social | 80 |
View Code
<figure class="chart" data-chart="donut">
<figcaption>
Traffic sources
</figcaption>
<details class="chart-data">
<summary>
View Data
</summary>
<div class="chart-data-scroll">
<table>
<caption>
Traffic sources — example data
</caption>
<thead>
<tr>
<th scope="col">
Source
</th>
<th scope="col">
Visits
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Direct
</th>
<td>
420
</td>
</tr>
<tr>
<th scope="row">
Search
</th>
<td>
350
</td>
</tr>
<tr>
<th scope="row">
Referral
</th>
<td>
150
</td>
</tr>
<tr>
<th scope="row">
Social
</th>
<td>
80
</td>
</tr>
</tbody>
</table>
</div>
</details>
</figure>Single category
One category fills the ring without a seam or an artificial gap.
View Data
| Source | Visits |
|---|---|
| Direct | 1000 |
View Code
<figure class="chart" data-chart="donut">
<figcaption>
Traffic sources
</figcaption>
<details class="chart-data">
<summary>
View Data
</summary>
<div class="chart-data-scroll">
<table>
<caption>
Traffic sources — example data
</caption>
<thead>
<tr>
<th scope="col">
Source
</th>
<th scope="col">
Visits
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Direct
</th>
<td>
1000
</td>
</tr>
</tbody>
</table>
</div>
</details>
</figure>Zero values
Known categories with zero values retain their legend and reserved ring.
View Data
| Source | Visits |
|---|---|
| Direct | 0 |
| Search | 0 |
| Referral | 0 |
| Social | 0 |
View Code
<figure class="chart" data-chart="donut">
<figcaption>
Traffic sources
</figcaption>
<details class="chart-data">
<summary>
View Data
</summary>
<div class="chart-data-scroll">
<table>
<caption>
Traffic sources — example data
</caption>
<thead>
<tr>
<th scope="col">
Source
</th>
<th scope="col">
Visits
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Direct
</th>
<td>
0
</td>
</tr>
<tr>
<th scope="row">
Search
</th>
<td>
0
</td>
</tr>
<tr>
<th scope="row">
Referral
</th>
<td>
0
</td>
</tr>
<tr>
<th scope="row">
Social
</th>
<td>
0
</td>
</tr>
</tbody>
</table>
</div>
</details>
</figure>Right-to-left
Labels follow the reading direction; segment order remains clockwise.
View Data
| Source | Visits |
|---|---|
| Direct | 420 |
| Search | 350 |
| Referral | 150 |
| Social | 80 |
View Code
<figure class="chart" data-chart="donut" dir="rtl">
<figcaption>
Traffic sources
</figcaption>
<details class="chart-data">
<summary>
View Data
</summary>
<div class="chart-data-scroll">
<table>
<caption>
Traffic sources — example data
</caption>
<thead>
<tr>
<th scope="col">
Source
</th>
<th scope="col">
Visits
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Direct
</th>
<td>
420
</td>
</tr>
<tr>
<th scope="row">
Search
</th>
<td>
350
</td>
</tr>
<tr>
<th scope="row">
Referral
</th>
<td>
150
</td>
</tr>
<tr>
<th scope="row">
Social
</th>
<td>
80
</td>
</tr>
</tbody>
</table>
</div>
</details>
</figure>Empty data
An empty ring preserves the chart space without inventing values.
View Data
| Source | Visits |
|---|
View Code
<figure class="chart" data-chart="donut">
<figcaption>
Traffic sources
</figcaption>
<details class="chart-data">
<summary>
View Data
</summary>
<div class="chart-data-scroll">
<table>
<caption>
Traffic sources — example data
</caption>
<thead>
<tr>
<th scope="col">
Source
</th>
<th scope="col">
Visits
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</details>
</figure>Installation
Download these files into the matching paths in your project, or use Create to assemble a kit. Include each dependency once. Do not also load app.css.
<link rel="stylesheet" href="/library/assets/base.css">
<link rel="stylesheet" href="/library/assets/chart-core.css">
<link rel="stylesheet" href="/library/assets/donut-chart.css">
<script defer src="/library/assets/chart-core.js"></script>
<script defer src="/library/assets/donut-chart.js"></script>12,442 bytes CSS including base · 12,470 bytes runtime JavaScript
Usage
Show parts of a whole
Use one nonnegative series with up to six categories. Prefer a bar chart for precise comparisons or many small categories. Combine small categories into Other in your application.
Keep the context
The center shows the total and the legend lists category values. Hover, tap or use arrow keys to inspect values and percentages. The source table remains available without JavaScript; the enhanced chart keeps values in its legend and accessible segment labels. Zero values have no segment; empty data keeps the ring.
Share the foundation
Chart Core owns table parsing, number formatting, the legend, responsive sizing, keyboard navigation and lifecycle. Use layoutCharts.refresh(root) after data changes and destroy(root) before removal. Customize Total with data-chart-total-label.
Building with AI? The AI Manifest has these notes and the full contract. See the AI Guide.