# Adherence pie chart

> Medication adherence, as a pie chart with a legend.

A shadcn/ui block from the [@organui](https://organui.com/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/organui/chart-pie-adherence).

- Page, with a live preview: https://shadcn.exchange/r/organui/chart-pie-adherence
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/organui/chart-pie-adherence-light-4f3db896a9e38895.png
- Registry item: https://organui.com/r/chart-pie-adherence.json
- Categories: charts, charts-pie
- Listed: 2026-10-22, source last changed 2026-10-22

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/organui/chart-pie-adherence.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `recharts`
- Registry items: `card`, `chart`

## Notes from the registry

Adherence pie chart: https://organui.com/charts/pie#chart-pie-adherence

## Files

### `registry/base-nova/charts/chart-pie-adherence.tsx`

```tsx
"use client"

import { Pie, PieChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  type ChartConfig,
} from "@/components/ui/chart"

export const description = "Medication adherence, as a pie chart with a legend"

// Doses over 30 days for a fictional patient.
const chartData = [
  { status: "onTime", doses: 52, fill: "var(--color-onTime)" },
  { status: "late", doses: 5, fill: "var(--color-late)" },
  { status: "missed", doses: 3, fill: "var(--color-missed)" },
]

const chartConfig = {
  doses: {
    label: "Doses",
  },
  onTime: {
    label: "On time",
    color: "var(--chart-2)",
  },
  late: {
    label: "Late",
    color: "var(--chart-4)",
  },
  missed: {
    label: "Missed",
    color: "var(--chart-1)",
  },
} satisfies ChartConfig

export function ChartPieAdherence() {
  return (
    <Card className="flex flex-col">
      <CardHeader className="items-center pb-0">
        <CardTitle>Adherence</CardTitle>
        <CardDescription>Doses over the last 30 days</CardDescription>
      </CardHeader>
      <CardContent className="flex-1 pb-0">
        <ChartContainer
          config={chartConfig}
          className="mx-auto aspect-square max-h-[300px]"
        >
          <PieChart>
            <Pie data={chartData} dataKey="doses" />
            <ChartLegend
              content={
                <ChartLegendContent
                  nameKey="status"
                  className="-translate-y-2 flex-wrap gap-2 *:basis-1/4 *:justify-center"
                />
              }
            />
          </PieChart>
        </ChartContainer>
      </CardContent>
      <CardFooter className="text-sm text-muted-foreground">
        87% on time; a fictional patient.
      </CardFooter>
    </Card>
  )
}
```
