# C pie chart 3

> Expenses — spending by category with currency values

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/c-pie-chart-3).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/c-pie-chart-3
- Screenshot: https://shadcn.exchange/shot/cnippet/c-pie-chart-3/light.png
- Registry item: https://ui.cnippet.dev/r/c-pie-chart-3.json
- Categories: pie chart
- Listed: 2026-10-27, source last changed 2026-10-27

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-pie-chart-3.json
```

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

## Dependencies

- Registry items: `@cnippet/pie-chart`, `@cnippet/chart-card`, `@cnippet/chart-utils`

## Files

### `registry/default/chart-variants/c-pie-chart-3.tsx`

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { PieChart } from "@/registry/default/charts/pie-chart";
import { formatCurrency } from "@/registry/default/lib/chart-utils";

const data = [
  { amount: 1840, category: "Rent" },
  { amount: 620, category: "Groceries" },
  { amount: 310, category: "Transport" },
  { amount: 260, category: "Dining out" },
  { amount: 190, category: "Subscriptions" },
];

export default function Expenses() {
  return (
    <ChartCard
      className="max-w-md"
      description="Spending by category, September"
      title="Expenses"
      value={formatCurrency(3220, "USD", { compact: false })}
    >
      <PieChart
        category="amount"
        className="h-48"
        data={data}
        index="category"
        legendLayout="side"
        valueFormatter={(value) =>
          formatCurrency(value, "USD", { compact: false })
        }
      />
    </ChartCard>
  );
}
```
