Skip to main content

Chart

A picture of numbers: comparison, trend, share or spread.

In Accessible first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Accessible first: A relationship in a set of numbers, with the numbers also as a table. Not decoration, and never color alone.

  • Use it when: The story is a relationship in a set of numbers, not a single number.
  • Not when: A table is clearer, the set is too small, or the chart is decoration.

Instead:

  • Table: The numbers as rows; often needed beside the chart.

How Accessible first uses it​

A number in a table
Use type.body
Not A small or mono font
Every number must be readable at large size.

Words​

  • Use common words. Explain any term you must use.
  • One idea per sentence. Put the action first.
  • Never blame the person.
  • Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.

The labels components use, from the voice tokens:

  • content.action.commit: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

Test before you ship:

  • The same numbers are available as a table or text; color is not the only key. undefined

Use it in code​

npx open-ds add chart

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Chart reads 18 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Chart's tokens to change Chart alone.

Changes with theme

Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Chart
Text sizecomponent.chart.font-sizetype.caption.font-sizevar(--chart-font-size)font.size.16:1rem
Icon
Changes with theme
component.chart.iconcolor.text.mutedvar(--chart-icon)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Icon 2
Changes with theme
component.chart.icon-2color.border.defaultvar(--chart-icon-2)Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222
Icon 3
Changes with theme
component.chart.icon-3color.surface.sunkenvar(--chart-icon-3)Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222
Weightcomponent.chart.font-weighttype.label.font-weightvar(--chart-font-weight)font.weight.700:700
Gapcomponent.chart.gapcomponent-spacing-map.x2var(--chart-gap)space.8:0.5rem
Cornercomponent.chart.radiusradius.containervar(--chart-radius)radius.8:0.5rem
Border
Changes with theme
component.chart.bordercolor.border.defaultvar(--chart-border)Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222
Fill
Changes with theme
component.chart.backgroundcolor.surface.canvasvar(--chart-background)Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A
Padding, left and rightcomponent.chart.padding-xcomponent-spacing-map.x3var(--chart-padding-x)space.20:1.25rem
Padding, top and bottomcomponent.chart.padding-ycomponent-spacing-map.x2var(--chart-padding-y)space.8:0.5rem
Shadowcomponent.chart.shadowelevation.overlayvar(--chart-shadow)shadow.none
Gap 2component.chart.gap-2space.gap.defaultvar(--chart-gap-2)space.16:1rem
Text
Changes with theme
component.chart.labelcolor.text.mutedvar(--chart-label)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Label 2
Changes with theme
component.chart.label-2color.text.primaryvar(--chart-label-2)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Gap 3component.chart.gap-3space.gap.groupvar(--chart-gap-3)space.32:2rem
Padding, bottomcomponent.chart.padding-bottomcomponent-spacing-map.x3var(--chart-padding-bottom)space.20:1.25rem
Padding, topcomponent.chart.padding-topcomponent-spacing-map.x3var(--chart-padding-top)space.20:1.25rem
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222