Skip to content

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.

React
tsx
import { PlAreaChart } from 'plass-ui';

<PlAreaChart series={traffic} categories={months} stacked />;
dart
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

PropTypeDefaultDescription
series * readonly PlassChartSeries[]The data
categoriesreadonly 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
stackedboolean | 'full'falseStacks 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
connectNullsbooleanfalseDraws 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
xAxisPlassChartAxisThe category axis
yAxisPlassChartAxisThe value axis
legendPlassChartLegendThe legend
tooltipPlassChartTooltipThe tooltip
heightnumber | stringHow tall the plot is
formatIntl.NumberFormatOptionsHow a value is written
labelstring'Chart'What the whole drawing is called
emptyReactNodeWhat is drawn when there is nothing to draw
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Type scale, plot height and line weight
PropTypeDefaultDescription
series * List<PlassChartSeries>The data
categoriesList<PlassChartCategory>?What the category axis says
curvePlChartCurvePlChartCurve.linearHow the edge of the band gets from one point to the next. The same three shapes PlLineChart offers
stackingPlAreaStackingPlAreaStacking.noneHow 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
markersPlChartMarkersPlChartMarkers.noneDots on the points. none by default: a filled band already has a visible edge
valueLabelsPlassChartValueLabelsPlassChartValueLabels.noneWhich values are written on the bands
connectNullsboolfalseDraws 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
xAxisPlChartAxisPlChartAxis()The category axis
yAxisPlChartAxisPlChartAxis()The value axis
legendPlChartLegendPlChartLegend()The legend
tooltipPlChartTooltipPlChartTooltip()The tooltip
heightdouble?How tall the plot is
formatString Function(double)?How a value is written
semanticLabelString?'Chart'What the whole drawing is called
emptyWidget?What is drawn when there is nothing to draw
sizesharedPlassSizePlassSize.mdType 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.

React

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.

React

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.

Released under the MIT License