# QuantileDots (/docs/charts/quantile-dots)

QuantileDots draws a sample or a posterior as 20 dots, each one an equal-probability quantile. A dot is therefore about
a **1-in-N chance**, not a raw observation. Add a `threshold` and the dots past the line are re-inked and ringed, and
the summary reports the answer as a frequency ("10 in 20") rather than a percentage. Two cues carry the count, so it
survives grayscale, print, and forced-colors.

```tsx
<QuantileDots
  data={Array.from({ length: 200 }, (_, i) =>
    Math.round(4 + (i % 30) * 0.35 + ((i * 7) % 13) * 1.1 + (i % 50 === 0 ? 20 : 0)),
  )}
  threshold={15}
  format={{ style: "unit", unit: "minute", unitDisplay: "short", maximumFractionDigits: 0 }}
  title="Bus wait"
  width={260}
  height={30}
/>
```

## Install

```tsx
import { QuantileDots } from "@microcharts/react/quantile-dots";

<QuantileDots data={waits} threshold={15} format={(n) => `${n} min`} title="Bus wait" />
```

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 { QuantileDots } from "@microcharts/react/quantile-dots/interactive";

<QuantileDots
  data={waits}
  threshold={15}
/>
```

## When to use it

Use it for a "will we miss the SLA?" read in a sentence, countable odds in a KPI card, and a posterior communicated as a
frequency rather than a percent. For a precise distribution shape use HistogramStrip; for one estimate's interval use
GradedBand.

## Sizing

**count the odds past a line**

```tsx
<QuantileDots data={waits} threshold={15} side="above" />
```

**fewer dots — faster to count**

```tsx
<QuantileDots data={waits} count={15} threshold={15} />
```

## Variants

```tsx
<QuantileDots data={waits} count={15} threshold={15} />
<QuantileDots data={waits} threshold={10} side="below" />
```

`format` also takes `Intl.NumberFormatOptions` — with a `locale`, the announced threshold follows that locale's own
grouping and decimal marks.

```tsx
<QuantileDots
  data={waits}
  threshold={15000}
  format={{ style: "unit", unit: "minute", unitDisplay: "narrow" }}
  locale="de-DE"
/>
```

## Edge cases

```tsx
<QuantileDots data={[]} title="No samples" />
```

```tsx
<QuantileDots data={[7, 7, 7, 7, 7]} title="Certain outcome" />
```

```tsx
<QuantileDots data={waits} threshold={9999} side="above" />
```

Empty data draws nothing and the summary says so. An all-equal sample collapses every dot into one column: that is
certainty in the sample, not a rendering glitch. A threshold outside the observed range reads as 0 in N (or N in N), so
the count always reports the fraction of the field it catches.

Use `count` to change how many dots the sample is quantized into; 20 is the default because a reader subitizes a handful
of highlighted dots faster than they parse "48%".

## Four homes

**In a sentence**

```tsx
<p>
  Bus wait times{" "}
  <span className="mc-inline">
    <QuantileDots data={waits} threshold={15} summary={false} />
  </span>{" "}
  — 16% of waits exceed the 15 min SLA.
</p>
```

**In a table cell**

```tsx
<td>
  <QuantileDots data={waits} threshold={15} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">16%</span>
  <span className="unit">over 15 min</span>
  <QuantileDots data={waits} threshold={15} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  Route 42 <QuantileDots data={waits} threshold={15} />
</button>
```

## Accessibility

The accessible name states the odds as a frequency: **"8 in 15 chances above 15 min."** Without a `threshold` it reads
"Most likely …; range …" instead. In the interactive entry, hovering or arrowing moves a live threshold and the count
past it recomputes as you go.

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[]` | Raw sample or posterior draws — the component derives the quantile dots. |
| `count` | `number` | Number of quantile dots (default 20; 15–20 recommended; capped at 25). |
| `threshold` | `number` | The decision line — turns the plot from shape into odds. |
| `side` | `"above" \| "below"` | Which side of the threshold is the event being counted. |
| `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).
