Histogram
How values spread: how many requests took 0–50 ms, 50–100 ms… The ranges are round and the bars touch, because the ranges do.
import { Histogram } from '@sypnia/ui/react'
On this page
Response times
Response time
400 requests, last hour
View as table
| Time | Count |
|---|---|
| 0 ms – 100 ms | 160 |
| 100 ms – 200 ms | 209 |
| 200 ms – 300 ms | 0 |
| 300 ms – 400 ms | 0 |
| 400 ms – 500 ms | 3 |
| 500 ms – 600 ms | 6 |
| 600 ms – 700 ms | 6 |
| 700 ms – 800 ms | 6 |
| 800 ms – 900 ms | 8 |
| 900 ms – 1000 ms | 2 |
Code
import { Histogram } from '@sypnia/ui/react';
// How long 400 requests took. Most are fast; a tail is slow.
const values = Array.from({ length: 400 }, (_, i) => Math.round(40 + ((i * 37) % 97) + (i % 13 === 0 ? 400 + (i % 7) * 60 : 0) + (i % 5) * 9));
export default function Latency() {
return <Histogram title="Response time" subtitle="400 requests, last hour" values={values} unit="Time" formatValue={(v) => `${v} ms`} />;
} When to use it
Use it when
- Times, sizes and other measures where the shape matters: most fast, a slow tail.
Do not use it when
- Categories: use BarChart.
For everyone
- Each bar is named with its range and count; the table lists every range.
Props
| Histogram | Type | Default |
|---|---|---|
titlerequired | ReactNode | |
valuesrequired | number[] | |
binCount | number | 12 |
empty | ReactNode | |
error | ReactNode | |
formatValueHow a value is written on the axis: «120 ms». | Fmt | |
height | number | |
loading | boolean | |
subtitle | ReactNode | |
unitThe header of the first column of the table view. | string | Range |