Skip to content
animorio
IT
Back to the library

Live latency chart

SVG, HoverGSAPMediumCompressed weight: Demo 7.5 KBGSAP 28 KBFreeDownload the zip

The monitoring card of a service, light and product grade: the latency line scrolls live from the right and the big number follows it. When a spike crosses the dashed threshold, the part above turns red, a small flag is planted where it crossed and travels away with the data, the status pill flips to ‘Degraded’ and the alert count rolls; then everything goes green again. Under the pointer a hairline reads any moment of the line.

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 latency 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 latency chart with a spike that trips the alert threshold</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 latency card of a monitoring dashboard: the line scrolls live from the right while the number follows it;
         when a spike crosses the dashed threshold the part above turns red, a flag is planted where it crossed and
         travels away with the data, the status pill flips to Degraded and the alert count rolls; then it recovers.
         Under the pointer a hairline reads any moment of the line -->
    <article class="card" data-card aria-label="Latency of the checkout API, live">
      <header class="head">
        <span class="service">
          <svg class="service__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M3 10h3.4l2-5.4 3.2 10.8 2-5.4H17"></path></svg>
          checkout-api
        </span>
        <span class="status" data-status>
          <svg class="status__icon" viewBox="0 0 14 14" aria-hidden="true">
            <path class="status__ok" d="M3.2 7.4 5.9 10 10.8 4.4"></path>
            <path class="status__bad" d="M7 3.4v4.4M7 10.4v.2"></path>
          </svg>
          <span class="status__roll"><span class="status__word" data-status-word>Healthy</span></span>
        </span>
      </header>

      <div class="read">
        <span class="read__n"><span data-ms>0</span><small>ms</small></span>
        <span class="read__label">p95 latency, live</span>
      </div>

      <div class="chart" data-chart>
        <svg class="chart__svg" data-svg role="img" aria-label="Line chart of the latency over the last seconds">
          <defs>
            <linearGradient id="lat-area" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="var(--accent)" stop-opacity="0.2"></stop>
              <stop offset="1" stop-color="var(--accent)" stop-opacity="0"></stop>
            </linearGradient>
            <linearGradient id="lat-hot" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="var(--alert)" stop-opacity="0.26"></stop>
              <stop offset="1" stop-color="var(--alert)" stop-opacity="0.04"></stop>
            </linearGradient>
            <clipPath id="lat-below"><rect data-clip-below></rect></clipPath>
            <clipPath id="lat-above"><rect data-clip-above></rect></clipPath>
            <clipPath id="lat-wipe"><rect data-clip-wipe></rect></clipPath>
          </defs>
          <g data-grid class="chart__grid"></g>
          <g clip-path="url(#lat-wipe)">
            <g clip-path="url(#lat-below)">
              <path class="chart__area" data-area fill="url(#lat-area)"></path>
              <path class="chart__line" data-line></path>
            </g>
            <g clip-path="url(#lat-above)">
              <path class="chart__area" data-area-hot fill="url(#lat-hot)"></path>
              <path class="chart__line chart__line--hot" data-line-hot></path>
            </g>
            <g data-flags></g>
            <rect class="chart__head" data-head width="3" height="13" rx="1.5"></rect>
          </g>
          <line class="chart__limit" data-limit></line>
          <line class="chart__hair" data-hair></line>
          <rect class="chart__mark" data-mark width="3" height="13" rx="1.5"></rect>
        </svg>
        <span class="limit" data-limit-tag><span data-limit-text>Alert at 300 ms</span></span>
        <div class="tip" data-tip aria-hidden="true"><b data-tip-n>142 ms</b><span data-tip-t>8 s ago</span></div>
      </div>

      <footer class="foot">
        <span>Region <b>eu-west</b></span>
        <span class="foot__alerts">Alerts today <b class="foot__n"><span data-alerts>2</span></b></span>
      </footer>
    </article>

    <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.

25 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 latency 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 warm white page sits a white card with round corners and a soft shadow that barely takes the colour of the status. At the top the service name, ‘checkout-api’, with its mark, and on the right the green ‘Healthy’ pill with a tick. Below, the big number of milliseconds with the words ‘p95 latency, live’, then the chart: three thin lines behind, the dashed threshold line with its ‘Alert at 300 ms’ tag and the green latency line, with a fade under it, which comes in from left to right like a curtain and then scrolls without stopping: new data arrives from the right, where a small bar marks the present, and the big number chases it. A pointer crosses the chart: a vertical hairline follows it, a dark bar rides up and down the line and a dark label says ‘142 ms’ and ‘6 s ago’. Then the spike arrives: the line climbs over the threshold and the part above is red, with its own fade; where it crossed a red flag rises with a small spring, the threshold tag fills with red and takes a sideways knock, the pill flips to ‘Degraded’ with an exclamation mark, the number turns red and ‘Alerts today’ rolls from 2 to 3. The line comes back down, a second smaller spike brushes the threshold without touching it, and after a moment everything is green again, while the flag travels left with the data until it leaves. With a real pointer or finger the hairline follows the hand.

How it works

A data clock

Everything depends on one number, the data time, which advances every frame. Each sample has an index; its x is the width minus (now minus index) times the pitch, so the line scrolls smoothly between samples too, and the last point, on the right, is interpolated at the exact instant.

The smooth line

Every frame the visible points become an SVG path of Bézier curves (Catmull-Rom: each handle is a sixth of the distance between the two neighbours). The same path, closed at the bottom, makes the fade.

Green below, red above

The line is drawn twice with the same path: a green one clipped by a clipPath below the threshold, a red one clipped above. So the change of colour falls exactly on the dashed line, with no intersections to compute.

The travelling flag

Among the visible samples the code looks for pairs going from below to above the threshold: there, with an interpolation, the flag is planted. It has no state: its position is worked out every frame from the data, and its height depends on the seconds since the crossing, with a spring that dies out.

The status and the alert

When the head of the line goes over the threshold, the card takes the is-bad class: one CSS variable changes pill, number, shadow and tag. The pill’s word and the alert count leave and come back with back.out; the tag takes a knock with elastic.out. The status is good again 0.9 seconds after the line has come down.

The hairline under the pointer

From the pointer’s x the code goes back to the fractional index of the sample and its value: hairline, bar and label read the line while it scrolls underneath. The label stays inside the sides and goes below the line when there is no room above.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0e9f8aThe colour of the line when all is well.
ALERTscript.js#f0442eThe colour above the threshold.
THRESHOLDscript.js300The alert threshold, in milliseconds.
PEAKscript.js430How high the spike goes, in milliseconds: below the threshold, the alert never trips.
SPEEDscript.js4.5How many samples a second: higher makes the line run faster.
EVERYscript.js11How many seconds between one spike and the next.
LOOPscript.jstrueLeft alone, a pointer reads the line between one spike and the next.

Try them in the Playground

When to use it

For the dashboard of a monitoring tool, a cloud service or a developer app, and for a product’s status page: the card that shows a live number and what happens when it goes over the limit. Also good on the product page as a showpiece.

On phones

The same animation with adapted sizes: the pitch between samples tightens, the chart height follows the window’s and the number gets smaller. Touching and dragging on the chart the hairline follows the finger.

With reduced motion

The line does not scroll: the chart stands still on a moment with a spike already past, red above the threshold and with its flag. The hairline under the pointer works without easing.

Pitfalls

  • Colouring the line in pieces by computing where it meets the threshold leaves visible joints: two copies of the same path clipped by two clipPaths are exact and cheaper.
  • The flag should not be created on the event and then moved: worked out from the data every frame it stays right after a resize or a tab change.
  • The data time advances with the ticker’s delta, capped at 50 milliseconds: coming back from another tab the line does not jump ahead.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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