# EventRaster (/docs/charts/event-raster)

EventRaster draws one tick per event and one lane per source, all on a shared time domain. A vertical band means those
sources fired together, a diagonal means one triggered the next, and a sparse row means silence. Lanes stay aligned to
that shared domain because the banding is the phenomenon the chart exists to show. One tick is always one event; the
single exception is `overflow="bin"`, and the summary discloses it.

```tsx
<EventRaster
  data={[
    { label: "api", events: [2, 5, 6, 14, 20, 21, 33, 40, 41, 48, 55] },
    { label: "db", events: [3, 6, 15, 21, 34, 41, 55] },
    { label: "cache", events: [6, 21, 41, 55] },
    { label: "queue", events: [10, 30, 50] },
  ]}
  title="Service events"
  width={300}
  height={56}
/>
```

## Install

```tsx
import { EventRaster } from "@microcharts/react/event-raster";

<EventRaster data={services} title="Service events" />
```

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 { EventRaster } from "@microcharts/react/event-raster/interactive";

<EventRaster
  data={services}
/>
```

## When to use it

Use it for service events across sources, agent steps, and cron or sensor triggers. For a single lane use RugStrip; for
continuous rates use Sparkline.

## Sizing

**table cell**

```tsx
<EventRaster data={row.lanes} labels={false} width={80} height={24} />
```

**emphasis**

```tsx
<EventRaster data={services} emphasis="api" />
```

## Variants

```tsx
<EventRaster data={services} emphasis="api" />
```

## Edge cases

```tsx
<EventRaster data={[{ label: "api", events: [2, 5, 6, 14, 20, 33, 40, 48] }, { label: "db", events: [] }]} />
```

```tsx
<EventRaster
  data={[{ label: "requests", events: Array.from({ length: 200 }, (_, i) => i * 0.3) }]}
  overflow="bin"
/>
```

```tsx
<EventRaster data={[{ label: "boot", events: [0] }]} />
```

An empty lane keeps its row, because a source that stopped firing is part of the reading. When a lane is dense enough
that its ticks would alias into a solid smear, `overflow="bin"` (the default) switches that lane to per-bucket counts
drawn as opacity, and the summary names the lanes that were binned. `overflow="clip"` opts out and keeps one tick per
event at any density.

## Four homes

**In a sentence**

```tsx
<p>
  Service events this hour{" "}
  <span className="mc-inline">
    <EventRaster data={services} summary={false} />
  </span>{" "}
  — checkout-api busiest, 9 events.
</p>
```

**In a table cell**

```tsx
<td>
  <EventRaster data={services} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">9</span>
  <span className="unit">checkout-api/hr</span>
  <EventRaster data={services} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  checkout <EventRaster data={services} />
</button>
```

Best at KPI/card scale — multi-lane rasters need height per series.

## Accessibility

The accessible name summarizes the field: **"3 lanes, 22 events; busiest api (11)."** The interactive entry roves lanes
with ↑/↓ and events with ←/→, announcing each event's lane, time, and position within the lane.

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) | `{ label, events }[]` | One lane per source. |
| `emphasis` | `string` | Accents one lane — the sync read. |
| `labels` | `boolean` | Left-gutter lane names (on ≤ 8 lanes). |
| `overflow` | `"bin" \| "clip"` | Aliasing lanes bin to counts (disclosed). |
| `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).
