Skip to content
animorio
IT
Back to the library

Glucose curve

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.0 KBGSAP 28 KBFreeDownload the zip

A glucose sensor’s day: the curve draws itself inside the target band and the large value follows its tip; outside the band the line and the number turn warm and the word rolls to “High” or “Low”. The point can be taken back along the day and the arrow leans with the trend.

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>
<!--
  "Glucose curve" 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>Glucose curve</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">
    <!-- a glucose sensor's day: the curve draws itself through the target band, the reading follows its tip,
         and the point can be dragged back along the day; the arrow leans with the trend -->
    <section class="gl" data-gl aria-label="Glucose today">
      <header class="gl__head">
        <p class="gl__read">
          <b class="gl__num" data-num>0</b>
          <span class="gl__unit" data-unit></span>
          <svg class="gl__arrow" viewBox="0 0 28 28" aria-hidden="true"><g transform="translate(14 14)"><g data-arrow><path d="M-7.500 0H7.500M2.500-5 7.500 0 2.500 5"></path></g></g></svg>
        </p>
        <p class="gl__state"><span class="gl__word"><span data-word>In range</span></span><span class="gl__time" data-time></span></p>
      </header>

      <div class="gl__chart" data-chart role="slider" tabindex="0" aria-label="Time of day" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100">
        <svg viewBox="0 0 300 132" preserveAspectRatio="none" aria-hidden="true">
          <defs>
            <clipPath id="gl-seen"><rect data-seen x="0" y="-10" width="0" height="152"></rect></clipPath>
            <clipPath id="gl-in"><rect data-clip-in x="0" y="0" width="300" height="0"></rect></clipPath>
            <clipPath id="gl-out"><rect data-clip-high x="0" y="-10" width="300" height="0"></rect><rect data-clip-low x="0" y="0" width="300" height="0"></rect></clipPath>
          </defs>
          <rect class="gl__band" data-band x="0" y="0" width="300" height="0" rx="3"></rect>
          <line class="gl__edge" data-edge-high x1="0" x2="300"></line>
          <line class="gl__edge" data-edge-low x1="0" x2="300"></line>
          <g clip-path="url(#gl-seen)">
            <path class="gl__line gl__line--in" data-line clip-path="url(#gl-in)"></path>
            <path class="gl__line gl__line--out" data-line clip-path="url(#gl-out)"></path>
          </g>
          <line class="gl__rule" data-rule y1="0" y2="132"></line>
        </svg>
        <i class="gl__dot" data-dot></i>
        <span class="gl__lim gl__lim--high" data-lim-high></span>
        <span class="gl__lim gl__lim--low" data-lim-low></span>
      </div>
      <div class="gl__hours" data-hours aria-hidden="true"></div>

      <p class="gl__tir"><span>Time in range</span><b><span data-tir>0</span>%</b></p>
      <div class="gl__share" aria-hidden="true"><i data-s-low></i><i data-s-in></i><i data-s-high></i></div>
    </section>

    <svg class="ghost" data-ghost 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.

16 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 “Glucose curve” 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 paper-coloured ground, at the top a large number with the unit beside it and on the right an arrow in a circle; below, a word (“In range”) and the time. In the middle the chart: a soft teal band between two dashed lines, the limits 180 and 70 written on the right, and the hours from 8 to 20 underneath. As it opens, the curve draws itself from the left: a ring point runs on its tip with a thin vertical rule, the number follows it and the arrow leans up when it rises and down when it falls, settling with a small spring. Where the curve leaves the top of the band, after lunch, that stretch is orange: the number takes weight and colour, the word rolls to “High” and the point jolts; the same in the afternoon dip, with “Low”. At the bottom “Time in range” counts its percentage and a thin bar splits between low, in range and high. Once it reaches “Now”, the curve stays: moving the pointer over it, or dragging a finger, the point goes back along the day and everything follows; on leaving, it returns to now.

How it works

The same samples

The half-hourly readings go through a Catmull-Rom curve sampled 240 times: the same samples draw the path and give the value under the point, so number and line never disagree.

Two colours with clips

The same path is drawn twice: one copy clipped by the band, teal, and one clipped by what is above and below it, orange. A third clip, as wide as the time elapsed, reveals the curve.

The trend arrow

The slope is the difference between the values a quarter of an hour before and after. It becomes an angle written into the arrow’s transform attribute, reached with back.out: it settles instead of snapping.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0f9d8aThe colour of the target band.
LOWscript.js70Below this value glucose is low.
HIGHscript.js180Above this value glucose is high.
UNITscript.jsmg/dLThe unit of measure.
DRAWscript.js2.6How many seconds the curve takes to draw.
LOOPscript.jstrueLeft alone, a pointer takes the point back to the peak and the dip.

Try them in the Playground

When to use it

On the page of a diabetes app or a glucose sensor, on the site of whoever sells them, in a health app; and wherever a value is read inside a target band: a cold room’s temperature, a greenhouse’s humidity, a server’s load.

On phones

The same scene: the point is dragged with a finger along the chart, without scrolling the page. Number and chart are also sized on the window’s height.

With reduced motion

The curve is already drawn and the point is on now. The point moves without gliding and the words change without rolling.

Pitfalls

  • The day’s values and the limits are made up, as an example: they are not medical advice. In a real app they come from the sensor and the limits are set by the doctor.
  • The chart is a slider for the keyboard: arrows for a quarter of an hour, Page up and down for an hour, Home and End; aria-valuetext says time and value.
  • High and low are not told by colour alone: there is the word beside the number, and the arrow gives the trend.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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