Skip to content

Treemap for Angular

AngularCharts

Accessible SVG treemap for hierarchical part-to-whole data: nested rectangles laid out with the squarified algorithm (area proportional to value), one level at a time with drill-down (click, Enter/Space) and a breadcrumb and Backspace to go up, keyboard-reachable tiles in size order with printed labels and tooltips, a generated summary, and a data table of the whole hierarchy.

  • Squarified tilesTile area follows value, largest first; groups sum their children.
  • Drill-downOpen a group with a click or Enter, go back with Backspace or the breadcrumb.
  • Keyboard tilesOne tab stop; arrow keys move between tiles in size order.
  • Data table fallbackA generated summary and a table of the whole hierarchy.

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

import { Component } from '@angular/core';
import { AuiTreemap } from '@absoluteui/angular/treemap';
import type { TreemapNode } from '@absoluteui/components/treemap';
@Component({
selector: 'app-budget',
imports: [AuiTreemap],
template: `<aui-treemap label="Budget" [data]="data"></aui-treemap>`,
})
export class BudgetComponent {
readonly data: TreemapNode[] = [
{ id: 'eng', label: 'Engineering', children: [{ id: 'web', label: 'Web', value: 30 }, { id: 'api', label: 'API', value: 20 }] },
{ id: 'ops', label: 'Operations', value: 25 },
];
}
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 { AuiTreemap } from '@absoluteui/angular/treemap';

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

Class AuiTreemap; template reference #ref="auiTreemap".

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); also the data table caption.
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 (shown path, item count, total, three largest items).
valueFormat NumberFormatOptions Number format for values in tile labels, tooltips, the data table, and the summary (percentages use a percent format).
formatValue (value: number) => string Custom value text; overrides valueFormat everywhere.
data readonly TreemapNode[] Required. Top-level nodes: { id (unique across the tree), label, value?: number | null, children?: TreemapNode[], color?: 1-8 }. Groups default to the sum of their children (a positive own value takes precedence). Zero, negative, and missing values are not plotted. At most 32 levels of nesting.
root string | null null Id of the group to show (drill-down state); null shows the top level. An unknown id or a leaf falls back to the top level. Setting it through update() emits no event.
drillDown boolean true Allow opening groups by click and Enter/Space and going up with Backspace and the breadcrumb. false: groups are plain tiles and no breadcrumb is shown (drillTo() still works).
rootLabel string 'All' Name of the top level in the breadcrumb and the “Showing …” text (default: localized “All”).
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' Shared chart option; a treemap labels its tiles directly and never shows a legend, so it has no effect.
dataTable ChartTableMode 'toggle' Data table of the whole hierarchy (name path, value, share of parent): 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 (label, value, share).
patterns boolean false Texture fills on tiles (by position in the shown level) so neighbors never differ by color alone (always on in forced colors).
height number '300' Plot height in CSS px (integer 120-2000); the width follows the container.
tileLabels boolean true Print the label (groups that open end with “>”) and the value inside tiles that are large enough.
locale string 'en-US' Number and message locale.
direction Direction 'ltr' rtl mirrors the layout (largest tile at the top right), right-aligns tile labels, and swaps ArrowLeft/ArrowRight.
Model Type Change output Description
[(hiddenSeries)] readonly string[] (hiddenSeriesChange) Shared chart option; a treemap has no series, so it has no effect.
Output Payload Description
(drilled) TreemapDrillDetail The shown group changed through a tile (click, Enter/Space), Backspace, the breadcrumb, or drillTo(). id: the shown group (null: top level); path: ids from the top level. Not emitted for update({ root }). Re-emits aui-drill.
(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.
Property Type Description
path Signal<string[]> Ids from the top level to the shown group (empty at the top level).

Call them through a viewChild query or a template reference.

Method Description
drillTo(id: string | null): void Show the group id (null: top level). Ignored for leaves, unknown ids, and the current group. Emits aui-drill and announces “Showing {path}” politely; when focus was in the chart it moves to the largest tile (going down) or the group you came from (going up).
setSeriesVisible(id: string, visible: boolean): void Shared chart method; a treemap has no series, so it only re-renders.

Pattern: SVG treemap as a named, described group (role=“group” with aria-roledescription “treemap”) of role=“img” tiles in size order with roving focus; one level shown at a time with drill-down (Enter/Space, click), Backspace and a breadcrumb (nav “Treemap path”) to go up, a polite announcement of the shown level, and a data table of the whole hierarchy.

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