# GardenGrid (/docs/charts/garden-grid)

GardenGrid shows the rhythm of activity over time the way ActivityGrid does, in a single ink. Dot **area** carries a
five-step ordinal, so the rhythm reads in grayscale and print where a color heatmap would collapse. The radius is
√-quantized so perceived area steps evenly; a linear radius map would exaggerate the highs quadratically. A zero cell is
a hairline ring, present but quiet, and a `null` cell is nothing at all, since print and grayscale otherwise lose the
zero-versus-missing distinction color grids get for free. The steps are ordinal rather than values: `ActivityGrid` is
the color twin when exact values matter.

```tsx
<GardenGrid
  data={[12, 20, 8, 0, 15, 28, 34, 5, 0, 22, 18, 9, 3, 0, 24, 30, 11, 6, 19, 0, 26]}
  unit="weeks"
  title="Activity"
  cell={11}
/>
```

## Install

```tsx
import { GardenGrid } from "@microcharts/react/garden-grid";

<GardenGrid data={weeks} title="Activity" unit="weeks" />
```

Setup (package + stylesheet): [Quickstart](/docs/quickstart#set-up-with-an-ai-agent) or paste [`/agent-setup.md`](/agent-setup.md) into your agent.

## Try it

```tsx
import { GardenGrid } from "@microcharts/react/garden-grid/interactive";

<GardenGrid
  data={weeks}
/>
```

## When to use it

Use it for a contribution or activity rhythm you print or read in grayscale, a per-repo or per-team activity strip, or
any calendar-shaped intensity where color isn't available. For exact per-cell values use ActivityGrid with hover or
HeatStrip; for trends, Sparkline.

## Sizing

**strip mode for a table cell**

```tsx
const weeks = [12, 20, 8, 0, 15, 28, 34, 5, 0, 22, 18, 9];

<GardenGrid data={weeks} rows={1} />
```

**empty='blank' for sparse data**

```tsx
const weeks = [12,20,8,0,15,28,34,5,0,22,18,9,3,0,24,30,11,6,19,0,26];

<GardenGrid data={weeks} empty="blank" />
```

## Variants

```tsx
const weeks = [12, 20, 8, 0, 15, 28, 34, 5, 0, 22, 18, 9];

<GardenGrid data={weeks} rows={1} />
<GardenGrid data={weeks} empty="blank" />
```

## Edge cases

```tsx
<GardenGrid data={[]} title="No history" />
```

```tsx
<GardenGrid data={[0, 0, 0, 0, 0, 0, 0]} title="Quiet week" />
```

```tsx
<GardenGrid data={[5, null, 8, null, null, 3]} title="Gaps" />
```

```tsx
<GardenGrid data={[12]} title="One" />
```

## Four homes

**In a sentence**

```tsx
<p>
  Contributions this quarter{" "}
  <span className="mc-inline">
    <GardenGrid data={weeks} rows={1} summary={false} />
  </span>{" "}
  — busy mid-month, quiet weeks 4 and 10.
</p>
```

**In a table cell**

```tsx
<td>
  <GardenGrid data={weeks} rows={1} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">34</span>
  <span className="unit">peak week</span>
  <GardenGrid data={weeks} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  microcharts <GardenGrid data={weeks} rows={1} />
</button>
```

Best at KPI/card scale — activity grids need room for cell area.

## Accessibility

The accessible name summarizes the rhythm: **"12 periods; peak 34, 10 active."** The interactive entry walks the grid in
2-D with the arrow keys (or hover), announcing each cell as its ordinal step — **"3 of 21: 8, step 2 of 5."** — because
dot area reads to a step rather than a number.

The interactive entry follows the shared [interaction contract](/docs/accessibility#one-interaction-contract):
arrow keys rove between units on both axes, `Home` and `End` jump to the ends, and a click, tap, `Enter` or
`Space` selects a unit — pinning its readout so it survives blur, until you select it again, press `Escape`, or
press outside the chart. On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `(number \| null)[]` | Binned values; null = missing. |
| `rows` | `number` | Grid rows (default 7); 1 = strip. |
| `steps` | `3 \| 5` | Radius quantization steps (default 5). |
| `empty` | `"outline" \| "blank"` | How zero cells render (default outline). |
| `unit` | `string` | Noun for the summary count (default "periods"). |
| `cell` | `number` | Cell edge length in viewBox units (default 10). |
| `gap` | `number` | Gap between cells in viewBox units (default 2). |
| `animate` | `boolean` | (interactive) Opt-in entrance motion when the chart mounts client-side — add `import "@microcharts/react/motion"` once. Inert on the server, on hydrated server HTML, and under `prefers-reduced-motion`. |

Plus the shared grammar — `data`, `domain`, `color`, `title`, `summary`, `format` — and the layout props (`width`, `height`, `className`, `style`) that every chart accepts. Interactive entries also share `animate` and `live`, and — wherever a chart has more than one navigable unit — `onActive`, `onSelect`, `selectedIndex` and `defaultSelectedIndex`; and — wherever the chart shows a hover value — `readout`. See [the shared grammar](/docs/quickstart#the-shared-grammar).
