Distribution chart
The shape of a spread rather than its average — latency, jitter, call duration. A mean of 80ms hides whether that is every call at 80 or half at 20 and half at 140.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
The shape of a spread rather than its average — latency, jitter, call duration. A mean of 80ms hides whether that is every call at 80 or half at 20 and half at 140.
Import
import { DistributionChart } from "@ir/ui";Watch out
- The bars touch. A histogram's bins are a continuous axis cut into pieces, so the 2px gap a BarChart puts between categories would be a lie here — there is nothing between 20–40ms and 40–60ms. Only the group edges breathe.
- One hue, not six. Every bar is the same series, and the x position already carries the order. Colouring bins by their value would spend the identity channel re-encoding what the axis and the bar height both show.
- A marker here is VERTICAL. On a bar chart a threshold is a count — "no more than 20 failures" — and runs across. On a histogram the number anyone cares about is on the measured axis — a p95, an SLA limit — so it runs down.
Props
| Prop | Type | Required | What it does |
|---|---|---|---|
values | readonly number[] | yes | The raw samples. Binning is the component's job, not the caller's. |
bins | number | How many buckets. The range is widened to round numbers, so the edges read. | |
min | number | Pin the measured axis. Useful when two distributions are compared. | |
format | (v: number) => string | Formats a value on the measured axis — "80ms", not "80". | |
xLabel | string | Names the measured axis for the table. | |
markers | readonly DistributionMarker[] | Vertical lines: a p95, an SLA limit. | |
label | string | yes | Sentence for the table caption. |
Do and don't
Show the distribution, and mark the percentile the SLA is written against.
Don't — Report a single average for a latency or jitter figure and move on.
An average is one number standing in for a shape, and the shapes that matter most are the ones it flattens. A bimodal spread — most calls fine, a tail that is not — has the same mean as a tight one centred on the same value, and only one of them is an outage.
Let them touch; only the plot edges breathe.
Don't — Put the bar chart's gap between the bins.
A histogram's x axis is continuous and cut into pieces. A gap says there is something between 20–40ms and 40–60ms, and there is not. The gap on a bar chart means the opposite — those categories really are separate things.
Mark it down the measured axis, where the number anyone quotes actually lives.
Don't — Draw the threshold across the chart, as a count.
On a bar chart a threshold is a count — "no more than 20 failures". On a histogram the counts are incidental; the number in the SLA is on the other axis. A horizontal line here marks a bucket height nobody has an opinion about.
One series, one colour.
Don't — Colour the bins by their value so the chart runs through the series palette.
Position already carries the order and height already carries the count. Spending the identity channel on a third copy of the same information leaves nothing to tell two distributions apart when they are shown side by side.
Accessibility
- The plot is
aria-hidden; the bucket counts are carried by a visually-hidden table, one row per bucket with its range as the label. - Each bucket carries its own
title— the range and the count — so a pointer can read one without a crosshair. - An empty bucket keeps its slot and draws nothing, so a gap in the middle of a spread is visible as a gap rather than closing up.
Where it is drawn
Figma — structure from code, measurements from code.