Label List Pie Chart
Display categorical data with formatted labels showing browser names directly on segments. Perfect for React applications requiring enhanced label presentation with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/pie-chart-05.json
npx shadcn@latest add https://www.shadcn.io/registry/pie-chart-05.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/pie-chart-05.json
bunx shadcn@latest add https://www.shadcn.io/registry/pie-chart-05.json
Features
- LabelList component displaying formatted browser names on each segment
- Background contrast labels using background color for optimal readability
- Custom label formatting with configurable formatter function for label display
- Responsive typography with adjustable font size and styling options
- TypeScript support with complete type definitions for label configuration
- shadcn/ui integration using Chart and tooltip components without background
Use Cases
This free open source React component works well for:
- Branded visualizations - Display category names clearly on each segment built with Next.js
- Educational dashboards - Show data with immediate category identification using TypeScript and Tailwind CSS
- Report presentations - Present statistics with prominent category labels
- User-friendly analytics - Provide clear segment identification without requiring hover
API Reference
ChartPieLabelList
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
LabelList Implementation
The key feature is the LabelList component with custom formatting:
<Pie data={chartData} dataKey="visitors">
<LabelList
dataKey="browser"
className="fill-background"
stroke="none"
fontSize={12}
formatter={(value: keyof typeof chartConfig) =>
chartConfig[value]?.label
}
/>
</Pie>
Implementation Notes
- LabelList uses
fill-background
class for contrast against segment colors - Custom formatter function maps browser keys to display labels
- Font size set to 12px for optimal readability on segments
- No stroke applied to labels for cleaner appearance
- Formatter ensures type safety with TypeScript key mapping
- Labels automatically position themselves within segment boundaries
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.
Legend Pie Chart
Display categorical data with an external legend showing colors and category names. Perfect for React applications requiring clear data identification with Next.js integration and TypeScript support.