Histogram

The distribution of a list of numbers: bars of counts per bin on a counted y axis, with the bin edges on the x axis. The bins and the rounded axis come from d3-array bin() with the Sturges rule, computed on the server, so there is no script. A hidden table gives each bin from, to and count. Motion-ready: every moving value reads --p (build progress 0 to 1, default 1) through a per-item --k, so a motion_timeline track on p grows the bars one after another and the standalone render is the finished picture; reduced motion shows the end state.

Surfaces
webgoogle-apps-script-webmcp-appsandroid
Degraded on
SurfaceNote
pdfPrints the finished picture; no motion
Live preview
API response times
Count of values per bin
0
5
10
15
20
80
100
120
140
160
180
200
Response time (ms)
Bin fromBin toCount
80 ms100 ms5
100 ms120 ms15
120 ms140 ms19
140 ms160 ms7
160 ms180 ms2
180 ms200 ms2
Fields
FieldTypeRequired
titlestring (optional, max 80).optional
valuesarray (required, 5 to 2000) of numbers. Entries that are not finite numbers (text, null, true or false, NaN, Infinity) or whose size is above 1e12 are skipped and counted in a note; with fewer than 5 numbers left a note replaces the chart. Only the first 2000 entries are read.required
binsinteger (optional, 3 to 40). The number of bins to aim for. Default is the Sturges rule, ceil(log2(n)) + 1. d3 rounds the bin edges to 1, 2 or 5 times a power of ten, so the number drawn can differ a little from the number asked for.optional
x_labelstring (optional, max 40). Names the values on the x axis.optional
unitstring (optional, max 12). Appended to the x label and to the edge values in the hidden table.optional
bin_sizenumber (optional, above 0). Explicit bins of this width instead of the Sturges rule; at most 200 bins are drawn, with a note. The last bin ends at bin_end, so it can be narrower than the rest. Draws one series (no overlay or stack as in Plotly). Bins are start + k * size, include their lower edge and exclude the upper, except the last. Values outside the bins are not counted and a note says how many. Not understood values are ignored with a note.optional
bin_startnumber. The first bin edge; default the smallest value rounded down to a multiple of the bin size.optional
bin_endnumber (optional, above bin_start). The last bin edge; default one bin past the largest value.optional
normstring (optional, "percent", "probability", "density" or "probability density"). Normalises count or sum. Percent and probability of the total, density per unit of width, probability density per unit of width of the total. Default counts.optional
cumulativeboolean (optional, default false). Only true switches it on; draws the running total over the bins (count or sum only).optional
funcstring (optional, "count", "sum", "avg", "min" or "max", default "count"). What a bin shows; all but count need `weights` (without them it counts, with a note). An empty bin shows nothing for avg, min and max.optional
weightsarray (optional, same order as values) of numbers, one per value; a value or weight that is not a finite number skips the pair.optional
layoutstring (optional, "bars" or "ridge", default "bars"). "ridge" draws one ridge per entry of `series` on shared bins, to compare distributions; `values` is then not read. Any other value draws bars.optional
seriesarray (optional, read only when layout is "ridge", 1 to 8) of {label (string, max 30, default "Series n"), values (array, 5 to 2000, of numbers, filtered like `values`)}. The shared bins come from d3 bin() of all the series pooled (`bins` applies); each ridge's height is its share of that series' values per bin, so series of different sizes compare. A series with fewer than 5 usable numbers is left out with a note; series beyond the first 8 are noted and not drawn.optional
versioninteger (optional, default 1). The histogram contract the payload was written for. Only version 1 exists; a higher whole number is drawn as version 1 with a note.optional
Example payload
{
  "type": "histogram",
  "values": 1
}
ARD catalog entry
{
  "identifier": "urn:air:a2uicatalog.ai:atom:histogram",
  "displayName": "Histogram",
  "type": "application/vnd.a2ui.atom+json",
  "url": "https://a2uicatalog.ai/atoms/histogram",
  "capabilities": [
    "web",
    "google-apps-script-web",
    "mcp-apps",
    "android"
  ],
  "description": "The distribution of a list of numbers: bars of counts per bin on a counted y axis, with the bin edges on the x axis. The bins and the rounded axis come from d3-array bin() with the Sturges rule, computed on the server, so there is no script. A hidden table gives each bin from, to and count. Motion-ready: every moving value reads --p (build progress 0 to 1, default 1) through a per-item --k, so a motion_timeline track on p grows the bars one after another and the standalone render is the finished picture; reduced motion shows the end state.",
  "representativeQueries": [
    "show a histogram: counts of numbers per bin",
    "the distribution of a list of numbers: bars of counts per bin on a counted y axis, with the bin edge",
    "render a histogram"
  ]
}
← Full ARD catalog
Deploy your own Google Apps Script renderer

The renderer is an open-source Google Apps Script web app. Deploy your own instance in 4 commands — you own the URL, no dependency on the demo endpoint.

git clone https://github.com/a2uicatalog/a2ui
cd a2ui/apps-script-surface/gas-wired-renderer
clasp push && clasp deploy
Full deploy guide →