Skip to main content

Chart

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

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Totals over time on dashboards.

  • 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 Dense data uses it​

A number in a table
Use type.data
Not type.body
Mono digits line up in columns, so values compare at a glance.

Words​

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

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

Dense data 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.12:0.75rem
Icon
Changes with theme
component.chart.iconcolor.text.mutedvar(--chart-icon)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Icon 2
Changes with theme
component.chart.icon-2color.border.defaultvar(--chart-icon-2)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Icon 3
Changes with theme
component.chart.icon-3color.surface.sunkenvar(--chart-icon-3)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Weightcomponent.chart.font-weighttype.label.font-weightvar(--chart-font-weight)font.weight.500:500
Gapcomponent.chart.gapcomponent-spacing-map.x2var(--chart-gap)space.8:0.5rem
Cornercomponent.chart.radiusradius.containervar(--chart-radius)radius.4:0.25rem
Border
Changes with theme
component.chart.bordercolor.border.defaultvar(--chart-border)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Fill
Changes with theme
component.chart.backgroundcolor.surface.canvasvar(--chart-background)Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117
Padding, left and rightcomponent.chart.padding-xcomponent-spacing-map.x3var(--chart-padding-x)space.12:0.75rem
Padding, top and bottomcomponent.chart.padding-ycomponent-spacing-map.x2var(--chart-padding-y)space.8:0.5rem
Shadow
Changes with theme
component.chart.shadowelevation.overlayvar(--chart-shadow)Lightshadow.overlayDarkshadow.overlay-dark
Gap 2component.chart.gap-2space.gap.defaultvar(--chart-gap-2)space.8:0.5rem
Text
Changes with theme
component.chart.labelcolor.text.mutedvar(--chart-label)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Label 2
Changes with theme
component.chart.label-2color.text.primaryvar(--chart-label-2)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Gap 3component.chart.gap-3space.gap.groupvar(--chart-gap-3)space.16:1rem
Padding, bottomcomponent.chart.padding-bottomcomponent-spacing-map.x3var(--chart-padding-bottom)space.12:0.75rem
Padding, topcomponent.chart.padding-topcomponent-spacing-map.x3var(--chart-padding-top)space.12:0.75rem
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38