When to use a pie or donut chart
Pie and donut charts work for a few categories that add up to a meaningful whole.
- Budget or headcount by team
- Traffic share by browser or device
- Plan mix across customers
Data format
- Use exactly 2 columns: Category,Value.
- Keep it to about 6 slices; group the long tail into Other.
- Paste CSV, JSON from your API, TSV copied from Excel or Google Sheets, or a Markdown table. The generated component keeps your column names as its data keys.
Category,Value
Engineering,45
Design,20
Marketing,18
Operations,12
Other,5[
{"category": "Engineering", "value": 45},
{"category": "Design", "value": 20},
{"category": "Marketing", "value": 18},
…
]Options
- Donut
- Hollow center with the total, rounded padded slices.
- Labels
- Show each slice's value, percent, or name.
- Colors
- Custom color per slice.
How to add it to your project
- 1. Add the shadcn/ui chart component (it installs Recharts):
npx shadcn@latest add chart - 2. Paste your data above, pick the options, and copy the generated
chart.tsx. - 3. Save it in your project (e.g.
components/pie-chart.tsx) and render<Chart />, or<Chart data={rows} />in Data as prop mode.
Pie / Donut Chart FAQ
Turn on Donut. The generated Pie gets an innerRadius and a center label that shows the total, computed from your data at render time.
Two columns: a category and a numeric value. Blank values are left out of the chart.
With many small categories or when comparing close values. A horizontal bar chart is easier to read in those cases.