Angular Area Chart
An Angular area chart built on D3: each series is a line with the space beneath it filled in, so it shows how much as well as which way. With zoom, a hover crosshair, point images and ranges.
Three series
Three series, other values
Axes hidden
Point images
Set image on a data point to draw it in place of the dot, sized by the config's pointImage box. Points without an image keep their dot.
Forecast with icons
Point colors
Set color on a data point to draw its dot in that color in place of its series' — to flag a reading below a threshold, say. Its ring and its hover fill take the color; the area keeps the series'. Say why in words too, in the tooltip or the chart's ariaLabel, for readers who can't tell the colors apart. See the Line Chart's demo.
When To Use An Area Chart
An area chart is a line chart with the space beneath each line filled in. The fill turns the line into an amount: the reader sees not just where a series is but how much of it there is, so an area chart suits values that are volumes or totals over time — requests served, energy used, revenue earned, people in a building. Reach for one when:
- the size of each series matters as much as its trend, and its values start from a meaningful zero;
- there are only a few series, two or three, so the overlapping fills stay readable;
- one series is mostly larger than the others, or the series rarely cross, so each fill keeps its own band.
Use the line chart instead when the series cross often, when there are more than three or four of them, or when the y axis doesn't start at zero — there, the fills would stack up into a muddy block, or claim an amount that isn't there. To compare totals at a single moment rather than over time, a bar chart is easier to read; and for how a single total splits into parts, see the pie and donut charts.
How The Areas Are Drawn
Each series in data becomes one filled shape, running from its points down to the bottom of the plot — the y axis' domainMin, 0 by default. The series are overlaid rather than stacked: every area starts from that same floor, at half opacity, in the order they appear in data, so a later series is painted over an earlier one and the overlap shows as a blend of the two colors. The area itself has no outline; its points carry the dots, the tooltips and (dotClicked), exactly as on the line chart.
- Order matters. Put the series that is usually largest first, so the smaller ones are drawn over it rather than hidden behind it.
- Mind the floor. Because the fill runs down to
yAxis.domainMin, raising it to zoom in on a narrow band crops every area at the same line. That's fine for a line chart; on an area chart it exaggerates the differences between series, so keep the floor at zero when the size of the area is the point. - Gaps stay gaps. A point with no numeric
valuebreaks the area there instead of dropping it to zero, so missing data isn't drawn as a dip. - Hidden series keep their color. A series with
hide: trueisn't drawn, but keeps its place in the palette, so a legend that toggles series never reshuffles the colors of the rest.
Stacked Areas
The chart doesn't stack series for you, but a stacked area chart — each series sitting on top of the ones before it, so the top edge is the total — is a few lines of data preparation away: give each series the running total up to and including it, then reverse the order so the tallest band (the total) is drawn first and every smaller one over it.
import { PcacData } from '@pioneer-code/pioneer-charts';
/**
* Stacks series that share the same x keys, in the same order: each point's value becomes the
* running total of the series up to and including it. Returned tallest first, for drawing order.
*/
function stack(series: PcacData[]): PcacData[] {
const totals = series[0]?.data.map(() => 0) ?? [];
return series
.map((s) => ({
...s,
data: s.data.map((point, i) => ({ ...point, value: (totals[i] += Number(point.value ?? 0)) })),
}))
.reverse();
}
config = { ...config, data: stack(config.data) };Two things change with stacked data: a point's tooltip and the hover crosshair show the running total rather than the series' own value (a custom tooltip can show the original, from a field you keep on the point), and the series are now in reverse order, so pass a reversed colorOverride, or list a legend's items in the same reversed order, if the colors need to match something else.
Markup
<pcac-area-chart [config]="config" (dotClicked)="onClicked($event)"/>
API
import { PcacAreaChart } from '@pioneer-code/pioneer-charts';Configuration
| Name | Description |
|---|---|
| data | Collection of PcacData objects. |
| height | Height of chart component. Default is 200px. |
| ariaLabel | What the chart shows, for screen readers — e.g. 'Sales by month, 2026'. The chart is announced as a group with this name, and each bar, slice or point inside it by its own key and value (see Accessibility). When omitted, its type is used: 'Bar chart', 'Pie chart', 'Line chart' and so on. |
| heightFull | If true, height is treated as a minimum height and the chart grows to fill its container whenever that container is taller. Default is false.
|
| xAxis / yAxis | Per-axis settings, one PcacAxisConfig for each axis. Every field is optional; omit the whole object for a default axis. See the Axis Styling guide for a live demo.
|
| yAxis.domainMin | Floor of the y-axis domain. Default is 0. |
| yAxis.domainMax | Ceiling of the y-axis domain. Default is 100. |
| yAxis.format | Formats the y-axis tick labels, the hover crosshair's value and the value shown in a point's tooltip.
|
| xAxis.format | Controls both how each point's key is mapped to an x position and how the x-axis tick labels are formatted.
|
| xAxis.domainMin | Start of the x-axis domain. Only used when xAxis.format is Decimal (a number, default 0) or DateTime (anything new Date() accepts; required). Ignored by the index-based formats, which size the axis from the data. |
| xAxis.domainMax | End of the x-axis domain. Same rules as xAxis.domainMin; the Decimal default is 100. |
| enableEffects | If true, hovering the chart shows a vertical crosshair with the interpolated value of every line or area at that x position. Default is true when the config is created with new; an object literal (or JSON) that omits it gets no effects. |
| enableZoomX | If true, the chart can be zoomed along the x-axis with the mouse wheel (1x to 10x) and panned by dragging, staying within the original domain; lines, areas, points, the x-axis and its grid all follow. Default is false. |
| enableZoomY | The same along the y-axis: zoom (1x to 10x) and pan within the y domain, with the y-axis and its grid following. Independent of enableZoomX — set either or both. With only one on, the other axis just stays put during a gesture. Default is false. A zoom survives the chart redrawing — a new config, a series toggled in a legend, a resize — and is dropped when zoom is turned off or the zoomable axes change. |
| colorOverride | Array of hex color codes, one per series in order, used instead of the theme palette for that series' line/area and dots. Series beyond the array's length get no color, so supply one entry per series when using it. Omitted or empty, the theme palette is used. |
| pointRadius | Radius of each point's dot at rest, in px. Default 4. A hovered or focused dot grows to 1.5× that, and never to less than 4px. 0 draws no dots at rest — for a sparkline or a dense series — while each point can still be hovered, focused and clicked, and still shows its tooltip. Meant for line and area charts: a plot chart has no line, so it would show nothing until hovered. Doesn't affect point images. |
| pointImage | Bounding box for point images: { maxWidth: number, maxHeight: number }, both defaulting to 16. A data point with an image (a URL or data URI) is drawn as that image instead of a dot, scaled to fit inside this box with its aspect ratio preserved and centered on the point. It gets the same tooltip and (dotClicked) behavior as a dot (only the hover enlarge effect is dot-only). |
| pointRange | Draw each point's range (on the innermost data: range: { x?: { min, max }, y?: { min, max } }, where x is read like the point's key for the x axis' format — a number, a date, or an index for the index-based formats; a min above its max is read the other way round, and one equal to it as no range on that axis). Plot, line and area charts. Off when omitted; {} turns it on with the defaults below. Ranges sit above the lines and areas and below the points, on the point's true coordinate (a fanned-out point's range stays on its anchor), clipped to the plot and following zoom. Nothing is labeled; a custom tooltip gets the point, range included. There's a live demo of every option, on all three chart types, on the Plot Chart page.
|
Events
| Binding | Description | Payload |
|---|---|---|
| (dotClicked)="onClicked($event)" | Emitted when a point (its dot, or its image) is clicked. It emits a copy of the item; set its id to trace it back to your record (see Data Contract). | PcacData |