Labeled Pie Chart
Display categorical data with visible segment labels showing values directly on the chart. Perfect for React applications requiring clear data visualization with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/pie-chart-03.json
npx shadcn@latest add https://www.shadcn.io/registry/pie-chart-03.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/pie-chart-03.json
bunx shadcn@latest add https://www.shadcn.io/registry/pie-chart-03.json
Features
- Visible segment labels showing values directly on each pie slice
- Interactive tooltips providing additional context on hover
- Customizable label styling using CSS classes for foreground text color
- Responsive design with aspect-square container and fixed dimensions
- TypeScript support with complete type definitions for all chart props
- shadcn/ui integration using Chart and tooltip components without background
Use Cases
This free open source React component works well for:
- Detailed data presentation - Display exact values on each segment built with Next.js
- Educational dashboards - Show data with immediate visibility using TypeScript and Tailwind CSS
- Report visualizations - Present statistics with clear numerical labels
- Business analytics - Highlight specific metrics with prominent value display
API Reference
ChartPieLabel
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes for the container |
Chart Configuration
The component uses the same browser data configuration:
const chartConfig = {
visitors: {
label: "Visitors",
},
chrome: {
label: "Chrome",
color: "var(--chart-1)",
},
// ... additional segments
} satisfies ChartConfig
Key Features
The main difference is the label
prop and label styling:
<ChartContainer
config={chartConfig}
className="[&_.recharts-pie-label-text]:fill-foreground aspect-square w-80 h-80"
>
<PieChart>
<Pie data={chartData} dataKey="visitors" label nameKey="browser" />
</PieChart>
</ChartContainer>
Implementation Notes
- Labels display visitor counts directly on each pie segment
- Uses
[&_.recharts-pie-label-text]:fill-foreground
for proper text color theming - Labels automatically position themselves based on segment size and angle
- Maintains interactivity with tooltips for additional information
- Perfect for cases where immediate data visibility is crucial
- Colors and label text follow theme-aware styling patterns
Seamless Pie Chart
Display categorical data with seamless segments and no dividing lines. Perfect for React applications requiring clean data visualization with Next.js integration and TypeScript support.
Custom Label Pie Chart
Display categorical data with fully customizable label rendering and no connecting lines. Perfect for React applications requiring advanced label control with Next.js integration and TypeScript support.