Join our Discord community
Pie chart

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

Loading component...

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

PropTypeDefaultDescription
classNamestring-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