When to use
Section titled “When to use”Chart shows the shape or trend of a data set at a glance: change by month, a comparison between categories, the shares of a whole. When exact values matter, the chart comes with its table.
Pick the right kind:
- Line (
line): change along an ordered axis, time series. - Area (
area): the size and trend of a single series. - Bar (
bar): categories compared side by side. - Stacked bar (
stacked-bar): the parts of a whole in each category. - Donut (
donut): the shares of one series, at most 5 parts.
When not to use
Section titled “When not to use”- For a single number: use StatCard for a value and its change.
- To read exact values: use Table or DataTable for rows of records.
- For shares with many parts: more than 5 slices cannot be told apart; use a bar chart or a table.
- As decoration: do not add a chart that carries no information.
Anatomy
Section titled “Anatomy”- Figure (
figure): the container of the chart, its caption and its table. - Caption (
figcaption): the requiredtitle;titleHiddenleaves it for screen readers only. - Description: the optional
description, linked witharia-describedby. - Table button: at the end of the caption row when
table="toggle". - Drawing: SVG named by
role="img"and a summary sentence; a tooltip opens on hover. - Legend: at the top start for several series and for a donut; 8 px squares.
- Data table: the title as
caption, categories as row headers, series as column headers.
Behaviour
Section titled “Behaviour”- The chart appears within 400 ms on first draw. When data changes, series update in place over 240 ms; the entrance does not replay.
- With reduced motion, animation is off.
- While
loading, a placeholder block shows and the figure isaria-busy. Without data it says “No data for this period”. hideValuesremoves the axis values; the tooltip, summary and table show••••.- The chart follows the width of its container and resizes when the container does.
- Points are not focusable by keyboard; all data is in the table.
Guidelines
Section titled “Guidelines”A donut has at most 5 parts
Section titled “A donut has at most 5 parts”More than five slices cannot be told apart. With many parts use a bar chart.
A bar axis starts at zero
Section titled “A bar axis starts at zero”The length of a bar is the value. Chart starts the axis at zero for you; do not cut the value axis.
Colour does not carry meaning alone
Section titled “Colour does not carry meaning alone”With several series the lines differ in symbol and style and the bars in pattern. Do not hang the meaning on colour; write series names in the legend and the table.
The red line shows the increase, the blue line the decrease.
Content
Section titled “Content”- Make the title a noun phrase that says what the chart shows: “Monthly values”.
- Keep
descriptionto two sentences at most; state the period and the unit. - Keep series names short: “First series”, “Category A”.
- Format numbers with their unit through
formatValue; do not leave raw numbers without a unit. - Change the empty text to say what to do next with
emptyLabel.