Charts fetch nothing themselves, so the states of a request are props you set from wherever the data comes from. Handled, a chart becomes a readable panel instead of an empty frame, and it keeps its height, so the page doesn't jump when the data lands.
An empty array is not an error: the query ran and matched nothing. That is why emptyState and errorState are separate. When both loading and error are false and data is empty, the empty state shows.
Hovering the plot shows a tooltip with every visible series at that x value, written in the chart's format. A line chart draws a cursor line, a bar chart highlights the band (hover on BarChart paints the whole band).
The plot is also reachable from the keyboard. Tab to it, and:
A pie moves slice by slice with the arrow keys. tooltip={false} turns the tooltip off and takes the plot out of the tab order, for a chart that is only a picture next to its numbers.
The legend lists the series with their colours. With two or more series, each entry is a button: pressing it hides or shows that series, and the value axis rescales to what is left. That lets the reader take the big series out to see the small ones.
A time series can carry a date-range picker in its header. Give it a start and an end, which set the first range and filter the rows to it, and turn on selector:
| date | Visits |
|---|---|
| Jan 2025 | 2,600 |
| Feb 2025 | 2,550 |
| Mar 2025 | 2,900 |
| Apr 2025 | 3,100 |
| May 2025 | 3,050 |
| Jun 2025 | 3,400 |
| Jul 2025 | 3,600 |
| Aug 2025 | 3,500 |
| Sep 2025 | 3,900 |
| Oct 2025 | 4,100 |
| Nov 2025 | 4,300 |
| Dec 2025 | 4,600 |
The chart filters the rows it already has. For a long history, fetch the range instead: keep start and end in state, refetch in onRangeChange, and pass the new rows. onRangeChange is a function, so this chart lives in a client component.
Charts draw in on mount: lines sweep from the left, bars grow from the baseline. Readers who ask for reduced motion never see it. LineChart takes animation={false} and animationBegin, animationDuration and animationEasing to tune it. For live data, either match animationDuration to the sample interval so updates glide, or turn it off so they snap: see LineChart.
Each chart's plot is a figure (role="figure"), named by its title and a summary written from the data, in the chart's valueFormat and locale:
- a line or bar chart: "Revenue and Cost, Jan to Dec. Revenue: highest 12,400 in Aug, lowest 3,100 in Feb."
- a pie: "Share by browser: Chrome 62%, Safari 21%, Firefox 9%."
Inside the card, hidden from sight, the chart also renders its data as a table: the x values as rows, a column per series. A reader who wants the numbers can walk them cell by cell. While a chart loads, fails or is empty, the plot is no figure, and its status is read as it is.
The generated summary states only what is in the data. When the point of the chart is something the numbers don't say on their own, write it:
Colour is never the only cue: each series is named in the legend, the tooltip and the table. Use label so those names are words a reader knows, not rev_q_usd.