Histogram Chart
histogram-chartHow a set of measurements is distributed, on TanStack Charts. Bins are computed with round edges, the tooltip names each range and its count, and dashed markers put a median or p95 right on the shape.
import { HistogramChart } from "@/components/forme/histogram-chart/histogram-chart";
// API response times in milliseconds: a fast body and a long, slow tail. Generated
// from a fixed sequence rather than Math.random, so the server and client agree.
const latencies = Array.from({ length: 400 }, (_, position) => {
const wave = Math.sin(position * 12.9898) * 43758.5453;
const unit = wave - Math.floor(wave);
const tail = position % 9 === 0 ? 180 * unit : 0;
return Math.round(70 + 90 * unit * unit + tail);
});
const sorted = latencies.toSorted((a, b) => a - b);
const percentile = (share: number) => sorted[Math.floor((sorted.length - 1) * share)] ?? 0;
const median = percentile(0.5);
const p95 = percentile(0.95);
export function HistogramChartDemo() {
return (
<div className="w-full rounded-xl border border-border bg-card p-5 lit edge">
<p className="text-caption-1-medium text-muted-foreground">Response time, last hour</p>
<p className="mt-1 text-body-regular text-foreground">
Half answer within {median} ms; one in twenty takes longer than {p95} ms.
</p>
<HistogramChart
className="mt-5"
label={`Distribution of ${latencies.length} API response times in milliseconds`}
values={latencies}
unit="Requests"
formatValue={(value) => `${value} ms`}
markers={[
{ value: median, label: "p50" },
{ value: p95, label: "p95" },
]}
/>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
HistogramChart
How a set of measurements is distributed: where most of them fall, how long the tail is, whether there are two humps instead of one.
| Prop | Type | Default | Description |
|---|---|---|---|
values* | readonly number[] | — | The observations: response times, order values, session lengths. |
label* | string | — | Accessible name. Say what was measured and how many times. |
bins | number | 12 | Roughly how many bars. The width is rounded to a readable step, so this is a target. |
markers | readonly HistogramMarker[] | [] | Dashed reference lines: a median, a p95, a budget. |
formatValue | (value: number) => string | plain | |
unit | string | "count" | The name of what is counted, for the tooltip. |
height | number | 260 | |
className | string | — |
Related


Bar Chart
A single or grouped column chart in plain SVG. Columns are capped at 24px with rounded tops and 2px gaps, the hovered category lifts while the rest recede, arrow keys read each category, and a hidden table carries every value.
data display

Chart
The tooltip and legend every Forme chart shares: a floating panel with a colour, a name and a right-aligned value per series, and a row of swatches. Installed with any chart; use them directly to give a chart of your own the same finish.
data display

Composed Chart
Columns and a line on one axis, on TanStack Charts: volume against its target, actuals against the plan. Rounded columns side by side, the line drawn over them, and a band cursor that lists every series in the column.
data display