Skip to content
animorio
IT
Back to the library

Stage elevation chart

SVG, HoverGSAPAdvancedCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The route card of a made-up cycling app, Ridgeway, in the premium product style: on a near black page the elevation profile of a 142 km stage draws itself as one thin SVG line that takes the colour of its own grade, cool grey on the flat, amber on the climbs, coral where it bites. The three climbs raise the flag of their category, a cursor rides the stage on a spring with a light under it and a tooltip with kilometre, altitude and grade, and when it rides into a climb it lights it up and the numbers below switch from the whole route to that climb. At the summit the route is sent to the bike computer.

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>
<!--
  "Stage elevation 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 elevation chart of the stage with the climbs that light up</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 route card of a made-up cycling app, Ridgeway: the elevation profile of a 142 km stage drawn as one thin
         SVG line coloured by its own gradient (cool on the flat, amber on the climbs, coral where it bites), the three
         climbs lighting up with their category, a cursor that rides the route with a light under it, and the button
         that sends the route to the bike computer -->
    <article class="route" data-card>
      <span class="route__rim" data-rim aria-hidden="true"></span>
      <header class="route__head">
        <div class="route__title">
          <span class="route__eyebrow">Stage 4 &middot; Saturday</span>
          <h1 class="route__name">The Ventara Loop</h1>
        </div>
        <span class="route__chip">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 13l4.6-7.2 2.7 4 1.7-2.4L14.5 13z"/><path class="route__chip-flag" d="M10.2 7.4V2.6l2.6 1.1-2.6 1.1"/></svg>
          Summit finish
        </span>
      </header>

      <div class="route__chart" data-chart>
        <div class="tip" data-tip aria-hidden="true">
          <span class="tip__face">
            <span class="tip__km" data-tip-km>km 0.0</span>
            <span class="tip__alt" data-tip-alt>320 m</span>
            <span class="tip__grade" data-tip-grade>0.0%</span>
          </span>
        </div>
        <svg class="plot" data-svg aria-hidden="true">
          <defs>
            <linearGradient id="rg-grade" data-grade gradientUnits="userSpaceOnUse"></linearGradient>
            <linearGradient id="rg-fade" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#fff" stop-opacity="0.95"/>
              <stop offset="1" stop-color="#fff" stop-opacity="0"/>
            </linearGradient>
            <mask id="rg-area-mask" maskUnits="userSpaceOnUse" data-area-mask>
              <rect data-area-mask-rect fill="url(#rg-fade)"/>
            </mask>
            <radialGradient id="rg-column" data-column-grad>
              <stop offset="0" stop-color="currentColor" stop-opacity="0.42"/>
              <stop offset="0.55" stop-color="currentColor" stop-opacity="0.12"/>
              <stop offset="1" stop-color="currentColor" stop-opacity="0"/>
            </radialGradient>
            <radialGradient id="rg-head">
              <stop offset="0" stop-color="#fff" stop-opacity="0.9"/>
              <stop offset="0.25" stop-color="#ffc46b" stop-opacity="0.45"/>
              <stop offset="1" stop-color="#ffc46b" stop-opacity="0"/>
            </radialGradient>
            <clipPath id="rg-drawn"><rect data-clip-drawn/></clipPath>
            <clipPath id="rg-ridden"><rect data-clip-ridden/></clipPath>
          </defs>
          <g class="plot__grid" data-grid></g>
          <g class="plot__bands" data-bands></g>
          <ellipse class="plot__column" data-column fill="url(#rg-column)"/>
          <g clip-path="url(#rg-drawn)">
            <path class="plot__area" data-area fill="url(#rg-grade)" mask="url(#rg-area-mask)"/>
            <path class="plot__line plot__line--dim" data-line-dim stroke="url(#rg-grade)"/>
          </g>
          <g clip-path="url(#rg-ridden)">
            <path class="plot__line" data-line stroke="url(#rg-grade)"/>
          </g>
          <g class="plot__climbs" data-climbs></g>
          <ellipse class="plot__head" data-head fill="url(#rg-head)"/>
          <g class="plot__cursor" data-cursor>
            <line class="plot__hair" data-hair/>
            <circle class="plot__ring-shadow" data-ring-shadow r="7"/>
            <circle class="plot__ring" data-ring r="4.5"/>
          </g>
        </svg>
        <div class="flags" data-flags></div>
        <div class="axis" data-axis aria-hidden="true"></div>
      </div>

      <section class="stats" aria-live="polite">
        <p class="stats__caption"><span data-caption>Whole route</span></p>
        <div class="stats__row">
          <div class="stat"><span class="stat__label" data-label>Distance</span><span class="stat__value"><span data-value>0.0</span><small data-unit>km</small></span></div>
          <div class="stat"><span class="stat__label" data-label>Elevation</span><span class="stat__value"><span data-value>0</span><small data-unit>m</small></span></div>
          <div class="stat"><span class="stat__label" data-label>Max grade</span><span class="stat__value"><span data-value>0.0</span><small data-unit>%</small></span></div>
        </div>
      </section>

      <button class="send" type="button" data-btn>
        <span class="send__face" data-face>
          <span class="send__icon" aria-hidden="true">
            <svg viewBox="0 0 18 18">
              <g data-icon-send><rect x="4.5" y="2.2" width="9" height="13.6" rx="2.2"/><path d="M9 5.4v5.2M6.8 8.6L9 10.8l2.2-2.2"/><path d="M7.4 13.2h3.2"/></g>
              <circle class="send__arc" data-arc cx="9" cy="9" r="6.2" pathLength="1"/>
              <path class="send__check" data-check pathLength="1" d="M4.6 9.4l3 3 5.8-6.4"/>
            </svg>
          </span>
          <span class="send__words" data-words>Send to bike computer</span>
        </span>
      </button>
    </article>
  </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.

37 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 “Stage elevation 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 near black page with two soft lights, amber above and cool below, and a fine grain, the route card of Ridgeway, a made-up cycling app, rises: at the top ‘Stage 4 · Saturday’, the title ‘The Ventara Loop’ and on the right the amber pill ‘Summit finish’ with a drawn mountain. In the middle the chart: the dashed lines of the altitudes (500, 1,000, 1,500, 2,000 m), the kilometres below, and the profile drawing itself from the left with a small light at its head. The line is thin and takes the colour of the grade kilometre by kilometre: cool grey on the flat and downhill, amber as it climbs, coral past 8%; the area under it fills with the same colours and fades to the bottom. The three climbs raise their flags one by one on a spring: Cat 2 on the Col Ardena, Cat 3 on the Côte de Vire, HC on the Passo Ventara, each with a dashed stem and the mark of the summit. Below, ‘Whole route’ and the numbers counting up: 142.0 km, 2,880 m of elevation gain, 12.9% maximum grade. Then the cursor appears, a ring with its shadow and a thin vertical line, and rides the stage on a spring: the part already ridden stays lit and the rest dims, under the ring a soft light in the colour of the grade, above it a glass tooltip with kilometre, altitude and the grade pill, and the rim of the card catches the same light where it passes. Riding into a climb its flag lights up in its colour, the climb's area glows, the rest of the line steps back and the numbers roll over to the climb: length, gain and average grade, with its name above. At the top of the Passo Ventara the light ‘Send to bike computer’ button is pressed, gives and comes back on a spring, an arc spins with ‘Sending route’, then the check draws itself and it turns amber, ‘On your bike computer’. Then everything dims and the stage starts again. With the pointer or a finger on the chart you take the cursor wherever you like, a tap on a flag jumps to its summit.

How it works

A made-up but credible stage

The profile comes from fourteen key points (kilometre and altitude) joined with a cosine, plus three small sine waves for the rolling bits, faded to zero at the start and the finish. It is sampled every 250 metres: the same function gives the line, the total elevation gain (the sum of the rises from one sample to the next), the maximum grade and the numbers of each climb, so everything adds up.

The line coloured by its own grade

The colour is not one stroke per segment but a single horizontal linearGradient in userSpaceOnUse with a stop every kilometre: each stop takes the colour of the grade there, interpolated between grey, amber and coral (STEEP says where it turns fully coral). The same gradient fills the area, with a mask that fades it towards the bottom.

Drawn with two clips

The profile does not draw itself with a dash but with a clipPath that widens from the left, so line and area arrive together. A second clip, as wide as the cursor, keeps the part already ridden lit over a dim copy of the line. The SVG is rebuilt in pixels on every resize, so the line stays thin at any size.

The cursor on a spring

The cursor follows the wanted kilometre (from the ride on its own or from the finger) on a spring integrated in three steps per frame: STIFFNESS and DAMPING decide how quick it is and how far it passes the mark. The ring widens a little with the speed, the light under it is an ellipse with a radialGradient in currentColor, and the colour comes from the grade at that point.

The climbs and the numbers

When the cursor stays a tenth of a second inside a climb, its flag lights up, the area glows, the line around it steps back and the numbers roll over to the climb on a short spring: the labels change with a touch of blur, the digits count to the new value. Outside every climb they go back to the whole route.

Values to change

NameFileDefaultWhat it changes
DRAWscript.js2.6How many seconds the profile takes to draw itself.
RIDEscript.js6How many seconds the cursor takes to ride the stage on its own.
STIFFNESSscript.js140The cursor's spring: higher is quicker.
DAMPINGscript.js16Lower lets the cursor pass the mark and come back.
LIGHTscript.js1How strong the light under the cursor and on the card's rim is.
STEEPscript.js8The grade (in %) where the line turns fully coral.
SPEEDscript.js12 = the ride on its own twice as fast, 0.5 = half.
LOOPscript.jstrueRepeats the ride on its own.

Try them in the Playground

When to use it

For the route page of a cycling, running or hiking app, for the stage of a race or a gran fondo on the event's site, for the detail of a hike on a travel site: whenever a value has a profile along a distance and it pays to read it with a finger.

On phones

The same animation with adapted sizes: the card is as wide as the box, the chart is as tall as the screen allows and is rebuilt in pixels, the flags and the tooltip always stay inside the edges; the finger drags the cursor sideways and leaves the page free to scroll vertically.

With reduced motion

The profile fades in already drawn, the flags fade in without a spring, the cursor appears still on the Passo Ventara and the numbers change without counting; the button changes its label and check with a fade.

Pitfalls

  • A stop-color in currentColor inside a gradient takes its colour from the gradient itself, not from the shape using it: to tint the light under the cursor the colour has to be written on the radialGradient.
  • Drawing with a dash would bring the line ahead of the area on the climbs (the line is longer where it rises): with a clipPath that widens horizontally they arrive together.
  • The ride on its own and the finger move two different states: if the finger wrote into the ride's object, on resuming the ride's tweens and the finger's would fight over the same values.
  • On a phone the chart has touch-action: pan-y: the finger drags the cursor sideways, but the page still scrolls vertically.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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