# ErrorBudget (/docs/charts/error-budget)

A checkout SLO has 62% of its error budget left on day 12 of 30. ErrorBudget plots that remaining line against the
**steady-burn diagonal**, the pace that exactly spends the window, so "too fast" becomes a position: below the diagonal
means you are outrunning the budget. Faster burn-rate reference lines sit below it as faint policy context. The
1×/6×/14.4× multipliers are the Google SRE Workbook's multiwindow burn-rate alert **convention** rather than physics, so
`rates` is configurable and the lines never render data-colored.

```tsx
<ErrorBudget
  data={[1, 0.96, 0.93, 0.9, 0.86, 0.83, 0.79, 0.75, 0.71, 0.67, 0.64, 0.62]}
  window={30}
  unit="day"
  label="remaining"
  title="Checkout SLO"
  width={260}
  height={30}
/>
```

## Install

```tsx
import { ErrorBudget } from "@microcharts/react/error-budget";

<ErrorBudget data={remaining} window={30} title="Checkout SLO" />
```

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 { ErrorBudget } from "@microcharts/react/error-budget/interactive";

<ErrorBudget
  data={remaining}
  window={30}
/>
```

## When to use it

Use it for an SLO error budget in a KPI card, a service list where each row is a budget, and spotting a fast burn before
it exhausts the window. For a plain uptime series use Sparkline; for a one-number budget use Progress.

## Sizing

**fast-burn exhausts the window**

```tsx
<ErrorBudget data={[1, 0.82, 0.6, 0.38, 0.18, 0.04, 0]} window={20} />
```

**diagonal only (quietest form)**

```tsx
<ErrorBudget
  data={[1, 0.96, 0.93, 0.9, 0.86, 0.83, 0.79, 0.75, 0.71, 0.67, 0.64, 0.62]}
  rates={[1]}
/>
```

## Variants

```tsx
<ErrorBudget data={[1, 0.82, 0.6, 0.38, 0.18, 0.04, 0]} window={20} />
<ErrorBudget data={remaining} window={30} rates={[1]} />
```

```tsx
<ErrorBudget data={remaining} window={30} locale="de-DE" />
```

`format` defaults to a percent formatter, and with `locale` it follows that locale's own conventions for the
remaining-budget label: "62 %" with a space before the sign under `de-DE`, rather than the English "62%".

## Edge cases

```tsx
<ErrorBudget data={[]} title="No data yet" />
```

```tsx
<ErrorBudget data={[0.9]} window={30} title="Day 1" />
```

```tsx
<ErrorBudget data={[1, 0.82, 0.6, 0.38, 0.18, 0.04, 0]} window={20} title="Exhausted" />
```

With no data the chart renders an empty root and the accessible name says **"No data."** A single point still draws the
diagonal, the wedges, and the endpoint, though `currentRate` reads `0`, since it needs a prior step: it is the observed
burn slope over the last `max(2, ⌈n/6⌉)` steps divided by the steady slope. Once the remaining line reaches zero, an ✕
at that first zero-crossing replaces the endpoint dot and the summary reads **"Budget exhausted at day 7 of 20."**
instead of the usual remaining-and-rate sentence. Values are clamped to `0–1`, so nothing draws below the floor or above
a full budget.

## Four homes

**In a sentence**

```tsx
<p>
  Checkout SLO budget{" "}
  <span className="mc-inline">
    <ErrorBudget data={remaining} window={30} summary={false} />
  </span>{" "}
  — 34% remaining, burn rate elevated.
</p>
```

**In a table cell**

```tsx
<td>
  <ErrorBudget data={remaining} window={30} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">34%</span>
  <span className="unit">remaining</span>
  <ErrorBudget data={remaining} window={30} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  checkout <ErrorBudget data={remaining} window={30} />
</button>
```

## Accessibility

The accessible name states the budget, the elapsed window, and the burn rate: **"62% of error budget remains at day 12
of 30 — burning at 0.6× the steady rate."** An exhausted window reads "Budget exhausted at day N of M." The interactive
entry steps the days and announces each step's remaining budget and local burn rate.

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[]` | Budget remaining (0–1) per elapsed step; index 0 is 1.0. |
| `window` | `number` | Total steps in the SLO window (default = data.length). |
| `rates` | `number[]` | Burn-rate reference multiples (default the SRE 1×/6×/14.4× convention). |
| `unit` | `string` | Period noun for the summary (default "day"). |
| `label` | `"remaining" \| "none"` | Current budget % in a right gutter. |
| `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).
