Rost

← All components

component

BarChart

A handful of figures side by side as bars, with a label under each: grey, and green for the one that matters now. For months, not for analysis.

In code Contract: review Guidance: proposed Contract on GitHub Figma 749:23 As markdown
  1. Jun: €1,200
  2. Jul: €1,800
  3. Aug: €1,500
  4. Sep: €2,400
  5. Oct: €2,100
  6. Nov: €2,760
Default

Install

npx github:Runceanu/rost add bar-chart

It lands in src/rost/bar-chart/, with what it needs and its contract. Install has the rest.

When to use

  • How this month compares

    Income for the last six months, with this one in green. The Stat above it says the number; the bars say whether it's up.

When not to use

Behaviour

Each bar's height is its value out of max, which is the largest value unless you set it. It has no axis, gridlines or tooltips, on purpose.

Accessibility

  • Element

    <ol> with an aria-label, so it's read as a list of so many items. Each <li> says its label and value in words.

  • Name

    label: what the chart shows, like Income by month.

  • Colour

    The grey bars are 4.3:1 on the dark page and the green one 10:1. The current label is also heavier, so the colour isn't the only sign.

Content

Short labels, like Jun or Q3. Give valueText in the units people read, like €1,200.

Props

PropTypeValuesDefault
data node
current number
max number
height number 160
label string

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • gap 8px spacing/gap/small
  • margin 0px spacing/gap/none
  • padding 0px spacing/gap/none

displayflex · list-stylenone

item

  • gap 8px spacing/gap/small

displayflex · flex-directioncolumn · flex1 1 0 · min-width0

plot

displayflex · align-itemsflex-end · flex-grow1

bar

  • border-top-left-radius 4px spacing/radius/xsmall
  • border-top-right-radius 4px spacing/radius/xsmall
  • background #747573 bar-chart/bar

width100%

current-bar

  • border-top-left-radius 4px spacing/radius/xsmall
  • border-top-right-radius 4px spacing/radius/xsmall
  • background #00d669 bar-chart/current

width100%

label

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/label/font-weight/regular
  • font-size 12px typography/label/font-size
  • line-height 14px typography/label/line-height
  • letter-spacing 0px typography/label/letter-spacing
  • color #999999 bar-chart/label

text-aligncenter · white-spacenowrap

current-label

  • font-family 'General Sans Variable' font-family/base
  • font-weight 500 typography/label/font-weight/medium
  • font-size 12px typography/label/font-size
  • line-height 14px typography/label/line-height
  • letter-spacing 0px typography/label/letter-spacing
  • color #ededed bar-chart/current-label

text-aligncenter · white-spacenowrap