# C donut chart 4

> Budget split — side legend with a currency total

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-donut-chart-4).

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

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-donut-chart-4.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/donut-chart`, `@cnippet/chart-card`, `@cnippet/chart-utils`

## Files

### `registry/default/chart-variants/c-donut-chart-4.tsx`

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { DonutChart } from "@/registry/default/charts/donut-chart";
import { formatCurrency, sumBy } from "@/registry/default/lib/chart-utils";

const data = [
  { amount: 186000, line: "Payroll" },
  { amount: 54000, line: "Infrastructure" },
  { amount: 38000, line: "Marketing" },
  { amount: 21000, line: "Tools" },
  { amount: 12000, line: "Travel" },
];

export default function BudgetSplit() {
  return (
    <ChartCard
      className="max-w-md"
      description="Q4 operating budget by line"
      title="Budget"
    >
      <DonutChart
        category="amount"
        centerLabel="Q4 total"
        centerValue={formatCurrency(sumBy(data, ["amount"]))}
        className="h-52"
        data={data}
        index="line"
        legendLayout="side"
        valueFormatter={formatCurrency}
      />
    </ChartCard>
  );
}
```
