# Seismogram (/docs/charts/seismogram)

Errors arrive in bursts, and the question is when they hit and how hard. Seismogram centers its ticks on a midline and
flares them symmetrically: density is presence, length is intensity. The centered trace keeps the strip from inviting
the bar-to-bar magnitude comparison it is too small to support, and keeps it visually distinct from SparkBar. Long
series collapse via max-per-bucket only, so a spike always survives, and the summary is computed from the raw values
rather than the buckets.

```tsx
import { Seismogram } from "@microcharts/react/seismogram";

<Seismogram
  data={[1, 2, 1, 3, 2, 6, 2, 1, 0, 2, 1, 4, 9, 3, 1, 2, 0, 1, 3, 2, 7, 2, 1, 0, 2, 1, 5, 11, 3, 1]}
  title="Error bursts"
/>
```

## Install

```tsx
import { Seismogram } from "@microcharts/react/seismogram";

<Seismogram data={burstsPerMinute} title="Error bursts" />
```

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 { Seismogram } from "@microcharts/react/seismogram/interactive";

<Seismogram
  data={burstsPerMinute}
/>
```

## When to use it

Use it for error bursts per service, alert density, and activity texture in table rows. For level tracking use
Sparkline; for labeled events use EventTimeline.

## Sizing

**table row**

```tsx
<Seismogram data={service.bursts} width={120} height={14} />
```

**barcode (presence only)**

```tsx
// heights are noise? declare it — uniform ticks say "when", not "how hard"
<Seismogram data={burstsPerMinute} mode="barcode" />
```

**flag anomalies**

```tsx
// spikes at or above the threshold flare in the alert token
<Seismogram data={service.bursts} anomaly={6} />
```

## Variants

```tsx
// magnitudes are noise? say so — uniform ticks are presence only
<Seismogram
  data={[1, 0, 2, 1, 3, 0, 1, 2, 0, 1, 1, 0, 2, 1, 3, 1, 0, 1, 2, 1]}
  mode="barcode"
/>
```

In `barcode` mode every tick is the same length: it records presence and carries no magnitude.

```tsx
// negatives extend below a zero baseline (up = +, down = −)
<Seismogram
  data={[3, -1, 4, -2, 1, 5, -3, 2, -1, 4, -2, 6, -4, 1, -2, 3, -1, 2]}
  positive="up"
/>
```

```tsx
// spikes at or above the threshold flare in the alert token
<Seismogram data={burstsPerMinute} anomaly={6} />
```

`anomaly` flags spikes at or above its threshold in the alert token, on top of the tick length that already shows them,
so the flag never rests on color alone.

```tsx
<Seismogram
  data={[3, -1, 4, -2, 12500, 5, -3, 2, -1, 4]}
  positive="up"
  format={{ maximumFractionDigits: 0 }}
  locale="de-DE"
/>
```

`format` also takes `Intl.NumberFormatOptions` — with a `locale`, the accessible summary's peak number follows that
locale's own grouping ("12.500" in German, not "12,500"). Tick positions and lengths are unaffected; only the announced
peak is localized.

## Edge cases

```tsx
// all-zero data renders the baseline at rest — never a blank hole
<Seismogram data={[0, 0, 0, 0, 0, 0]} />
```

```tsx
// series longer than the pixel width collapse via max-per-bucket ONLY,
// so a single sharp spike never gets averaged away
<Seismogram
  data={Array.from({ length: 300 }, (_, i) => (i === 210 ? 9 : i % 17 === 0 ? 2 : 0))}
/>
```

All-zero data renders the baseline at rest rather than a blank hole. A series longer than the pixel width collapses by
max-per-bucket, so a single sharp spike is never averaged away.

## Four homes

**In a sentence**

```tsx
<p>
  Checkout errors this hour{" "}
  <span className="mc-inline">
    <Seismogram data={burstsPerMinute} width={90} height={16} summary={false} />
  </span>{" "}
  — 29 events, spiking to 11 at minute 28.
</p>
```

**In a table cell**

```tsx
<td>
  <Seismogram data={svc.bursts} domain={[0, 12]} width={90} height={16} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">29</span>
  <span className="unit">events/hr · peak 11</span>
  <Seismogram data={burstsPerMinute} anomaly={6} width={200} height={30} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  checkout-api <Seismogram data={svc.bursts} domain={[0, 12]} width={54} height={14} />
</button>
```

## Accessibility

The accessible name counts the events: **"29 events, peak 11."**, or **"No events."** for a quiet strip. The interactive
entry steps slots with position readouts ("Point 2 of 5: 3."). A quiet slot reads as the zero it is ("Point 1 of 5:
0."), and only a missing sample announces "no data". Home and End jump to the first and last event.

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)[]` | Per-slot event intensity; 0/null = quiet. |
| `mode` | `"intensity" \| "barcode"` | Barcode collapses heights — pure occurrence density. |
| `positive` | `"up" \| "down"` | Polarity coloring of signed ticks. |
| `anomaly` | `number` | Flag spikes: \|v\| ≥ threshold flares in the alert token. |
| `domain` | `[number, number]` | Fixed intensity scale across rows. |
| `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).
