Skip to content

Sparkline for Angular

AngularCharts

Word-sized inline trend graphic (line or bars) for text, tables, and cards: a static svg role=“img” with a generated accessible name summarizing count, first and last value, minimum, and maximum.

  • Word-sized trendA small line or bar graphic for text, table cells, and KPI tiles.
  • Generated nameThe accessible name summarizes count, first, last, minimum, and maximum values.
  • Cheap at scaleNo layout reads on creation, so hundreds per page stay fast.
  • Last value markerHighlights the most recent value by default.

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

import { Component } from '@angular/core';
import { AuiSparkline } from '@absoluteui/angular/sparkline';
@Component({
selector: 'app-kpi',
imports: [AuiSparkline],
template: `<p>Sign-ups 230 <aui-sparkline label="Weekly sign-ups" [values]="trend"></aui-sparkline></p>`,
})
export class KpiComponent {
readonly trend = [120, 132, 150, 170, 230];
}
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 { AuiSparkline } from '@absoluteui/angular/sparkline';

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

Class AuiSparkline; template reference #ref="auiSparkline".

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

Input Type Default Description
label string Required. What the values are, for example “Revenue, last 12 months”; starts the accessible name.
values readonly (number | null)[] Required. Values in order; null, NaN, and infinities are gaps.
variant SparklineVariant 'line' Line or bars (bars include zero and draw negatives below a baseline).
color SparklineColor '1' Palette slot (color-chart-<n>).
min number Fixed domain minimum (for comparable sparklines).
max number Fixed domain maximum.
valueFormat NumberFormatOptions Number format for the accessible name.
formatValue (value: number) => string Custom value text for the accessible name.
valueText string Replaces the generated accessible name.
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’]. The sparkline uses palette, lineWidth, axisColor (bar baseline), and animation.
highlightLast boolean true Mark the last value (dot for line, full opacity for bar).
locale string 'en-US' Number, date, and message locale.
direction Direction 'ltr' rtl mirrors the category/x axis, the value axis side, and Left/Right arrow keys.

Pattern: Static informative image: svg role=“img” with a generated accessible name (WAI Images tutorial, informative images).

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