Opus Motion ★ Star on GitHub

Data · bar-race

Bar chart race

Ranked horizontal bars that grow, then re-order smoothly over time as the data steps through keyframes: bars overtake each other, values roll, the leader changes, and a big faded period label (year, quarter) changes behind them.

A free, MIT-licensed animated chart from the Opus Motion Library — 616 motions for Remotion, React and plain HTML.

Bar chart race: three frames of the animated chart, start, middle and end
Bar chart race — start, middle and end of the 8.0-second motion.

What Bar chart race is for

Rankings over time: market share by year, top products by quarter, followers by month, league tables, "who is winning" stories. Give the names once and one values row per period in `frames`.

  • bar chart race
  • ranking
  • leaderboard
  • chart
  • data
  • overtake
  • timeline
  • infographic
  • count-up
  • statistics
  • overlay

Details

Category
Animated charts & data visualisation
Length
8.0 s (240 frames at 30 fps)
Formats
16:9, 1:1, 9:16
Weight
light
Transparent overlay
yes
Seamless loop
no
Text props
title subtitle prefix
Colour props
colors background ink
Mood
hud
Roles
accent, subject

Use Bar chart race in Remotion, React or HTML

Remotion project

terminal
# copy this motion into your Remotion project
node cli/mgl.mjs add bar-race --to ../my-app/src

# render an mp4 (run in the library folder)
node cli/mgl.mjs render bar-race --props '{"title":"Who is growing fastest","subtitle":"Index of weekly active users","prefix":"","colors":["#2F6FED","#FF7A45","#16B39A","#F2B134","#8E5CF0","#E5487F","#5BC0EB","#7A8794"],"background":"#0F1722","ink":"#EEF2F7"}'

# or export for apps / editors: mp4 | webm-alpha | prores-alpha | gif | png | poster
node cli/mgl.mjs export bar-race --as webm-alpha --props '{"title":"Who is growing fastest","subtitle":"Index of weekly active users","prefix":"","colors":["#2F6FED","#FF7A45","#16B39A","#F2B134","#8E5CF0","#E5487F","#5BC0EB","#7A8794"],"background":"#0F1722","ink":"#EEF2F7"}'

React / Next.js

tsx
import {MotionPlayer} from 'opus-motion-library/web';

<MotionPlayer
  motion="bar-race"
  props={{
    title: 'Who is growing fastest',
    subtitle: 'Index of weekly active users',
    prefix: '',
    colors: [
      '#2F6FED',
      '#FF7A45',
      '#16B39A',
      '#F2B134',
      '#8E5CF0',
      '#E5487F',
      '#5BC0EB',
      '#7A8794',
    ],
    background: '#0F1722',
    ink: '#EEF2F7',
  }}
  playOnView
  loop="auto"
/>

Plain HTML / WordPress

html
<script src="opus-motion.element.js" defer></script>

<opus-motion motion="bar-race"
  props='{"title":"Who is growing fastest","subtitle":"Index of weekly active users","prefix":"","colors":["#2F6FED","#FF7A45","#16B39A","#F2B134","#8E5CF0","#E5487F","#5BC0EB","#7A8794"],"background":"#0F1722","ink":"#EEF2F7"}'>
</opus-motion>

Compose spec (multi-scene video)

json
{
  "width": 1920,
  "height": 1080,
  "fps": 30,
  "scenes": [
    {
      "motion": "bar-race",
      "props": {
        "title": "Who is growing fastest",
        "subtitle": "Index of weekly active users",
        "prefix": "",
        "colors": [
          "#2F6FED",
          "#FF7A45",
          "#16B39A",
          "#F2B134",
          "#8E5CF0",
          "#E5487F",
          "#5BC0EB",
          "#7A8794"
        ],
        "background": "#0F1722",
        "ink": "#EEF2F7"
      }
    }
  ]
}

Bar chart race props

18 parameters — change any of them to make the motion yours.

PropDefaultWhat it does
names["Aurora","Beacon","Cobalt","Delta","Ember","Fjord","Garnet","Harbor"]one name per bar; colours follow the name index so a bar keeps its colour while it moves
frames[{"label":"2019","values":[12,18,9,30,6,14,4,20]},{"label":"2020","values":[20,22,16,34…keyframes [{label, values[]}] — one values row per period, same order as names
topN6how many bars are visible at a time (others slide off the bottom)
title"Who is growing fastest"headline (empty = none)
subtitle"Index of weekly active users"small line under the headline (empty = none)
prefix""text before every value
suffix""text after every value, e.g. "%", "M"
decimals0decimal places on values
stepFrames34frames per keyframe step at speed 1
scale"dynamic""dynamic" rescales to the current leader, "fixed" keeps one scale for the whole race
showRankfalseprint the live rank number at the left
showPeriodtruebig faded period label behind the bars
colors["#2F6FED","#FF7A45","#16B39A","#F2B134","#8E5CF0","#E5487F","#5BC0EB","#7A8794"]bar palette by name index
background"#0F1722"page colour, or "transparent"
ink"#EEF2F7"text colour
fontFamily""CSS font family (empty = Space Grotesk)
startAt8frame the bars start to grow
speed1animation speed multiplier

Notes & credits

Technique sources:

  • original round-3 chart motion