API REFERENCE · CHARTS
<dj-sparkline>
A tiny inline chart of one numeric series, with no axes, grid, legend, tooltip, or margins.
data is a plain array of numbers. For a full chart with axes and interaction, use <dj-chart>: the sparkline shares its math but is a separate, much smaller component.
npm install @dojo-ng/chart
import "@dojo-ng/chart";
Live data
push()appends one or more values without rebuildingdata, for cheap live updates.max-pointslimits how many values it keeps.
Accessibility
- With a
label, the sparkline hasrole="img", that name, and a generated summary ("N points, min X, max Y, last Z") in the page's locale. - Without a
labelit isaria-hidden. That is the common case, when text next to it already states the value, as in a row of key figures with a trend beside each number.
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
data |
Property only | number[] |
[] |
typeMark type. line/area share one path; bar renders one rect per point. |
type reflected |
"line""area""bar" |
"line" |
labelAccessible name; when unset the sparkline is aria-hidden (see the class doc). |
label |
string |
None |
markerShow a dot at the last point. Ignored for type="bar". |
marker reflected |
boolean |
false |
minFixed domain minimum; defaults to the data's own minimum. |
min |
number |
None |
maxFixed domain maximum; defaults to the data's own maximum. |
max |
number |
None |
maxPointsCap on data values kept after push appends; 0 (default) is unbounded. Old values are trimmed from the front, so the sparkline shows a sliding window. |
max-points |
number |
0 |
CSS parts
Style these with dj-sparkline::part(name).
basemarker
CSS custom properties
| Property | Default | Description |
|---|---|---|
--dj-sparkline-width | 8em | Host width. |
--dj-sparkline-height | 1.5em | Host height. |
--dj-sparkline-color | None | Line/area/bar color; defaults to dj-chart's series-1 token (--dj-chart-1, #2563eb). |
--dj-sparkline-marker-size | 0.25em | Diameter of the last-point marker dot. |
Methods
| Method | Description |
|---|---|
push(value: number | number[]) | Append one or more values without rebuilding data yourself. Multiple calls within the same animation frame coalesce into a single data assignment. Trims from the front to max-points when set. Sparklines have no transitions, so nothing else changes on append. |