Skip to content
animorio
IT
All components

Sales comparison chart

Charts, Hover, PhysicsGSAP, CSS onlyAdvancedCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

The weekly sales bar chart of a made-up online store, Saltmoss, in a premium card on a white page. Seven glossy bars, one a day, grow one after the other on a spring that goes a pixel too far and settles; behind each bar a dashed outline open at the foot keeps last week's figure. The Compare switch slides last week's bars out beside the new ones, they fill with a fine hatch and the change in percent appears above each pair, green or a soft red. Pointing at a day lights its bar with a rising sweep of light, the others lower and fade and a frosted glass label gives the figure and the change; the total at the top rolls digit by digit.

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>
<!--
  "Sales comparison 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>The weekly sales chart with last week to compare</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 sales card of a made-up online store. Seven bars, one a day, grow one after the other on a spring; behind
         each one a dashed outline keeps last week's figure. Compare slides last week out beside this week with the
         change on top; pointing at a day lights its bar, lowers the others and a glass label gives figure and change -->
    <section class="card" data-card aria-label="Sales this week">
      <span class="card__sheen" aria-hidden="true"></span>
      <header class="card__head">
        <div class="card__id">
          <svg class="card__mark" viewBox="0 0 28 28" aria-hidden="true">
            <rect x="0.5" y="0.5" width="27" height="27" rx="8.5"></rect>
            <path d="M7.5 16.6c2.2-3.4 4.4-3.4 6.5 0s4.3 3.4 6.5 0"></path>
            <path d="M7.5 11.6c2.2-3.4 4.4-3.4 6.5 0s4.3 3.4 6.5 0"></path>
          </svg>
          <div>
            <h1 class="card__title">Sales this week</h1>
            <p class="card__sub">Saltmoss store · Nov 2 <span data-dash></span> 8</p>
          </div>
        </div>
        <button class="cmp" type="button" role="switch" aria-checked="false" data-switch>
          <span class="cmp__label">Compare</span>
          <span class="cmp__track" aria-hidden="true"><span class="cmp__knob" data-knob></span></span>
        </button>
      </header>

      <div class="total">
        <p class="total__num" data-total aria-label=""></p>
        <div class="total__side">
          <p class="pill is-up" data-total-pill>
            <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3.2 8.8 8.6 3.4M4.6 3.2h4.2v4.2"></path></svg>
            <span data-total-delta></span>
          </p>
          <p class="total__vs">vs <span data-total-then></span> last week</p>
        </div>
      </div>

      <div class="legend" aria-hidden="true">
        <span class="legend__item"><i class="legend__now"></i>This week</span>
        <span class="legend__item"><i class="legend__then"></i>Last week</span>
      </div>

      <div class="chart" data-chart tabindex="0" role="group" aria-label="Sales by day. Use the arrow keys to read a day.">
        <div class="grid" data-grid aria-hidden="true"></div>
        <span class="glow" data-glow aria-hidden="true"></span>
        <div class="bars" data-bars aria-hidden="true"></div>
        <div class="tip" data-tip aria-hidden="true">
          <div class="tip__glass" data-tip-glass>
            <p class="tip__day" data-tip-day></p>
            <p class="tip__num" data-tip-num></p>
            <p class="tip__delta" data-tip-delta>
              <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3.2 8.8 8.6 3.4M4.6 3.2h4.2v4.2"></path></svg>
              <b data-tip-pct></b><span data-tip-then></span>
            </p>
          </div>
        </div>
      </div>
      <div class="axis" data-axis aria-hidden="true"></div>
      <p class="sr" aria-live="polite" data-live></p>
    </section>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
  </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.

48 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 “Sales comparison 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 white page sits a light card with a one pixel edge, a faint indigo light along the top and a soft layered shadow. Top left the Saltmoss mark (a small black square with two waves) with Sales this week and under it Saltmoss store · Nov 2–8; on the right the Compare switch, a pill with the word and a grey track with a white knob. Below, the large total ($18,426), a green pill with a drawn arrow (+7.7%) and vs $17,110 last week; then the key, This week with a small indigo square and Last week with a small dashed square. The chart has four dashed guides ($1k, $2k, $3k, $4k), the baseline and seven days, Mon to Sun. On arrival the card rises and settles, last week's dashed outlines grow from the left and a moment later the glossy indigo bars, lighter on their left side and catching the light at the top, rise one after the other on a spring that takes them a pixel too far and settles them; meanwhile the total rolls from $0 to $18,426, one digit after the other. Pointing at a day its bar lights up (more saturated, with a halo and a longer shadow), a band of light runs up it from the foot, a pool of indigo light opens on the floor, the other bars fade and sink a few pixels on a spring and the day's name underneath turns black, wider and heavier. Beside the bar a frosted glass label, blurring and saturating the bars behind it, says Thursday, Nov 5, $3,120 and +18.2% vs $2,640, in green if the day did better and a soft red with the arrow turned if it did worse; from day to day the label glides on a spring. With Compare the knob squashes, runs right and the track turns indigo: the bars narrow and slide right, last week's outlines slide left, narrow like them and fill with a grey with a fine hatch; above every pair, one after the other, the change tags pop up (+8%, −2.9%, +16.9%, +18.2%, +9.2%, +11.8%, −7.7%), green or red, and the total's pill gives a small beat. Left alone, a drawn pointer reads Thursday and Saturday, turns Compare on, reads Wednesday and Sunday, turns it off; the bars sink and the week starts again.

How it works

Every measure is a spring

The height of every bar and outline, the fading of every day, the split of the pairs and the label's place are springs with a position, a speed and a target, kept in parts (of the value, of the day's slot) rather than pixels. One loop on GSAP's ticker steps them in 1/240 of a second, with the frame step capped at 1/30, and goes to sleep when nothing moves. GROW's damping (0.8) takes a bar about a pixel past its top before it settles.

The drawing worked out every frame

From the springs and the chart's size the script works out at every frame the width, height and x of every bar and outline: the width is half the day's slot (between 10 and 40 pixels), the scale is the top rounded up to the thousand above the highest day. So a resize in the middle of a movement only changes the drawing, and the guides go back to their place with a ResizeObserver.

Last week sliding out beside

With split at 0 the dashed outline sits centred behind the bar and eight pixels wider; going to 1 both narrow to 58%, the bar slides right and the outline left by half their width plus a small gap, and the outline's hatched fill takes opacity with the same value. The SPLIT spring overshoots, so the pairs open a hair too far for an instant and close.

The change tags

Above every pair a tag with the change worked out from the data, green if it rises and a soft red if it falls. Its holder is placed by the drawing (on the day's centre, seven pixels above the higher top, so it follows the bars as they grow and lower), its child is animated by GSAP: it comes in with back.out staggered by five hundredths and, on the day being read, drops to a quarter to make room for the label.

The glass label and the light

The label goes to the right of the bar in the first days and to the left in the last, at half the height of its top and always inside the chart; two springs take it there, and when it appears it starts in place. The glass is a backdrop-filter with blur and saturation over a white gradient with a one pixel edge. The bar being read takes a halo, a band of light that runs up it and a pool of light on the floor.

Rolling digits and the pilot

Every digit of the total is a column of ten numbers in a window one line tall, taken to its place with back.out from left to right. The drawn pointer is a timeline with infinite repeat and repeatRefresh, so its positions are worked out again every round; the visitor's first real gesture stops it and leaves the chart whole.

Values to change

NameFileDefaultWhat it changes
THIS_WEEKscript.js[2140, 2380, 2210, …]This week's sales, Monday to Sunday.
LAST_WEEKscript.js[1980, 2450, 1890, …]Last week's sales, the dashed outlines behind.
CURRENCYscript.js'$'The sign before the figures.
GROWscript.js[170, 0.8]The bars' spring: how stiff, and how much it is held back (1 = no overshoot).
STAGGERscript.js0.07Seconds between one bar and the next as they grow.
SPLITscript.js[210, 0.74]The spring last week's bars slide out on when Compare is on.
DIMscript.js0.55How much the other days fade while one is read.
SINKscript.js0.06How much the other days lower while one is read.
TIPscript.js[260, 0.82]The spring the glass label follows the day on.

Try them in the Playground

When to use it

For the dashboard of an online store, the sales panel of a back office or an analytics app, or the landing page of an e-commerce product as a showcase: it shows the week at a glance and, with the comparison, which days did better or worse than the week before.

On phones

The same animation with the sizes adapted: the card is 92% of the screen wide, the chart and the total are sized on the height too (34vh, between 112 and 232 pixels), the bars stay half the day's slot and the change tags drop their decimal. With a finger you tap a day to read it and the label stays until you tap outside; the switch is tapped like a button.

With reduced motion

Nothing moves by itself: the card fades in with the bars already at their height and the total already written, and the drawn pointer does not start. Reading a day the label fades in in its place; Compare sets the pairs side by side at once and the tags fade in.

Pitfalls

  • With the label above the bar, on the tall days (Saturday at 85% of the scale) it left the chart and covered the key: now it sits beside it, right on the first days and left on the last, and its y is kept inside the chart.
  • A label appearing started from the place of the day read before and crossed the chart: when it appears its springs start on the target.
  • The tag of the day being read ended up under the glass label and read blurred: on that day it drops to a quarter of opacity and comes back when you leave it.
  • The tags' holder is placed by the pixel drawing and its child is animated by GSAP: with one element GSAP's transform wiped out the position.
  • On a phone (days 39 pixels wide) the tags with a decimal, +18.2%, touched their neighbours: under 54 pixels a day they drop the decimal (+18%) and go down to 9 pixels, worked out again on every resize.

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 8 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 components