# C heatmap 3

> Error rate — services by day with an incident

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-heatmap-3).

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

## Install

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

## Files

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

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { Heatmap } from "@/registry/default/charts/heatmap";
import { formatPercent } from "@/registry/default/lib/chart-utils";

const services = ["api", "auth", "billing", "search", "webhooks"];
const days = [
  "Oct 20",
  "Oct 21",
  "Oct 22",
  "Oct 23",
  "Oct 24",
  "Oct 25",
  "Oct 26",
];

// Deterministic error rates, with a billing incident on Oct 23.
const data = services.flatMap((service, s) =>
  days.map((day, d) => ({
    day,
    rate:
      service === "billing" && d === 3
        ? 0.084
        : (0.002 + ((s * 7 + d * 3) % 9) * 0.0011) *
          (service === "search" ? 2.2 : 1),
    service,
  })),
);

export default function ErrorRateByService() {
  return (
    <ChartCard
      className="max-w-2xl"
      description="5xx responses as a share of requests, per service and day"
      footer="Billing spiked to 8.4% on Oct 23 during the payment-provider outage."
      title="Error rate"
    >
      <Heatmap
        cellLabel={(row) =>
          `${row.service}, ${row.day}: ${formatPercent(row.rate, { digits: 2 })} errors`
        }
        color="var(--destructive)"
        data={data}
        value="rate"
        valueFormatter={(v) => formatPercent(v, { digits: 1 })}
        x="day"
        xFormatter={(day) => day.replace("Oct ", "")}
        y="service"
      />
    </ChartCard>
  );
}
```
