Skip to content

Chart frame

Pro

The 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

Chart frame keyboard
KeyAction
Enter or SpaceSwitches between the chart and its table.The table switch
Enter or SpaceCalls onRetry.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 a table; below the medium width (600px of the table view’s own width) the table view is a list, as a DataTable below its compactBelow.
Accessible name
The title is a heading (h3 by default, headingLevel). It names every chart inside through aria-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, with aria-pressed saying whether the table shows. While pending, the chart area is aria-busy over 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 says labels.loading ("Loading"); the status goes into the page a moment before its words, so it is announced.
  • The error message, and empty words 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 is pending with its error the status goes quiet, so a retry that fails again with the same words is said again. An EmptyState passed as empty announces itself with its own announce.
  • The description is a div under the title, so it may hold more than words (a list, a link). It describes every chart inside and the table view through aria-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 onRetry loads 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. While pending, 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 title that says what the chart shows; it names the chart, so the chart needs no aria-label.
  • Set headingLevel to fit the page's outline.
  • Pass empty when there is nothing to draw, and write error as 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 minHeight near 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 table only for figures they leave out.
  • Translate labels.showTable, labels.loading and labels.retry, or set them once for the app with a LabelsProvider (its ChartFrame words).