# C bar chart 4

> Profit & loss — negative values below a zero line

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

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

## Install

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

## Files

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

```tsx
"use client";

import { ReferenceLine } from "recharts";
import { BarChart } from "@/registry/default/charts/bar-chart";
import { ChartCard } from "@/registry/default/charts/chart-card";
import { formatCurrency } from "@/registry/default/lib/chart-utils";

// Monthly net income: two loss-making months after a hiring push.
const data = [
  { month: "Jan", net: 18400 },
  { month: "Feb", net: 12900 },
  { month: "Mar", net: -6200 },
  { month: "Apr", net: -11800 },
  { month: "May", net: 4300 },
  { month: "Jun", net: 15600 },
  { month: "Jul", net: 21200 },
  { month: "Aug", net: 24800 },
];

export default function NetIncome() {
  return (
    <ChartCard
      className="max-w-2xl"
      description="Net income per month, after payroll and infrastructure"
      title="Profit & loss"
      value={formatCurrency(78900)}
    >
      <BarChart
        categories={["net"]}
        className="h-48"
        config={{ net: { color: "var(--chart-2)", label: "Net income" } }}
        data={data}
        index="month"
        radius={2}
        valueFormatter={formatCurrency}
      >
        <ReferenceLine stroke="var(--border)" y={0} />
      </BarChart>
    </ChartCard>
  );
}
```
