Histogram
Introduction
Section titled “Introduction”An accessible SVG histogram of the distribution of raw numeric values in adjacent bins on a linear x axis. It provides:
- automatic bins (Sturges’ rule on nice boundaries), a bin count, or explicit thresholds; bins are lower-inclusive and the last bin is also upper-inclusive;
- the binning as a reusable module function,
computeBins, which also reports missing and out-of-range values; - keyboard-reachable bins (one tab stop), including empty bins, with a tooltip on focus and hover (“10 to 20: 14 values”);
- a count axis that prints integer ticks only;
- a generated accessible summary (value count, bin count, binned range, most frequent bin, values outside the bins) and a data table fallback (bin, count).
- Automatic binsBins from a nice-boundary rule, a bin count, or explicit thresholds.
- Reusable binningThe same binning is available as a function that also reports missing and out-of-range values.
- Keyboard binsOne tab stop through every bin, empty ones included, with a tooltip.
- Data table fallbackA summary naming the most frequent bin and a table of bins and counts.
Use it for
- The shape of a distribution of one numeric variable (response times, amounts, scores).
- Checking skew, spread, and outliers before choosing a summary statistic.
Use something else for
- Comparing categories: use Bar Chart.
- Comparing distributions of several groups: use Box Plot.
- Relationships between two variables: use Scatter Chart.
Anatomy
<div class="aui-chart aui-histogram [aui-chart--patterns]"> <div class="aui-chart__header"> <div class="aui-chart__title" id="T">title</div> <p class="aui-chart__description" id="D">description</p> <div class="aui-chart__toolbar" hidden/> </div> <ul class="aui-chart__legend" aria-label="Legend" hidden/> (always empty) <div class="aui-chart__body"> (height: --aui-chart-height) <svg class="aui-chart__svg" role="group" aria-roledescription="histogram" aria-labelledby="T" aria-describedby="D S"> <g class="aui-chart__grid" aria-hidden="true"/> <g class="aui-chart__axis …" aria-hidden="true"/> <g class="aui-histogram__bars aui-chart__series--c1"> <rect class="aui-chart__mark aui-chart__bar" role="img" aria-label="0 to 10: 14 values" tabindex="0"/> <rect class="aui-chart__mark aui-chart__bar" role="img" aria-label="10 to 20: 0 values"/> </g> </svg> <div class="aui-chart__empty" hidden/> <div class="aui-chart__tooltip" aria-hidden="true" hidden/> </div> <p class="aui-chart__summary" id="S" hidden>generated summary</p> <div class="aui-chart__data">...Show data table...</div></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Histogram in the Analysis showcase
Section titled “Histogram in the Analysis showcase”The part of the Analysis showcase that uses Histogram. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Advanced charts showcase: an analysis page with a bubble chart (zoom, crosshair, a target// line), a combo chart on two axes with a custom tooltip, a profit bridge (waterfall), a// histogram with a reference band, a heatmap, and box plots. Style and animation// are switchable; point clicks are logged.import { BoxPlot } from '@absoluteui/components/box-plot';import { ComboChart } from '@absoluteui/components/combo-chart';import { Heatmap } from '@absoluteui/components/heatmap';import { Histogram } from '@absoluteui/components/histogram';import { ScatterChart } from '@absoluteui/components/scatter-chart';import { WaterfallChart } from '@absoluteui/components/waterfall-chart';import type { ChartTooltipContext } from '@absoluteui/components/combo-chart';import { chartControls, chartLook, choice, createShowcase, hostIn, section, toggle } from './kit.js';
const sc = createShowcase({ title: 'Analysis', description: 'Six analytical charts on one page. Every chart works with the keyboard, has a data table, and can use patterns instead of color alone.',});
const seeded = (seed: number): (() => number) => { let s = seed; return () => { s = (s * 16807) % 2147483647; return s / 2147483647; };};const rnd = seeded(42);
const s1 = section(sc, 'Accounts: revenue against satisfaction', ['scatter-chart']);const scatter = ScatterChart.create(hostIn(s1), { label: 'Accounts by revenue and satisfaction', description: 'Bubble size is the number of seats.', series: ['Enterprise', 'Mid-market', 'Small business'].map((label, k) => ({ id: label.toLowerCase().replace(/\s+/g, '-'), label, points: Array.from({ length: 12 }, (_, i) => ({ x: Math.round((k + 1) * 40 + rnd() * 120), y: Math.round(50 + rnd() * 50), size: Math.round(10 + rnd() * 300), label: `${label} ${String(i + 1)}` })), })), xAxis: { label: 'Annual revenue (k€)' }, yAxis: { label: 'Satisfaction score', min: 40, max: 100 }, sizeLabel: 'Seats', zoom: 'xy', crosshair: true, annotations: [{ type: 'line', axis: 'y', value: 75, label: 'Satisfaction target', tone: 'success' }], height: 300,});
/** Custom tooltip (DOM nodes, never HTML strings): the category and each series on its own line. */const comboTooltip = (context: ChartTooltipContext): Node => { const box = document.createElement('div'); const title = document.createElement('strong'); title.textContent = context.title; box.append(title); for (const r of context.rows) { const line = document.createElement('div'); line.textContent = `${r.label}: ${r.value}`; box.append(line); } return box;};
const grid = hostIn(sc.stage);grid.className = 'sc-grid';const comboSection = section(sc, 'Orders and conversion', ['combo-chart']);const bridgeSection = section(sc, 'Profit bridge', ['waterfall-chart']);const histSection = section(sc, 'Resolution times', ['histogram']);const heatSection = section(sc, 'Requests by day and hour', ['heatmap']);grid.append(comboSection, bridgeSection, histSection, heatSection);const combo = ComboChart.create(hostIn(comboSection), { label: 'Orders and conversion', categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'], series: [ { id: 'orders', label: 'Orders', type: 'bar', values: [420, 460, 510, 480, 560, 610] }, { id: 'conversion', label: 'Conversion rate', type: 'line', axis: 'secondary', values: [0.021, 0.023, 0.026, 0.024, 0.028, 0.031] }, ], primaryAxis: { label: 'Orders' }, secondaryAxis: { label: 'Conversion', format: { style: 'percent', maximumFractionDigits: 1 } }, crosshair: true, annotations: [{ type: 'line', axis: 'y', value: 500, label: 'Order goal' }], height: 260,});const bridge = WaterfallChart.create(hostIn(bridgeSection), { label: 'Profit bridge', steps: [ { id: 'start', label: 'Revenue', kind: 'total', value: 1200 }, { id: 'cogs', label: 'Cost of sales', value: -480 }, { id: 'opex', label: 'Operating costs', value: -310 }, { id: 'other', label: 'Other income', value: 45 }, { id: 'tax', label: 'Tax', value: -110 }, { id: 'net', label: 'Net profit', kind: 'total' }, ], valueFormat: { style: 'currency', currency: 'EUR', notation: 'compact' }, valueLabels: true, connectors: true, height: 260,});const hist = Histogram.create(hostIn(histSection), { label: 'Ticket resolution times', values: Array.from({ length: 400 }, () => Math.round(Math.abs(8 + (rnd() + rnd() + rnd() - 1.5) * 10) * 10) / 10), bins: 'auto', xAxis: { label: 'Hours' }, yAxis: { label: 'Tickets' }, annotations: [{ type: 'band', axis: 'x', from: 0, to: 4, label: 'Within SLA', tone: 'success' }], height: 260,});const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];const HOURS = ['08', '10', '12', '14', '16', '18', '20'];const heat = Heatmap.create(hostIn(heatSection), { label: 'Support requests by day and hour', columns: HOURS, rows: DAYS, values: DAYS.map((_, d) => HOURS.map((__, h) => (d > 4 ? Math.round(rnd() * 8) : Math.round(10 + rnd() * 30 + (h === 1 || h === 4 ? 15 : 0))))), cellLabels: 'auto', height: 260,});const box = BoxPlot.create(hostIn(section(sc, 'Salaries by grade', ['box-plot'])), { label: 'Salaries by grade', categories: ['G1', 'G2', 'G3', 'G4'], series: [ { id: 'eu', label: 'Europe', data: [0, 1, 2, 3].map((g) => Array.from({ length: 30 }, () => 30 + g * 15 + rnd() * 20)) }, { id: 'in', label: 'India', data: [0, 1, 2, 3].map((g) => Array.from({ length: 30 }, () => 12 + g * 8 + rnd() * 10)) }, ], valueAxis: { label: 'Salary (k€)' }, annotations: [{ type: 'line', axis: 'y', value: 50, label: 'Median market salary', tone: 'info' }], height: 280,});
for (const [name, chart] of [ ['scatter', scatter], ['combo', combo], ['waterfall', bridge], ['histogram', hist], ['heatmap', heat], ['box plot', box],] as const) { sc.listen(chart.host, ['aui-series-toggle', 'aui-zoom', 'aui-point-click'], name);}
chartControls(sc, [scatter, combo, bridge, hist, heat, box]);chartLook(sc, [scatter, combo, bridge, hist, heat, box]);toggle(sc, 'Custom combo tooltip', false, (custom) => { combo.update({ renderTooltip: custom ? comboTooltip : undefined });}, ['combo-chart']);choice( sc, 'Whiskers', [ { value: 'tukey', label: '1.5 × IQR (outliers shown)' }, { value: 'minmax', label: 'Minimum to maximum' }, ], 'tukey', (whiskers) => { box.update({ whiskers }); }, ['box-plot'],);toggle(sc, 'Stack combo bars', false, (stacked) => { combo.update({ stacked });}, ['combo-chart']);Response-time distribution with automatic bins
Section titled “Response-time distribution with automatic bins”import { Histogram } from '@absoluteui/components/histogram';
const values = Array.from({ length: 500 }, (_, i) => 80 + ((i * 37) % 200));const host = document.createElement('div');document.body.append(host);const chart = Histogram.create(host, { label: 'Response times', values, binFormat: { style: 'unit', unit: 'millisecond' }, xAxis: { label: 'Response time' },});host.dataset.bins = String(chart.bins.length);Explicit thresholds and computeBins for a custom table
Section titled “Explicit thresholds and computeBins for a custom table”import { Histogram, computeBins } from '@absoluteui/components/histogram';
const scores = [12, 45, 67, 68, 71, 88, 90, 95, null, 102];const thresholds = [0, 50, 70, 90, 100];const { bins, outside, missing } = computeBins(scores, { bins: thresholds });const host = document.querySelector<HTMLElement>('#scores');if (host) { Histogram.create(host, { label: 'Exam scores', values: scores, bins: thresholds, color: 3, dataTable: 'visible' }); host.dataset.counts = bins.map((b) => String(b.count)).join(','); host.dataset.outside = String(outside + missing);}Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { Histogram } from '@absoluteui/components/histogram';import '@absoluteui/components/histogram/style.css';First use
Section titled “First use”import { Histogram } from '@absoluteui/components/histogram';import '@absoluteui/components/histogram/style.css';
const host = document.querySelector<HTMLElement>('#amounts');if (host) { const chart = Histogram.create(host, { label: 'Order amounts', values: [12, 18, 25, 31, 40, 44, 52, 67, 89, 120], bins: 5, min: 0, max: 150, binFormat: { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }, xAxis: { label: 'Amount' }, }); chart.update({ values: [15, 22, 30, 48, 75] });}More usage
import { Histogram, computeBins } from '@absoluteui/components/histogram';
const values = [120, 135, 160, 180, 210, 240, 250, 310, null];const host = document.createElement('div');document.body.append(host);const chart = Histogram.create(host, { label: 'Response times', values, binFormat: { style: 'unit', unit: 'millisecond' } });
// The same binning for a custom table or export.const { bins, outside, missing } = computeBins(values, { bins: [100, 200, 300] });host.dataset.info = `${String(chart.bins.length)} bins; ${String(bins.length)} custom; ${String(outside)} outside; ${String(missing)} missing`;Export: @absoluteui/components/chart-export (chartToSvg, chartToPng, downloadChart) exports any chart instance to SVG or PNG.
Using Angular? See Histogram for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”Histogram.create(host: HTMLElement, options: HistogramOptions): HistogramGlobal configuration key: histogram (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Chart title: visible text and the accessible name of the plot (aria-labelledby). Required. | |
hideLabel |
boolean |
false |
Visually hide the title; it stays the accessible name. |
description |
string |
Visible description below the title, also referenced by aria-describedby (text only). | |
summary |
string |
Replaces the generated accessible summary (aria-describedby). | |
valueFormat |
Intl.NumberFormatOptions |
Number format of bin boundaries (x axis ticks, bar labels, tooltips, table, summary) when binFormat is not set. Counts always use the plain locale number format. | |
formatValue |
(value: number) => string |
Custom text for bin boundaries (x axis ticks included) when binFormat is not set. Counts are not affected. | |
hiddenSeries |
readonly string[] |
Accepted and validated (string[]) for the shared chart contract; a histogram has one data set, so it has no effect. | |
values |
readonly (number | null)[] |
Raw values to bin; null, NaN, and infinities are ignored (counted as missing). Required. | |
bins |
'auto' | number | readonly number[] |
"auto" |
auto: Sturges’ rule on nice boundaries; a number (integer 1-500): about that many bins on nice boundaries; an array: 2-501 ascending thresholds (bin edges). |
min |
number |
Lower edge of the binned domain (finite); with auto or count bins it becomes the exact first edge. Default: a nice boundary at or below the data minimum. Ignored for binning when bins is an array of thresholds (still validated). Values outside the bins are counted and named in the summary. | |
max |
number |
Upper edge of the binned domain (finite, greater than min); with auto or count bins it becomes the exact last edge. Default: a nice boundary at or above the data maximum. Ignored for binning when bins is an array of thresholds. | |
color |
ChartColor |
1 |
Palette slot 1-8 of the bars. |
binFormat |
Intl.NumberFormatOptions |
Number format of bin boundaries (axis, labels, tooltips, table, summary). Default: formatValue, else valueFormat. | |
xAxis |
{ label?: string } |
X axis title (also the first table column header; default “Bin”). | |
yAxis |
{ label?: string; min?: number; max?: number; tickCount?: number; includeZero?: boolean } |
Count axis: title (default “Count”, always drawn), fixed domain (bars taller than max are clipped), and tick count (2-20). Only integer ticks are printed. includeZero is accepted but has no effect (the count axis starts at zero unless min is set). | |
annotations |
readonly ChartAnnotation[] |
Reference lines ({ type: ‘line’, axis: ‘x’ | ‘y’, value, label?, tone? }) and bands ({ type: ‘band’, axis, from, to, label?, tone? }); tone: ‘neutral’ | ‘info’ | ‘success’ | ‘warning’ | ‘danger’. x values are data values (bin scale); y values are counts. Drawn under the marks (aria-hidden); listed in the accessible summary. | |
theme |
ChartTheme |
Look and feel: { palette?: string[] (1-8 CSS colors for slots 1-8); fontFamily?; fontSize? (8-32 px); textColor?; gridLines?: boolean; gridColor?; gridDash? (“4 2” or “none”); axisColor?; lineWidth? (0.5-12 px); markerSize? (1-20 px); cornerRadius?, barRadius?, cellRadius?, sliceRadius?, boxRadius? (0-50 px); swatchRadius? (0-8 px); tooltipRadius?, controlRadius? (0-50 px); lineJoin?: ‘round’ | ‘miter’ | ‘bevel’; areaOpacity? (0-1); gradient?: boolean; valueLabelColor?; tooltip?: { background?, color?, borderColor? }; legendPosition?: ‘top’ | ‘bottom’ | ‘start’ | ‘end’; animation?: boolean | { duration?: number (0-5000 ms) } }. Applied as –aui-chart-* custom properties and classes on the host through the CSSOM (CSP-safe); colors are validated with CSS.supports(‘color’). Animation is opt-in and never runs with prefers-reduced-motion: reduce or [data-aui-animation=‘none’]. | |
renderTooltip |
(context: ChartTooltipContext) => Node | null |
Custom tooltip content as DOM nodes (never HTML strings). context: { title, rows: { label, value, seriesId }[], column, row, source: “pointer” | “focus” | “sync” }. Return null for the default tooltip. The tooltip stays aria-hidden; the focused mark keeps its accessible label. | |
syncGroup |
string |
Synchronized crosshair: charts with the same group show the crosshair, highlight, and tooltip at the same column (category or x index) when one of them is hovered or focused. Focus never moves between charts. Use charts that share their categories or x values. | |
legend |
'auto' | 'show' | 'hide' |
"auto" |
Accepted for the shared configuration; a histogram never shows a legend (the legend list stays empty and hidden). Globally configurable. |
dataTable |
'toggle' | 'visible' | 'hidden' | 'none' |
"toggle" |
Data table fallback with the exact data: behind a Show data table button (built on first open), always visible, visually hidden (screen readers only), or none. Globally configurable. |
tooltip |
boolean |
true |
Tooltip on pointer hover and keyboard focus. Globally configurable. |
patterns |
boolean |
false |
Toggles the aui-chart–patterns host class; the single bar series draws no texture. Globally configurable. |
height |
number |
300 |
Plot height in CSS px (integer 120-2000); the width follows the container. Globally configurable. |
locale |
string |
"en-US" |
Number and message locale. Globally configurable. Inherited from common configuration. |
direction |
'ltr' | 'rtl' |
"ltr" |
rtl mirrors the x axis (lowest bin at the right), puts the count axis on the right, and swaps ArrowLeft/ArrowRight. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
The host element. |
element |
SVGSVGElement |
The plot (svg role=“group”), named by the title and described by the summary. |
summary |
string |
The generated (or custom) accessible summary. |
bins |
readonly HistogramBin[] |
Bins of the current data: { from, to, count }; lower-inclusive, the last bin also upper-inclusive. |
hiddenSeries |
string[] |
Always empty. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
update(options: Partial<HistogramOptions>): void |
Merge, validate, and re-render. Invalid options throw and keep the previous state. Keyboard focus stays on the same mark when it still exists. |
setSeriesVisible(id: string, visible: boolean): void |
Inherited from the shared chart controller; no visible effect. |
destroy(): void |
Remove rendering, host classes, listeners, the resize observer, and the configuration subscription. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-point-click |
HistogramPointClickDetail = ChartPointClickDetail: { seriesId: string | null; column: number; row: number; label: string; series: string; value: string; source: 'pointer' | 'keyboard' } |
Yes | No | A data mark was activated: pointer click or tap, or Enter / Space on the focused mark. label is the category, x value, or item; value is the formatted value text. Keyboard navigation is unchanged. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-chart |
Host (shared chart chrome). |
aui-histogram |
Host modifier for this chart type. |
aui-chart--patterns |
patterns option on: textures (and dash patterns) shown. |
aui-chart__header / __title / __title--hidden / __description |
Title and description. |
aui-chart__legend / __legend-entry / __legend-item / __legend-item--hidden / __legend-label |
Legend list (always empty and hidden for a histogram). |
aui-chart__swatch |
aria-hidden legend and tooltip key (marker, dash, texture). |
aui-chart__body / __svg / __layer |
Plot container (height from –aui-chart-height), SVG, and drawing layer. |
aui-chart__grid / __gridline / __zero-line / __axis / __axis-line / __tick-label / __axis-title |
Axes (aria-hidden). |
aui-chart__series--c1 ... --c8 |
Palette slot classes; set –aui-chart-color from color-chart-<n>. |
aui-chart__mark / __mark--active / __mark--hover |
Focusable data mark and its states. |
aui-chart__tooltip / __tooltip-title / __tooltip-rows / __tooltip-row / __tooltip-label / __tooltip-value |
Tooltip (aria-hidden; the focused mark carries the same text). |
aui-chart__empty |
Empty state text (No data, All series are hidden). |
aui-chart__summary |
Hidden summary referenced by aria-describedby. |
aui-chart__data / __data--hidden / __table-toggle / __table-scroll / __table / __cell--numeric |
Data table fallback. |
aui-chart__bar / __line / __area / __point / __connector / __value-label |
Shared mark styles (chart-marks): bars, lines, areas, point markers, dashed connectors, printed values. |
aui-histogram__bars |
Bars group (carries the aui-chart__series–c<n> slot class). |
aui-chart--legend-bottom / --legend-start / --legend-end |
theme.legendPosition (top is the default layout). |
aui-chart--no-grid / --gradient / --animate / --entering |
theme.gridLines: false, theme.gradient, theme.animation (entering: the render that animates). |
aui-chart__annotations / __annotation-line / __annotation-band / __annotation-label / __annotation--<tone> |
Annotations (aria-hidden), drawn under the marks. |
aui-chart__gradient / __gradient-stop |
Gradient fills (theme.gradient). |
aui-chart__tooltip--custom |
Tooltip content comes from renderTooltip. |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-border-width-strong | --aui-color-border | --aui-color-border-strong | --aui-color-chart-1 | --aui-color-chart-2 | --aui-color-chart-3 | --aui-color-chart-4 | --aui-color-chart-5 | --aui-color-chart-6 | --aui-color-chart-7 | --aui-color-chart-8 | --aui-color-chart-axis | --aui-color-chart-grid | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-hover | --aui-color-info-fg | --aui-color-link | --aui-color-success-fg | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-muted | --aui-color-warning-fg | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-size-xs | --aui-font-weight-medium | --aui-font-weight-regular | --aui-font-weight-semibold | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-radius-sm | --aui-shadow-md | --aui-space-1 | --aui-space-2 | --aui-space-3 | --aui-tooltip-max-width | --aui-touch-target-min
TypeScript definitions
interface HistogramBin { readonly from: number; readonly to: number; readonly count: number }interface HistogramBinning { bins?: 'auto' | number | readonly number[]; min?: number; max?: number }type HistogramConfig = ChartBaseConfig; // { legend; dataTable; tooltip; patterns; height }interface HistogramOptions extends ChartCommonOptions, Partial<HistogramConfig>, HistogramBinning { values: readonly (number | null)[]; color?: ChartColor; binFormat?: Intl.NumberFormatOptions; xAxis?: { label?: string }; yAxis?: HistogramValueAxis; // { label?; min?; max?; tickCount?; includeZero? }}function computeBins(values: readonly (number | null)[], binning?: HistogramBinning): { bins: HistogramBin[]; outside: number; missing: number };Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: SVG chart as a named, described group (role=“group” with aria-roledescription) of role=“img” data marks with roving focus; data table fallback (native table). Follows the WAI Complex Images tutorial (short name plus long description) and the roving tabindex technique of WAI-ARIA APG.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| ArrowLeft / ArrowRight (also ArrowUp / ArrowDown) | Bin focused | Previous / next bin; Left/Right are mirrored in RTL. Empty bins are reachable too. |
| Home / End | Bin focused | First / last bin. |
| PageUp / PageDown | Bin focused | Ten bins back / forward. |
| Escape | Tooltip visible | Hides the tooltip without moving focus (WCAG 1.4.13); it returns on the next move. |
| Tab / Shift+Tab | Any | One tab stop for the plot (the active bin), then the Show data table button and table region. |
| Element | Role |
|---|---|
| svg.aui-chart__svg | group with aria-roledescription (localized chart type), named by the title |
| data marks | img with an aria-label: bin range and value count |
| axes, tooltip | aria-hidden (decorative duplicates of the accessible data) |
| data table | table (native) with caption, column headers, and row headers; wide tables scroll in a focusable region |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-labelledby |
svg | id of the visible (or visually hidden) title |
aria-describedby |
svg | description id (when provided) and the generated summary id |
aria-roledescription |
svg | Localized “histogram” |
aria-label |
each mark | Localized “{from} to {to}: {count} values” (pluralized) |
tabindex |
active mark | 0 on exactly one mark (roving); other marks have none |
aria-expanded / aria-controls |
Show data table button | Table open state and the table region id |
Roving focus: one bin is in the tab sequence and remembers the last visited bin across re-renders (resize, update). Toggling the table keeps focus on the table button.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- The generated summary names the value count, bin count, the binned range, the most frequent bin, and values outside the bins.
- One data set, so no color coding is needed; bars are separated by a surface-colored outline.
- Forced colors: bars use CanvasText with a Canvas outline (hovered and active bar outlined in Highlight); gridlines GrayText, axes and text CanvasText; focus uses Highlight.
- No animation: nothing moves on render; hover and focus emphasis transitions are removed under prefers-reduced-motion and animation: none.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver, TalkBack) is pending.
- aria-roledescription support varies; screen readers without it announce “group”.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/histogram |
52.8 kB | 18.5 kB | 16.6 kB | 2.3 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| Histogram.create, 10,000 values, including binning and the first render | < 40 ms in headless Chromium (e2e performance test) |
Tested scale: Measured in tests/e2e/perf-r3.spec.ts with 10,000 values. Binning is one pass for the extent plus a binary search per value; the DOM has one node per bin (Sturges asks for 15 bins at 10,000 values; a bin count of up to 500 gives about that many). The data table is built only when opened (toggle mode).
Budget: Histogram 10,000 values create < 40 ms in headless Chromium (e2e performance test), including binning and the first render (tests/e2e/perf-r3.spec.ts). Binning is one pass for the extent plus a binary search per value; the DOM has one node per bin; the data table is built only when opened in toggle mode.
Measured run times: Performance.
Details
Section titled “Details”States
default, empty (“No data”), bin focused (tooltip), hovered, table open.
State transitions
| From | Trigger | To |
|---|---|---|
| plot not focused | Tab | active bin focused, tooltip shown |
| bin focused | arrow keys, Home, End, PageUp, PageDown | another bin focused |
| tooltip visible | Escape | tooltip hidden, focus unchanged |
| table closed | Show data table | table built and shown |
| any | update({ values }) |
bins recomputed and re-rendered; focus kept on the same bin index |
| any | container resize | re-render at the new width; focus kept on the same bin |
Accessibility notes
- The summary names the type, value count, bin count, the binned range, the most frequent bin, and values outside the bins, for example “histogram, 8 values in 4 bins, from 0 sec to 8 sec. Most values: 2 sec to 4 sec (5 values).” Values outside the bins add “3 values outside the bins.”
- One data set, so no color coding is needed; adjacent bars are separated by a surface-colored outline.
- Forced colors: bars use
CanvasTextwith aCanvasoutline; the hovered and active bar and focus useHighlight. Nothing animates. - Manual screen-reader verification (NVDA, JAWS, VoiceOver, TalkBack) is pending.
Responsive behavior
The width follows the container (ResizeObserver); the height is height. Bin edge labels are thinned (every k-th edge) so they never crowd. Reflows at 320 CSS px.
Right-to-left
direction: 'rtl' mirrors the x axis (lowest bin at the right), puts the count axis on the right, and swaps ArrowLeft/ArrowRight.
Theming
The bar color comes from color-chart-<n> via color (slot 1 by default). Gridlines use color-chart-grid, axes color-chart-axis, the hovered or active bar outline color-text.
Global configuration
configureAbsoluteUI({ components: { histogram: { dataTable: 'visible', height: 260 } } });Changes apply to existing instances immediately.
Component configuration
Instance options override global and theme defaults. All options are dynamic.
Timezones
Not applicable: numeric axes only; no dates are formatted.
Icons
None. No legend or toolbar is shown.
Security
All text uses textContent; SVG is built with createElementNS. Colors are classes; sizes and the tooltip position are written through the CSSOM. No innerHTML, style attributes, or inline handlers.
Data handling
Renders the given data only; no persistence, network access, or telemetry. Values are not logged; validation errors name the option, never its value.
Supported data scale
Tested with 10,000 values. Up to 500 bins (count) or 501 thresholds; the value count is not capped, and DOM size depends on the bin count only.
Edge cases
- No values, or only missing values: “No data”.
- A value equal to an inner edge falls in the upper bin; a value equal to the last edge falls in the last bin (for example thresholds
[0, 10, 20]: 10 counts in 10-20, 20 counts in 10-20). - Values outside
min/maxor the thresholds are counted inoutside, named in the summary, and included in the summary’s value count; they are in no bin. - Missing values (
null,NaN, infinities) are excluded from all counts exceptmissing. - All values equal: the domain is padded around the value (10% each side, or 0-1 for zero).
- Empty bins are zero-height bars that stay focusable.
- Counts above a fixed
yAxis.maxare clipped at the top of the plot. formatValueapplies to bin boundaries unlessbinFormatis set; counts are never custom-formatted.
Errors
| Code | Category | Cause |
|---|---|---|
HISTOGRAM_OPTIONS |
configuration | Missing label; values not an array of numbers or null; bins not 'auto', an integer 1-500, or 2-501 strictly ascending finite thresholds; non-finite min/max; max not greater than min; color outside 1-8; invalid binFormat, xAxis, or yAxis. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid or unknown configuration. |
A failed construction leaves the host untouched; a failed update() keeps the previous state. computeBins does not validate.
Known limitations
- One data set per chart (no overlaid distributions).
- Bins are lower-inclusive; the last bin is also upper-inclusive.
- A bin count is approximate (nice boundaries), unless
minandmaxfix the outer edges. - Only integer count ticks are printed.
- Manual screen-reader verification is pending.
- Animation is opt-in (
theme.animation) and replays after each data or option change; it never runs withprefers-reduced-motion: reduceor[data-aui-animation='none']. syncGroupmatches charts by column index (category or x index); use it for charts that share their categories or x values.- No zoom or pan: change the bin range (
min,max,bins) instead.
Unsupported scenarios
- Density curves, cumulative histograms, and logarithmic axes.
- Weighted values.
- Zoom, pan, and crosshair.
- HTML in labels or tooltips.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.