Skip to content
animorio
IT
All components

Live heart rate chart

Charts, HoverGSAP, CanvasMediumCompressed weight: Demo 8.5 KBGSAP 28 KBFreeDownload the zip

The live heart rate card of a running app, a chart that writes itself: the ECG trace is born from a glowing head running in from the left and leaving a fading tail, the beats per minute roll on the beat, like on a sports watch, and the drawn heart beats in time, lub and dub. When the pace rises the trace moves from Easy to Cardio to Peak and changes colour; hovering the trace, a thin hairline tells you the heart rate a few seconds ago.

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>
<!--
  "Live heart rate 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 live heart rate chart with the ECG trace writing itself</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 live heart rate card of a running app: the ECG trace is written from the left by a glowing head with
         a fading tail, the bpm rolls on every beat, the drawn heart beats in time, and when the pace rises the
         trace moves into the next zone and changes colour; over the trace a hairline reads back the past -->
    <section class="card" data-card aria-label="Live heart rate, Halyard">
      <header class="head">
        <span class="mark" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M3.5 13.2c2.4-.2 3.6-1.7 4.6-3.6 1-1.9 1.9-3.9 4.4-4.4M6.6 15.6c3.1 0 5-1.4 6.3-3.6.9-1.6 1.8-3.1 3.6-3.6"></path></svg>
        </span>
        <span class="who">
          <span class="who__name">Tempo run</span>
          <span class="who__sub">Halyard · <span data-clock>24:18</span></span>
        </span>
        <span class="zone-tag" data-zone-tag><span>Easy</span></span>
      </header>

      <div class="readout">
        <span class="heart" data-heart aria-hidden="true">
          <svg viewBox="0 0 24 24">
            <defs>
              <linearGradient id="carne" x1="0.2" y1="0" x2="0.8" y2="1">
                <stop class="s1" offset="0"></stop>
                <stop class="s2" offset="1"></stop>
              </linearGradient>
            </defs>
            <path class="heart__body" d="M12 20.4c-.28 0-.55-.1-.76-.29C6.5 15.9 3.1 12.9 3.1 9.05 3.1 6.4 5.18 4.3 7.76 4.3c1.62 0 3.08.82 4.24 2.24C13.16 5.12 14.62 4.3 16.24 4.3c2.58 0 4.66 2.1 4.66 4.75 0 3.85-3.4 6.85-8.14 11.06-.21.19-.48.29-.76.29Z"></path>
            <path class="heart__shine" d="M6.3 7.2c.5-.9 1.4-1.4 2.3-1.3"></path>
            <path class="heart__shine heart__shine--2" d="M5.6 9.6c0 .5.1 1 .3 1.4"></path>
          </svg>
        </span>
        <span class="bpm">
          <span class="bpm__num" data-bpm aria-live="off"><span>112</span></span>
          <span class="bpm__unit">bpm</span>
        </span>
        <span class="side">
          <span class="side__label">Zone</span>
          <span class="side__zone" data-zone-name><span>Easy</span></span>
        </span>
      </div>

      <div class="trace" data-trace>
        <canvas data-canvas aria-label="Heart rate trace" role="img"></canvas>
        <span class="probe" data-probe aria-hidden="true">
          <span class="probe__line"></span>
          <span class="probe__tag" data-probe-tag>142 bpm</span>
        </span>
      </div>

      <div class="zones" data-zones aria-hidden="true">
        <span class="zones__seg" data-seg="0" style="--w:40"><i></i><b>Easy</b></span>
        <span class="zones__seg" data-seg="1" style="--w:30"><i></i><b>Cardio</b></span>
        <span class="zones__seg" data-seg="2" style="--w:30"><i></i><b>Peak</b></span>
        <span class="zones__marker" data-marker></span>
      </div>

      <dl class="stats">
        <div><dt>Avg</dt><dd data-avg>112</dd></div>
        <div><dt>Max</dt><dd data-max>112</dd></div>
        <div><dt>In zone</dt><dd data-inzone>0:00</dd></div>
      </dl>
    </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.

35 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 “Live heart rate 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 black background there is only a dark card: a run on Halyard, a made-up training app, Tempo run, with the time ticking at the top. On the right a tag says the zone, Easy. Below, the drawn heart, solid, with a highlight and a vein, and next to it the beats per minute, big, then the zone written out. In the middle the ECG paper, a barely visible grid, where a glowing head writes the trace from left to right: the small wave, the tall narrow spike, the soft tail, at every beat; behind the head the last stretch glows and the rest fades into the dark, and ahead there is always a gap where the old trace is wiped. On the beat the number rolls, at most once a second like on a sports watch, the old figure rising away before the new one comes in; and at every beat the heart beats twice, a strong beat and a smaller one, widening a little more than it grows taller and settling on a spring. The workout rises by itself: warm-up, tempo, sprint, recovery. Above 130 beats the trace turns yellow, Cardio, above 160 red, Peak: the trace keeps the colours it was written in, the tag and the zone change their words, the zone’s segment under the trace lights up with a small bump and the white mark runs to its place on a spring. At the bottom the average, the maximum and the time spent in the zone. Moving the pointer over the trace brings up a thin hairline with a tag: the beats at that point and how many seconds ago.

How it works

A real beat, made of five waves

Every beat is the sum of five bells (Gaussians): the P wave, the Q dipping down, the R spike, the S, the wide T wave. When the heart beats fast the waves move closer together, like on a real ECG, instead of overlapping.

One column per pixel

The head moves one pixel at a time on gsap.ticker and stores, for each column, the value, the zone, the beats and the moment. The canvas redraws from oldest to newest in four-pixel pieces, each with its own opacity: so the tail fades and the colours stay the ones they were written in.

The heart beats on the spike

The heart’s beat and the number start when the trace reaches the R spike, not at the start of the beat: you see it beat exactly when the line shoots up. The number changes at most once every nine tenths of a second, or at 170 beats it would never stop rolling.

Zones are thresholds

Below 130 Easy, below 160 Cardio, above it Peak: at every beat the zone is worked out again, and only when it changes do the words, the card’s colour and the lit segment change.

Reading the past

The hairline over the trace takes the column under the pointer and its age, the distance from the head divided by the speed: that is how it knows the beats and how many seconds ago.

Values to change

NameFileDefaultWhat it changes
SWEEPscript.js3.6How many seconds the head takes to cross the trace.
RESTscript.js112The beats per minute at the start and the end of the workout.
PEAKscript.js168The beats per minute at the hardest sprint.
LOOPscript.js18How long the workout loop lasts, in seconds.
GLOWscript.js1How much the writing head glows.
TAILscript.js0.85How much the tail of the trace fades.

Try them in the Playground

When to use it

In the app of a sports watch, a gym or an online coach, on the workout-in-progress screen; with other data, for any live signal with thresholds: a home’s energy use, a server’s traffic, breathing in a meditation app.

On phones

The same card at the width of the screen, with a shorter trace on short screens; a finger on the trace brings up the hairline reading the beats and doesn’t scroll the page.

With reduced motion

No running head, beating heart or rolling numbers: the trace is written all at once and refreshes once a second, the texts change with a fade.

Pitfalls

  • If the trace moves on system time, it jumps in the video and with the tab hidden: it runs on gsap.ticker with the time between frames capped at 64 milliseconds, and moves one pixel at a time.
  • Drawing the trace as a single path, at the right edge the line goes back to the left across the whole chart: when the next column is further left, start again with moveTo.
  • The canvas is measured in CSS pixels, redrawn at the screen’s density and recalculated on resize: the demo window changes height while you watch.
  • With tabular-nums Mona Sans draws a slashed zero: the figures stay proportional.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 30 October 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