PlAreaChart
A line with the space under it filled, which changes what the chart is about. A line says where a value went; an area says how much of something there was, and stacked it says how that amount was made up.
import { PlAreaChart } from 'plass-ui';
<PlAreaChart series={traffic} categories={months} stacked />;import 'package:plass_ui/plass_ui.dart';
PlAreaChart(
series: traffic,
categories: months,
stacking: PlAreaStacking.total,
);That is the whole test for using this instead of a line chart: if the quantity does not add up to anything (a temperature, a rate, a score) the fill under it is decoration, and a chart with two of them is two washes fighting.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| series * | readonly PlassChartSeries[] | — | The data |
| categories | readonly PlassChartCategory[] | — | What the category axis says |
| curve | 'linear' | 'smooth' | 'step' | 'linear' | How the edge of the band gets from one point to the next. The same three shapes PlLineChart offers |
| stacked | boolean | 'full' | false | Stacks the bands. 'full' normalises every category to 100%, so the chart is about share and stops being about size |
| markers | 'none' | 'auto' | 'all' | 'none' | Dots on the points. none by default: a filled band already has a visible edge |
| valueLabels | 'none' | 'last' | 'extremes' | 'all' | 'none' | Which values are written on the bands |
| connectNulls | boolean | false | Draws the band through a gap. It matters more than on a line: a fill that closes across a gap paints a made-up number over a larger part of the chart |
| xAxis | PlassChartAxis | — | The category axis |
| yAxis | PlassChartAxis | — | The value axis |
| legend | PlassChartLegend | — | The legend |
| tooltip | PlassChartTooltip | — | The tooltip |
| height | number | string | — | How tall the plot is |
| format | Intl.NumberFormatOptions | — | How a value is written |
| label | string | 'Chart' | What the whole drawing is called |
| empty | ReactNode | — | What is drawn when there is nothing to draw |
| sizeshared | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Type scale, plot height and line weight |
| Prop | Type | Default | Description |
|---|---|---|---|
| series * | List<PlassChartSeries> | — | The data |
| categories | List<PlassChartCategory>? | — | What the category axis says |
| curve | PlChartCurve | PlChartCurve.linear | How the edge of the band gets from one point to the next. The same three shapes PlLineChart offers |
| stacking | PlAreaStacking | PlAreaStacking.none | How the bands are stacked. A single enum rather than React's boolean | 'full', because Dart has no union type — and three named states read better than a boolean with an exception bolted on |
| markers | PlChartMarkers | PlChartMarkers.none | Dots on the points. none by default: a filled band already has a visible edge |
| valueLabels | PlassChartValueLabels | PlassChartValueLabels.none | Which values are written on the bands |
| connectNulls | bool | false | Draws the band through a gap. It matters more than on a line: a fill that closes across a gap paints a made-up number over a larger part of the chart |
| xAxis | PlChartAxis | PlChartAxis() | The category axis |
| yAxis | PlChartAxis | PlChartAxis() | The value axis |
| legend | PlChartLegend | PlChartLegend() | The legend |
| tooltip | PlChartTooltip | PlChartTooltip() | The tooltip |
| height | double? | — | How tall the plot is |
| format | String Function(double)? | — | How a value is written |
| semanticLabel | String? | 'Chart' | What the whole drawing is called |
| empty | Widget? | — | What is drawn when there is nothing to draw |
| sizeshared | PlassSize | PlassSize.md | Type scale, plot height and line weight |
The data is the same PlassChartSeries every chart takes, and a null is a gap here too, more visibly so, because a fill that closes across a missing month paints a made-up number over a larger part of the chart than a bridged line does.
What the shared axes mean across the library is in prop conventions.
Examples
stacked
Each band rides on the total of those below it, and the top edge is the sum, which is the thing a stacked area is usually drawn to show.
A stacked band is not also given a line along its top. The band above would then be separated from it by a coloured stroke, and a stroke between two marks is ink that is not data. What separates them is the gap below.
Share rather than size
'full' normalises every category to 100%, so the chart stops being about size and starts being about share. The value axis is relabelled as a percentage.
The normalising is a change to the data, not to the drawing, which is what lets the axis, the tooltip and the table all agree that the number is a share. The tooltip still carries the number you passed: a chart that can only tell you percentages has thrown the data away.
stacking is one enum with three states rather than React's boolean | 'full'. Dart has no union type, and three named states read better than a boolean with an exception bolted onto it.
Unstacked bands overlap
Left unstacked, each band starts from the baseline and they lie over each other. The fill is a wash that fades downward rather than a slab: two of them overlapping stay readable, and the line along the top is what carries the value.
Stacked bands take a flatter, opaquer tint instead, because there the fill is the mark, a band that faded out would have no bottom edge.
The baseline is always zero
Unlike a line, an area's fill is its magnitude, so the baseline has to be zero or the band's thickness stops meaning anything. That is the one axis rule this chart does not share with PlLineChart, whose scale is free to crop.
Accessibility
Everything PlLineChart says applies here: the name and the per-series summary, the legend as real controls, and (on React) the hidden table that carries every number.