Chart frame
ProThe card a chart sits in: its title names the chart, a switch shows the same numbers as a table, and it has empty, loading, pending and error states. Not an M3 component (@windmorph/react-pro).
import { ChartFrame } from '@windmorph/react-pro/charts';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action | Where |
|---|---|---|
| Enter or Space | Switches between the chart and its table.The table switch | The table switch |
| Enter or Space | Calls onRetry.Try again, after an error | Try again, after an error |
- The chart inside keeps its own keys: a line, bar or segmented chart is one stop, a slider over its places.
- When the table view's rows are cut off, they are a tab stop of their own that the arrow and page keys scroll, as a plain
DataTable's are.
Screen reader
- Role
- The core
Card(a plain container) with a heading, the chart, and in the table view atable; below the medium width (600px of the table view’s own width) the table view is a list, as aDataTablebelow itscompactBelow. - Accessible name
- The title is a heading (
h3by default,headingLevel). It names every chart inside througharia-labelledby, unless a chart has a name of its own, and names the table view too. - States announced
- The table switch is a toggle button named
labels.showTable("Show as a table"), the same name in both views, witharia-pressedsaying whether the table shows. Whilepending, the chart area isaria-busyover the chart or the table, never over a state, whose announcements some screen readers would hold back inside a busy area; the table view shows its loading bar too.
- While
loading, a status sayslabels.loading("Loading"); the status goes into the page a moment before its words, so it is announced. - The
errormessage, andemptywords given as text, are announced politely as they take the chart's place, through a status that is in the page from the start. While a retry ispendingwith itserrorthe status goes quiet, so a retry that fails again with the same words is said again. AnEmptyStatepassed asemptyannounces itself with its ownannounce. - The description is a
divunder the title, so it may hold more than words (a list, a link). It describes every chart inside and the table view througharia-describedby. - While the table shows, the chart stays in the page, hidden from everyone.
Focus
- The header comes first in Tab order: your actions, then the table switch. The switch keeps focus as the view changes.
- While the table shows, the chart is hidden and leaves the Tab order; it comes back where it was.
- Focus never drops to the page. When what has it goes (the table switch as a state replaces the chart, Try again as
onRetryloads again, a focused chart as the loading placeholder takes its place), the chart area holds it, then hands it to Try again if loading fails again; a chart that comes back doesn't take it from there. Whilepending, Try again shows the core button's progress indicator and keeps focus.
Touch target
- The table switch is the core's standard icon button, with a 48px target; Try again is the core's tonal button, with its 48px target.
- The chart inside has its own targets; see its page.
Motion
- Switching between the chart and the table, or a state ending, fades the view that shows in where it stands, on an effects spring (
--wm-chart-frame-view-duration), under reduced motion too: a fade is not movement. Only once the frame is on screen, so nothing fades as the page loads. - While
pending, the marks dim and come back on an effects spring, under reduced motion too: a fade is not movement. - The loading placeholder is a
Skeleton, which holds still under reduced motion. - Going back from the table never replays the chart's entrance: it stayed in the page.
What you need to do
- Give every frame a
titlethat says what the chart shows; it names the chart, so the chart needs noaria-label. - Set
headingLevelto fit the page's outline. - Pass
emptywhen there is nothing to draw, and writeerroras what failed and what to do: the frame announces it, so it needs no announcement of your own. - Around a list or a meter, pass a
minHeightnear its height (or 0), so the first load’s placeholder is as tall as what replaces it and nothing below moves under someone reading or about to press. - For lists and meters, which give no table, the printed figures are the text alternative; pass
tableonly for figures they leave out. - Translate
labels.showTable,labels.loadingandlabels.retry, or set them once for the app with aLabelsProvider(itsChartFramewords).