# Heatmap chart

Two categories against each other with the amount as shade: requests by weekday and hour, eval scores by model and task.

Also called: activity grid, contribution graph, calendar heatmap.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Heatmap chart. A week of requests by hour: the launch on Wednesday afternoon stands out, and a logging gap is hatched. Preview: https://chatcn.dev/preview/heatmap-chart-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/heatmap-chart
```

## Usage

```tsx
import { HeatmapChart } from "@/components/ui/chatcn/pro/heatmap-chart"

<HeatmapChart
  title="Requests by hour, last week"
  x={["00:00", "01:00", …]}       // columns
  y={["Mon", "Tue", …]}           // rows
  values={[[120, 98, …], …]}      // one row per y, null for no data
  unit="requests"
  variant="isometric"             // or "grid" (default), "dots"
/>
```

Shades come from one palette color (`palette`, 1 to 6) mixed toward the card color on a smooth ramp, so the eye reads more and less rather than different hues, in light and dark. The legend shows the ramp and the real range. Cells are rounded with small gaps. Point at a cell, or focus the chart and walk it with the arrow keys: a crosshair keeps its row and column lit, the labels on both axes go bold, a card gives the value beside its row and column averages, and the readout says the same in words. Missing cells are hatched, never drawn as zero. When cells are large enough the value is printed inside, in a color chosen for contrast with its shade. `variant="dots"` draws a circle per cell whose area is the value, which reads well when a few cells dwarf the rest. `variant="isometric"` raises every cell into a column on a tilted floor: height and shade both carry the value, columns rise from the back corner on first draw, row and column names continue their lines past the front edges, the peak gets a pill, and pointing at a column fades the rest of the city toward the card while its row and column stay in color. The isometric chart sizes its own height to fit its width unless you pass `height`. Column labels thin out to fit in every variant.

## Examples

### States

Example: States. Eval pass rates by model and task on another palette color, loading, and empty. Preview: https://chatcn.dev/preview/heatmap-chart-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `x`, `y` | `string[]` | Column and row labels |
| `values` | `(number | null)[][]` | One row per `y` |
| `variant` | `"grid" | "dots" | "isometric"` | How cells are drawn. Default grid |
| `palette` | `number` | Palette color for the ramp, 1 to 6 |
| `unit`, `valueFormat` |  | How values read |
| `xLabelEvery` | `number` | Show every nth column label |
| `height` | `number` | Default 28 px per row plus the axis (30 for dots); isometric fits its width |
| `loading`, `error`, `onRetry` |  |  |
| `labels` | `Partial<HeatmapChartLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Tab | Focus the chart; the highest cell is read out |
| Arrow keys | Move between cells |
| Home, End | First or last cell in the row |

## Accessibility

- The chart is an image summarized with its range and peak, with a full table for screen readers.
- Missing values read as no data.
- The table button shows the same grid as a table.

## Motion

Cells fade in from left to right once, over 760 ms; dots grow from their centers. Isometric columns rise from the back corner to the front once, over 1.1 s. Highlights fade over 150 ms. Under reduced motion it appears drawn.

Source: https://chatcn.dev/docs/components/heatmap-chart