Skip to content

Histogram for Angular

AngularCharts

Accessible SVG histogram of the distribution of raw numeric values in adjacent bins on a linear axis: automatic bins (Sturges’ rule on nice boundaries), a bin count, or explicit thresholds. Every bin is a keyboard-reachable bar (“10 to 20: 14 values”), with tooltips, a generated summary naming the most frequent bin and out-of-range values, and a data table fallback. The binning is exported as computeBins.

  • 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.

Behavior, design tokens, and limitations are described on the Histogram page; this page covers the Angular API.

import { Component } from '@angular/core';
import { AuiHistogram } from '@absoluteui/angular/histogram';
@Component({
selector: 'app-latency',
imports: [AuiHistogram],
template: `<aui-histogram label="Response times" [values]="values" [bins]="thresholds"></aui-histogram>`,
})
export class LatencyComponent {
readonly values: (number | null)[] = [120, 135, 160, 180, 210, 240, 250, 310];
readonly thresholds: number[] = [100, 150, 200, 250, 300, 350];
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiHistogram } from '@absoluteui/angular/histogram';

Defaults for every instance: provideAbsoluteUIConfig({ components: { histogram: { ... } } }) (see Configuration).

Class AuiHistogram; template reference #ref="auiHistogram".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
label string Required. Chart title: visible text and the accessible name of the plot (aria-labelledby).
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 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.
values readonly (number | null)[] Required. Raw values to bin; null, NaN, and infinities are ignored (counted as missing).
bins number | "auto" | 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 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 ValueAxisInput 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 ChartTooltipRenderer 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 ChartLegendMode 'auto' Accepted for the shared configuration; a histogram never shows a legend (the legend list stays empty and hidden).
dataTable ChartTableMode '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.
tooltip boolean true Tooltip on pointer hover and keyboard focus.
patterns boolean false Toggles the aui-chart–patterns host class; the single bar series draws no texture.
height number '300' Plot height in CSS px (integer 120-2000); the width follows the container.
locale string 'en-US' Number and message locale.
direction Direction 'ltr' rtl mirrors the x axis (lowest bin at the right), puts the count axis on the right, and swaps ArrowLeft/ArrowRight.
Model Type Change output Description
[(hiddenSeries)] readonly string[] (hiddenSeriesChange) Accepted and validated (string[]) for the shared chart contract; a histogram has one data set, so it has no effect.
Output Payload Description
(pointClicked) ChartPointClickDetail 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. Re-emits aui-point-click.

Call them through a viewChild query or a template reference.

Method Description
setSeriesVisible(id: string, visible: boolean): void Inherited from the shared chart controller; no visible effect.

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.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Histogram: Accessibility and performance.