Skip to content
animorio
IT
Back to the library

Springy bar chart

Physics, HoverGSAP, CSS onlyMediumCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

The weekly revenue card of a made-up online homeware shop, Marrowby, white on a soft light page, like a Dribbble shot. The seven bars of the days fall from above like heavy blocks, one after the other, under a hand written gravity: on the floor they squash a little, bounce once and settle, the baseline gives a pixel and the total climbs with every block that lands. Grab a bar and pull it up or down and its neighbours follow as if tied by springs, less and less the further away they are, while a dark label reads the new value and a dashed line keeps the real one; let go and the whole row swings back to the real values. Switching week lifts the bars away and drops the other week.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Springy bar chart" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Marrowby, revenue this week</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the revenue card of a made-up online homeware shop, Marrowby. The seven bars of the week fall from above like
         heavy blocks, squash a little on the floor, bounce once and settle. Drag a bar up or down and its neighbours
         follow it as if they were tied by springs; let go and every bar swings back to its real value -->
    <section class="card" data-card aria-label="Revenue this week">
      <span class="card__sheen" aria-hidden="true"></span>
      <header class="card__head">
        <div class="brand">
          <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true">
            <rect x="1" y="1" width="22" height="22" rx="7"/>
            <path d="M7.5 16.5v-4M12 16.5v-8.5M16.5 16.5v-6"/>
          </svg>
          <span class="brand__words">
            <span class="brand__name">Marrowby</span>
            <span class="brand__sub">Revenue</span>
          </span>
        </div>
        <div class="tabs" role="tablist" aria-label="Week">
          <span class="tabs__pill" data-pill aria-hidden="true"></span>
          <button class="tabs__btn is-on" type="button" role="tab" aria-selected="true" data-tab="0">This week</button>
          <button class="tabs__btn" type="button" role="tab" aria-selected="false" data-tab="1">Last week</button>
        </div>
      </header>

      <div class="total">
        <p class="total__amount"><span data-total>$105,800</span></p>
        <span class="total__chip" data-chip>
          <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 9.5V2.8M2.9 5.6 6 2.5l3.1 3.1"/></svg>
          <span data-chip-words>11.3% vs last week</span>
        </span>
      </div>

      <div class="chart">
        <div class="chart__axis" aria-hidden="true">
          <span>$25k</span><span>$20k</span><span>$15k</span><span>$10k</span><span>$5k</span><span>$0</span>
        </div>
        <div class="plot" data-plot>
          <div class="plot__grid" aria-hidden="true">
            <i></i><i></i><i></i><i></i><i></i>
          </div>
          <span class="plot__ghost" data-ghost aria-hidden="true"></span>
          <div class="plot__cols" data-cols></div>
          <span class="plot__floor" data-floor aria-hidden="true"></span>
          <div class="tip" data-tip aria-hidden="true">
            <span class="tip__value" data-tip-value>$18.6k</span>
            <span class="tip__delta" data-tip-delta></span>
          </div>
        </div>
        <div class="chart__days" data-days aria-hidden="true"></div>
      </div>
    </section>

    <svg class="hand" data-hand viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"/></svg>
    <p class="sr" aria-live="polite" data-live></p>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

32 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Springy bar chart” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a light grey ground with a soft light in the middle and grain, a white card with round corners, a thin edge and a wide shadow. At the top the Marrowby mark (a black square with three white bars) with the word Revenue and, on the right, two pill tabs, This week and Last week, with a white pill sliding under the chosen one. Below, the large total, $105,800, and an indigo chip with an arrow and «11.3% vs last week». The chart has figures on the left, from $0 to $25k, fine dashed lines and the days underneath. The seven bars, pale indigo and Saturday, the tallest, in full indigo, fall from above one after the other: touching the floor they widen and squash, bounce a few pixels and stop, the floor gives and comes back, under each a soft shadow gets sharper as it arrives, and the total climbs block by block. Over the tallest bar a dark label says $21.3k. Hover a bar and it lights up, two little grip lines appear and the label slides over it. Pull it up or down and its neighbours follow as if tied by springs, taking a little colour and swinging, the label shows the new value and the difference, a dashed indigo line stays at the real height, the total and the percentage change live. Let go and the row swings back to the real values. Choose the other week and the bars fly away upwards from the right and the new ones fall. Left alone, a drawn pointer pulls Thursday up, pulls Tuesday down, switches week, pulls Friday and goes back.

How it works

The fall

Each bar has a vertical position y and a speed. It starts above the chart, y = −(chart height + 14), and after its delay (0.09 s per bar) at every step the speed grows by GRAVITY times the step and y by the speed. When y reaches 0 the bar touches the floor: if it was going slower than 150 px/s it stops, otherwise it goes back up with 28 % of its speed (BOUNCE).

The block that squashes

The squash is a small spring of its own, stiffness 760 and damping 19, just under critical damping: on impact it gets a push in proportion to the landing speed, and the bar is drawn with scaleY 1 − s and scaleX 1 + 0.55 s from its bottom, so it widens as it lowers and wobbles once. The baseline gets the same push and gives a pixel on its own spring.

The row tied by springs

Bars on the floor have an offset d from their real height. Each one is pulled to zero by STIFFNESS and towards its neighbours by COUPLING times the difference of the offsets, minus DAMPING times its speed; the grabbed bar instead follows the pointer on a stiff 900 spring. With 120 and 200 the neighbour goes about half way, the next one a quarter. Let go and they all swing back to zero.

The capped step

The physics runs on the GSAP ticker: the step is held to 1/30 s, so a tab coming back to the front does not throw the bars out of the chart, and split in 1/240 s sub steps to keep the stiff springs stable. Sizes are in pixels and read again on resize: the real height of each bar is value / 25k times the chart height, the offset stays in pixels.

The total and the label

The total is the sum of the values read from the heights of the bars that have landed, so it climbs with every block and changes while you pull; the written one chases it with an easing of 14 per second. The dark label sits over the grabbed bar, the hovered one or the tallest, moves sideways on a spring and follows the top of the bar every frame, even while it squashes.

Values to change

NameFileDefaultWhat it changes
GRAVITYscript.js3600How hard the bars fall, in pixels per second squared.
BOUNCEscript.js0.28How much speed a bar keeps when it hits the floor: 0 lands dead, 0.6 bounces a lot.
DROP_STAGGERscript.js0.09Seconds between one bar and the next as they fall.
SQUASHscript.js1How much a bar squashes on landing: 0 keeps it rigid.
STIFFNESSscript.js120The spring pulling each bar back to its real value.
COUPLINGscript.js200The spring between neighbours: higher, they follow the held bar more.
DAMPINGscript.js9The friction of the springs: lower, the row swings longer.
LOOPscript.jstrueLeft alone, the drawn pointer plays with the chart again and again.

Try them in the Playground

When to use it

For the dashboard of an online shop, an analytics app or a back office tool, for the page of a «what if» or forecasting feature: when the numbers should arrive with weight, and whoever looks should be able to try moving them and see the total change, knowing they go back to the truth as soon as they let go.

On phones

The same physics with adapted sizes: the chart is sized on height too (31 % of the screen, between 110 and 210 px), the card takes almost the full width and the tabs get tighter. Bars are pulled with a finger; the chart does not scroll the page while you pull.

With reduced motion

No falling and no springs: the bars fade in already in place, the pulled bar follows the finger on its own without the neighbours and goes straight back to its value when released, switching week is a fade, the drawn pointer does not start.

Pitfalls

  • The springs between neighbours must work on the offsets from the real height, not on the heights: with the heights the row would flatten itself without being touched, as each bar would pull its neighbours towards its own height.
  • The step has to be capped at 1/30 s and split in small ones: with the full step of a tab left in the background the bars go through the floor and the stiff springs blow up.
  • The squash goes on one element for the physics (.bar, height and transform written every frame) and the colour on a child (.bar__body): the inline transform would wipe the one from the classes.
  • Pointer coordinates must be divided by the scale of the demo (getBoundingClientRect against offsetWidth): in the phone box the safety net shrinks the page and the bar would follow the finger half way.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 11 KB; the libraries: GSAP 28 KB.

Testing

Tested on 9 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations