# SpiralYear (/docs/charts/spiral-year)

SpiralYear answers "how did the year breathe?" It winds a calendar series onto an Archimedean spiral: the angle is the
position in the year (January at 12 o'clock, running clockwise) and each turn outward is the next year. The value
becomes a five-step opacity, so busy stretches read as darker arcs of the spiral. This is a **pattern instrument** —
opacity is the weakest ordered channel, so for an exact day's value reach for `ActivityGrid` or `HeatStrip`.

```tsx
<SpiralYear
  data={Array.from({ length: 52 }, (_, i) => {
    const s = Math.round(200 + 140 * Math.sin(((i - 8) / 52) * Math.PI * 2));
    return i === 29 ? 480 : s;
  })}
  title="Seasonality"
  size={80}
/>
```

## Install

```tsx
import { SpiralYear } from "@microcharts/react/spiral-year";

<SpiralYear data={byWeek} title="Seasonality" />
```

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


## When to use it

- **Good for** — the seasonal shape of a year at a glance, spotting a busy season or a quiet stretch, or a compact "the
  year in one square".
- **Avoid for** — reading an exact day's value (`ActivityGrid` / `HeatStrip`), a non-cyclic trend (`Sparkline`), or more
  than about three years.

## Variants

```tsx
const byWeek = Array.from({ length: 52 }, (_, i) => {
  const s = Math.round(200 + 140 * Math.sin(((i - 8) / 52) * Math.PI * 2));
  return i === 29 ? 480 : s; // a summer peak in week 30
});

<SpiralYear data={byWeek} mark="arc" />
<SpiralYear data={byWeek} steps={3} />
```

`locale` doesn't change any in-chart mark — opacity steps carry the value, never a printed number — but it does localize
the peak and low values named in the accessible summary:

```tsx
const byWeek = Array.from({ length: 52 }, (_, i) => {
  const s = Math.round(200 + 140 * Math.sin(((i - 8) / 52) * Math.PI * 2));
  return i === 29 ? 1480 : s;
});

<SpiralYear data={byWeek} locale="de-DE" />
```


## Edge cases

```tsx
<SpiralYear data={[80, 120, null, 90, 140]} title="With a gap" />
```

```tsx
<SpiralYear data={[]} title="Empty" />
```


## Why this default

Month ticks are on by default because without a temporal anchor the spiral is just texture — the ticks are what make
"when" readable. Five steps is the ceiling: ordered opacity supports about five discriminable levels, and more would be
false precision. The spiral **radius encodes time only, never value** — an outer mark is simply a later date, not a
bigger number. Two adjacent turns place different years at the same angle; that radial adjacency is calendar alignment,
not similarity, and the chart never asks you to compare across it. A `null` day leaves a gap in the spiral, distinct
from a faint step-one mark, because missing is not the same as low.

## Accessibility

The accessible name states the count, the peak, and the low — **"52 weeks; peak 1.480 in week 30, low in week 48."**
(the `de-DE` localized demo). The interactive entry lets you arrow along the spiral chronologically, each mark announced
with its period and value through a polite live region. Because the channel is ordinal opacity, the docs and summary
steer any exact read to `ActivityGrid`.

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 or press `Escape`.
On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `(number \| null)[]` | One value per day or week (cadence inferred from length). |
| `cadence` | `"day" \| "week"` | Data cadence; inferred from length (≈52 → week, else day) when omitted. |
| `startDate` | `string` | ISO date anchoring index 0 to a calendar angle. |
| `steps` | `3 \| 5` | Opacity quantization (default 5). |
| `monthTicks` | `boolean` | Faint radial month ticks (default true). |
| `mark` | `"dot" \| "arc"` | Dots (default) or short arc segments. |
| `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).
