Skip to content
animorio
IT
Back to the library

Elastic mood chart

SVG, PhysicsGSAPMediumCompressed weight: Demo 9.2 KBGSAP 28 KBFreeDownload the zip

The weekly mood card of a made-up wellness app, Bellwort, white on a warm grey with one violet: the chart line is an elastic cord of 49 particles moved by hand-made verlet physics, each hung on a spring to the real value of its day. Pull it with a finger and it stretches and thins, the tooltip reads the mood under the finger; let go and it wobbles and settles on the real values. Today is still dashed: pull its point and let go, and it lands on the nearest mood, logs it, the tick draws itself and the average rolls from 7.1 to 7.4.

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>
<!--
  "Elastic mood 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>Bellwort, mood this week: the elastic line you pull</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">
    <!-- the weekly mood card of a made-up wellness app, Bellwort. The line of the chart is an elastic cord made of
         small particles (verlet, step capped at 1/30 s): each one is held by a spring to the real values of the week.
         Pull it with a finger and it stretches, let go and it wobbles back to the truth. Today is still open: pull
         today's point and let go, and it settles on the nearest mood and logs it -->
    <section class="card" data-card aria-label="Mood this week, Bellwort">
      <span class="card__sheen" aria-hidden="true"></span>

      <header class="head">
        <span class="mark" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M10 3.2c-2.6 2.2-3.6 4.6-3 7.2.5 2 1.6 3.6 3 6.4 1.4-2.8 2.5-4.4 3-6.4.6-2.6-.4-5-3-7.2Z"/><path d="M10 9.4v7.4"/></svg>
        </span>
        <span class="who">
          <span class="who__name">Bellwort</span>
          <span class="who__what">Mood check-in</span>
        </span>
        <span class="range">
          This week
          <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3.2 4.8 6 7.6l2.8-2.8"/></svg>
        </span>
      </header>

      <div class="stat">
        <p class="stat__big"><span class="stat__num" data-avg>7.1</span><span class="stat__of">/ 10</span></p>
        <div class="stat__side">
          <span class="stat__word" data-word>Good</span>
          <span class="delta"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 9.4V2.8M3.2 5.4 6 2.6l2.8 2.8"/></svg><span data-delta>0.4</span> vs last week</span>
        </div>
      </div>

      <div class="chart" data-chart>
        <svg class="plot" data-plot role="img" aria-label="Mood line for Monday to Sunday">
          <defs>
            <linearGradient id="fill" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="var(--accent)" stop-opacity="0.2"/>
              <stop offset="1" stop-color="var(--accent)" stop-opacity="0"/>
            </linearGradient>
            <filter id="soft" x="-10%" y="-40%" width="120%" height="180%"><feGaussianBlur stdDeviation="5"/></filter>
          </defs>
          <g data-guides></g>
          <path class="area" data-area fill="url(#fill)"/>
          <path class="shadow" data-shadow filter="url(#soft)"/>
          <path class="line" data-line/>
          <path class="line line--open" data-open/>
          <g data-dots></g>
          <g data-days></g>
        </svg>
        <div class="tip" data-tip aria-hidden="true"><span class="tip__in"><b data-tip-day>Wed</b><span data-tip-word>Okay</span><i data-tip-num>5.4</i></span></div>
        <div class="finger" data-finger aria-hidden="true"><span class="finger__in"></span></div>
      </div>

      <footer class="foot">
        <p class="hint" data-hint>
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2.6v10.8M5.2 5.4 8 2.6l2.8 2.8M5.2 10.6 8 13.4l2.8-2.8"/></svg>
          <span>Pull today’s point to log your mood</span>
        </p>
        <p class="done" data-done aria-live="polite">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path data-check d="M3.6 8.4 6.6 11.2 12.4 4.8"/></svg>
          <span>Logged today, <b data-done-word>Great</b></span>
        </p>
      </footer>
    </section>
  </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.

30 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 “Elastic mood 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

In the middle of a warm grey, a white card with round corners, a one-pixel edge and a soft layered shadow, with a faint violet sheen at the top right. At the top the Bellwort mark (a white sprout in a violet square), «Mood check-in» and the «This week» pill. Below, the week’s average, 7.1 out of 10, the word Good and a small violet badge «0.4 vs last week». The chart has four dashed rows (Great, Good, Okay, Low), the days from Mon to Today and a violet line with a soft gradient fill and a soft shadow under it. On arrival the line starts flat and wakes up from left to right, wobbling to the real values. The line is an elastic cord: grabbed anywhere it stretches under the finger, the tighter it gets the thinner it draws, its neighbours follow like rubber, the day’s point swells with a bounce, a dark tooltip gives the day, the mood and the number, and the row and label of the nearest level turn violet. Let go, it wobbles and settles on the real values, because past days cannot change. Today is still dashed: pull its point and let go, and it lands on the nearest mood, the line turns solid, the point fills with a bounce, the line at the bottom becomes «Logged today, Great» with the tick drawing itself and the average rolls to 7.4. Left alone, a finger pulls Wednesday down and lets go, then lifts today up to Great.

How it works

A cord of particles

Between one day and the next there are eight particles, 49 in all. Each has a home on the Catmull-Rom curve through the real values, and the rest length between two neighbours is their distance at home. When today is logged the homes are recomputed and the cord goes there by itself.

Fixed-step verlet

At every 1/120 s step each particle keeps its speed (position minus previous position, times 0.986) and gets the spring towards home, stronger on the days and softer in between. A frame never counts more than 1/30 s, so a card coming back into view does not make the cord jump.

Rubber between neighbours

After the spring, two passes of constraints correct the distance between neighbours by only 14 percent: the cord stretches instead of dragging everything along. The largest stretch thins the stroke from 2.4 to 1.6 px.

The grabbed point

The particle under the finger follows it by 32 percent each step, with no home spring; its old position is kept, so on release it leaves with the speed it had. The tooltip reads the value from the height, with the nearest of five moods, and stays inside the chart at the edges.

Logging today

If the released point is in the last half day, the value goes to the nearest level, the curve is recomputed and the dashes turn solid. The average rolls with GSAP in 0.9 s, the tick draws with stroke-dashoffset and the point goes from 1.8 back to 1 on an elastic.

Values to change

NameFileDefaultWhat it changes
SPRINGscript.js70How hard each point is pulled back to its real value (higher, a faster wobble).
DAMPINGscript.js0.986How much movement is kept at every small step (closer to 1, it wobbles longer).
ELASTICscript.js0.14How much the neighbours follow a pulled point (higher, a stiffer cord).
GRABscript.js0.32How closely the grabbed point follows the finger.
POINTSscript.js8Particles of the cord between one day and the next.
ENTRY_WAVEscript.js0.6Seconds the cord takes to wake up from left to right on arrival.
LAST_WEEKscript.js6.7Last week’s average, for the change next to the number.
LOOPscript.jstrueLeft alone, the finger pulls the line and logs today again and again.

Try them in the Playground

When to use it

For the dashboard of a wellness, sleep, training or journaling app: when a chart should feel like something you can touch, and logging today’s value means pulling the line itself instead of filling in a form.

On phones

The same physics, with sizes taken from the chart at every resize: the card fills the width, the chart is tall in proportion to the screen height and the tooltip stays inside the edges. Pull with a finger, with touch-action off on the card.

With reduced motion

No wobble and no moving finger: the line is already on the values, today is logged and cleared with a fade of the chart, the grabbed point follows the finger without physics and goes straight back.

Pitfalls

  • With stiff constraints (a 50 percent correction) pulling one point drags the whole line like wire: for rubber the correction stays low and the home springs do the work.
  • A long frame time (a background tab) blows up verlet: it is capped at 1/30 s and run in fixed 1/120 s steps.
  • The grabbed point must not feel its home spring, or on release it jumps instead of leaving with its own speed.
  • On resize the homes must be recomputed in pixels, even mid-wobble, or the cord pulls towards a chart that is no longer there.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 10 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