Area chart
An area chart shows the size of a quantity across an interval. A running total makes the filled area straightforward to interpret.
Track cumulative spending
#Switch months to compare spending over the first four days. The total reaches 80 in January and 96 in February.
components/area-chart/appliance/track_spending.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class TrackSpending extends StatefulWidget {
const TrackSpending({super.key});
@override
State<TrackSpending> createState() => _TrackSpendingState();
}
class _TrackSpendingState extends State<TrackSpending> {
bool alternate = false;
String get period => alternate ? 'February' : 'January';
List<double> get totals =>
alternate ? const [24, 42, 68, 96] : const [12, 34, 55, 80];
@override
Widget build(BuildContext context) => SingleChildScrollView(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('$period · cumulative spending'),
const SizedBox(height: 12),
ApplianceAreaChart(
labels: const ['1', '2', '3', '4'],
series: [ApplianceChartSeries('Spent', totals)],
semanticLabel: '$period cumulative spending',
),
const SizedBox(height: 12),
ApplianceButton(
alternate ? 'Show January' : 'Show February',
onPressed: () => setState(() => alternate = !alternate),
),
],
),
),
);
}
Parameters
ApplianceAreaChart API ↗labels- A label for each position along the horizontal axis.
series- The series name and ordered measurements.
semanticLabel- Names the chart and period.
height- Sets the plot height.
valueText- Formats a value in the chart readout.
Shared behaviour
- Keyboard and focus. Tab to the period button and activate it. Where the chart accepts focus, try its arrow keys to inspect a point.
- Screen readers. Read the period and the chart’s description. The value or summary provided by the look changes with the data.
- Direction and type. The surrounding text follows reading direction. Check the plot’s own ordering, labels and legend in RTL and at larger type.