Histogram recipe | kamod chartsSkip to content

Docs

Histogram recipe

Bin numeric samples with computeHistogramBins and render counts with BarChart.

Recipes / Histogram

Response time distribution

Bins use left-closed, right-open intervals, except the last bin which includes its right edge. The helper is count-based only (not density).

Count-based histogram (not density). Tooltip shows the interval label and request count.

API latency distributionSynthetic response times in milliseconds[12, 63)[63, 114)[114, 165)[165, 216)[216, 267)[267, 318)[318, 369)[369, 420]0510152025

Assigned 41 samples · skipped 2 invalid values

import { BarChart, computeHistogramBins, histogramBinsToBarData } from "@kamod-ch/charts";

const histogram = computeHistogramBins(latencyMs, { binCount: 8 });
const data = histogramBinsToBarData(histogram);

<BarChart
  data={data}
  xKey="bin"
  series={[{ key: "count", id: "count", label: "Requests" }]}
  tooltip
/>;

Custom bin edges:

computeHistogramBins(values, { edges: [0, 50, 100, 250, 500] });