Skip to content
Calm motion: animations on this site only fade, with no movement

Histogram ​

Raw values in round bins, as bars

Shows the shape of many values, for example how long people listen: where most values are, and whether there are two groups. For the spread of values in a few groups side by side, use the box plot.

Basic
Time listenedMinutes, 400 listeners of episode 41
Minutes listened
RangeCount
0–577
5–1056
10–1536
15–2035
20–2527
25–3024
30–3511
35–4027
40–4582
45–5025
  • values is a list of raw numbers. The chart counts them in bins of equal width. A value that is not a number is left out.
  • bins is about how many bins (default 10). The edges are round numbers, so the real count can be a little different. A bin holds the values from its start up to its end, and the last bin also holds its end.
  • The bars touch, because the bins have no gaps between them. The edges of the bins are on the x axis. A hover on a bar shows its range and count.
  • color sets the color of the bars, as a token name or any CSS color (default chart-1). The chart draws at the width of its container, and height sets the height (default 240).
  • The chart is hidden from screen readers, and a table of the ranges and counts is read in its place. label names the table, and format sets the text of an edge. Change the column names with labels or a label pack: range and count.
  • The chart is drawn as plain SVG. There is no chart library to install.

Usage ​

ts
import { BlessHistogram } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
values*number[]—the raw values; the chart counts them in bins
binsnumber10about how many bins; the edges are round numbers
colorstring"chart-1"
heightnumber240
format((v: number) => string)—text for a bin edge, for example `(v) => v + " min"`
labelstring"Chart"names the chart and its table for screen readers
labelsPartial<{ range: string; count: string; }>—

Released under the MIT License. Character names and artwork belong to their owners.