Pie Chart
<PieChart />TailwindCSS ModulesVisualize category shares and composition in dashboards with responsive pie and donut charts.
npx coloxo add pie-chart --style coloxo-cssimport { PieChart } from '@coloxo/ui';Understand the mix. Compare shares. See the whole picture.
1. Pie chart examples
Explore pie and donut views of the same traffic sources. All figures are sample data.
Pie Chart - Default
Visitors by acquisition source
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
Pie Chart - Labels
Show each source's percentage share
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
Pie Chart - Donut
A compact view of category composition
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
Pie Chart - Donut with total
Keep the total visible alongside the mix
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
2. Interactive configurator
Width is relative to the preview. Height sets the plot area in pixels; the circle scales to fit.
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
<PieChart label="Traffic sources" data={data} innerRadius={0} height={280} style={{ width: "100%" }} showLegend={true} showLabels={false}/>3. Enterprise layout compositions
Combine category shares with summary metrics for revenue reviews and budget planning. All figures below are sample data.
Revenue by plan
Subscription revenue mix · June
- Enterprise
- Business
- Starter
| Category | Value | Share |
|---|---|---|
| Enterprise | $126k | 60.0% |
| Business | $54k | 25.7% |
| Starter | $30k | 14.3% |
Department budget allocation
Quarterly operating budget · Sample allocation
- Engineering
- Sales
- Operations
- Support
| Category | Value | Share |
|---|---|---|
| Engineering | $45k | 45.0% |
| Sales | $25k | 25.0% |
| Operations | $20k | 20.0% |
| Support | $10k | 10.0% |
import { Card, PieChart, Statistic } from "@coloxo/ui";const data = [ { "label": "Enterprise", "value": 126 }, { "label": "Business", "value": 54 }, { "label": "Starter", "value": 30 }];<Card variant="default" className="p-6"> <Statistic label="Monthly revenue" value="210" prefix="$" suffix="k" /> <PieChart label="Monthly revenue by subscription plan" data={data} innerRadius={60} centerLabel="Revenue" valueFormatter={(value) => `$${value}k`} /></Card>4. Actions & composition
Pair the chart with reporting period filters, a visible data table, and CSV export. Each action uses the selected period.
Traffic source analytics
Acquisition mix · Sample data
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
| Source | Visitors | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
5. Dark theme
- Direct
- Search
- Social
- Referral
| Category | Value | Share |
|---|---|---|
| Direct | 420 | 29.2% |
| Search | 580 | 40.3% |
| Social | 260 | 18.1% |
| Referral | 180 | 12.5% |
Accessibility
Each chart has an accessible name, keyboard-focusable slices, descriptive values and percentages, and a screen-reader data table.
Hover or focus a slice to see its category, formatted value, and percentage in the shared ChartTooltip. Press Escape to dismiss it. Use descriptive category labels and retain the legend or data table so color is not the only way to identify a slice. Use a small number of categories. Empty datasets and datasets without positive values display a clear empty state.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| data | PieChartDatum[] | — | Category label, numeric value, and optional CSS color. Negative, non-finite, and zero values do not create slices. |
| label | string | — | Required accessible chart name. |
| innerRadius | number | 0 | Hole radius as a percentage of the outer radius, clamped to 0–80. Use 60 for a donut. |
| height | number | 280 | Chart height in pixels, minimum 160. The circular plot scales to fit the available width. |
| showLegend | boolean | true | Display category labels with color markers. |
| showLabels | boolean | false | Display rounded percentages on slices of at least 6%. Exact shares remain in descriptions and the data table. |
| centerLabel | string | — | Show the formatted total and a caption inside a donut. |
| valueFormatter | (value: number) => string | — | Format slice values, the donut total, and accessible data. |
| className / style | string / CSSProperties | — | Customize the chart container, including width. |