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.
Props
ChartFrame 23 props
The chart's title, a heading that names the chart inside. Untrusted text, rendered as text.
The title's heading level.
Under the title: what the chart shows.
The app's own controls, before the table switch.
The chart. A chart inside gives the frame its numbers for the table view.
The core Card's variant.
Whether the table view shows (controlled).
Whether it shows at first. The charts give the frame their numbers once they're in the page, so the server's HTML shows the chart and the table follows; pass
tablefor a table in the server's HTML.Rows for the table view in place of the chart's own;
falsefor no table view.Shown in place of the chart (words, or an
EmptyState) when there's nothing to draw: the app says so (empty={rows.length ? undefined : 'No orders yet'}), since lists and meters have no table for the frame to look at.errorandloadingcome first, so that pattern never hides a load or a failure. The title stays and the switch goes. Its words are announced as they replace the chart: text, and the words of elements (blocks apart, a picture'salt), but not an app's own component's, whose words can't be read without drawing it (it stays where screen readers reach it); anEmptyStateannounces itself with its ownannounce.No picture yet: a placeholder in place of the chart, before
empty, at the frame's least height, or the last chart's height once one has shown.New numbers loading: the last picture stays, dimmed (busy for assistive technology); with
error, Try again shows it's working, and the error is said again if the retry fails.A message in place of the chart, first of the states; announced as it replaces the chart, read as
emptyis: words are read once by screen readers, and an error holding a link (or an app's own component) stays where they reach it.The least height of the chart area, px at the default text size (growing with larger text): the placeholder's, a state's and the table view's until something has shown, and a line or bar chart's. Such a chart with no
minHeightof its own fills it, its legend included (its plot takes the rest, half of it at least), so a load never moves the page; a chart's ownminHeightis its plot's. A list or a meter (SegmentedList,RankedBars,Meter…) takes its own height instead; around one, pass about its height, which the first load's placeholder holds, or 0. After that, a reload holds the height last shown.Replaces the table switch's and the error's icons.
Ref to the outermost element.
The outermost element's id.
Events
Called when the switch is pressed.
Adds a Try again button to the error, which takes focus back if a retry fails.
Text
Words it shows and says. A
LabelsProvidersets them for the whole app.Names the switch to the table view, a toggle pressed while the table shows: its name stays the same and its pressed state says which view is on.
Names the chart's placeholder while it loads.
The retry button after an error.
Classes for the outermost element. Wins over the defaults via
cn().Classes for each part.
The row of the title, the description and the actions.
What holds the title and the description, beside the actions.
The title, the heading that names the chart.
The words under the title.
The app's actions and the table switch.
The table switch.
What holds the chart, the table or a state.
What holds the chart, and what holds the table view, each fading in as it shows.
The
DataTableof the table view.What shows when there is nothing to draw.
The error and its retry (an
EmptyState).The error's Try again button.
The placeholder before the first picture.
Inline styles for the outermost element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
| A title that names the chart, a description and the table switch | Built | Configuration · Table |
| The table view as a list of figures in a narrow column | Built | Configuration · Narrow |
| Empty, loading, error and pending states | Built | Configuration · States |
Actions of your own in the header (actions) | Built | Use case · States |
| The core Card, with a table view | Extension | M3 has no chart container. This is the core Card with a heading that names the chart and a switch to a plain DataTable of the same numbers, loaded only when first asked for. |
A title that names the chart, a description and the table switch
BuiltConfiguration · Table
The table view as a list of figures in a narrow column
BuiltConfiguration · Narrow
Empty, loading, error and pending states
BuiltConfiguration · States
Actions of your own in the header (
Builtactions)Use case · States
The core Card, with a table view
ExtensionM3 has no chart container. This is the core
Cardwith a heading that names the chart and a switch to a plainDataTableof the same numbers, loaded only when first asked for.
Theming & tokens
Set the tokens below on the frame or any ancestor. The card is the core's, so its --md-comp-card-* tokens paint the container, and the charts inside draw their point rings and the gaps between their marks in the card's colour. icons replaces the switch's and the error's icons. className goes on the card. Style each part with classNames: header, heading, title, description, actions, toggle, content, view, table, empty, error, retry, loading.
| Variable | Default | Paints |
|---|---|---|
--wm-chart-frame-padding | 16px | The space inside the card. |
--wm-chart-frame-gap | 12px | The space between the header and the chart. |
--wm-chart-frame-header-gap | 12px | The space between the title and the actions. |
--wm-chart-frame-header-min-height | 40px | The header’s least height: the actions’ 40px buttons, with or without them. |
--wm-chart-frame-actions-gap | max(8px, calc(8px - var(--md-sys-density, 0) * 4px)) | The space between the actions: 8px beside 40px icon buttons, and 4px more each density step down as they narrow, so their 48px targets never overlap. |
--wm-chart-frame-view-duration | var(--md-sys-motion-spring-effects-default-duration) | How long the chart or the table takes to fade in as the switch, or a state that ends, turns to it. |
--wm-chart-frame-view-easing | var(--md-sys-motion-spring-effects-default-easing) | The easing of that fade. |
--wm-chart-frame-title-color | var(--md-sys-color-on-surface) | The title. |
--wm-chart-frame-description-color | var(--md-sys-color-on-surface-variant) | The description under the title. |
--wm-chart-frame-empty-color | var(--md-sys-color-on-surface-variant) | The words shown when there is nothing to draw. |
--wm-chart-frame-pending-opacity | 0.5 | The last picture’s marks while new numbers load (a chart’s `marks`, a meter’s or a ranked or funnel list’s tracks, a segmented part’s colour): held, dimmed, never a skeleton; its words keep their contrast. A pending frame prints dimmed. |
--wm-chart-frame-pending-duration | var(--md-sys-motion-spring-effects-default-duration) | How long the marks take to dim and come back. |
--wm-chart-frame-pending-easing | var(--md-sys-motion-spring-effects-default-easing) | The easing of that change. |