suiss/uim · Chart

Pie Chart Legend

A donut chart with a legend below it naming each device color.

Pie Chart Legend is an open-source mobile chart from suiss/uim, drawn with react-native-svg for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Pie (legend) on iOS in light mode

A PieChart donut with a ChartLegend that lists every slice from chartConfig. chartData holds one record per device with a users count. Pressing a slice shows a tooltip.

Installation

$ pnpm dlx @esuiss/uim@latest add pie-chart-legend

The CLI also adds what it builds on: Card, Chart.

Manual

  1. Add the pieces it builds on: Card, Chart.

  2. Copy the source into components/charts/pie-chart-legend.tsx:

uniwind/components/charts/pie-chart-legend.tsx
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  Pie,
  PieChart,
  1. Update the import paths to match your project.

Usage

import { PieChartLegend } from "@/components/charts/pie-chart-legend"
<PieChartLegend />

Replace chartData with your records and keep dataKey and nameKey in step with your field names. Add one entry per slice to chartConfig with its label and color; the component takes no props.