Skip to content
animorio
IT
Back to the library

Portfolio chart crosshair

SVG, PhysicsGSAP, CSS onlyAdvancedCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The portfolio card of an invented investing app, Corvane, dark and clean like a Dribbble shot: the SVG value line with its faded area underneath behaves like a taut string. Dragging the crosshair the point follows it, the value and the date in the glass tag roll digit by digit and the change turns coral below the start; pressing pulls the string a few pixels towards the finger. Letting go, the crosshair springs back to ‘Now’, knocks on the end and the line hums for a moment before it settles. 1D, 1W, 1M and 1Y redraw the line point by point, each on its own spring.

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>
<!--
  "Portfolio chart crosshair" 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 portfolio chart with a spring crosshair and a line that hums like a string</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" data-stage>
    <!-- one gesture: drag. The portfolio card of an investing app. The value line is a taut string: dragging the
         crosshair along it the point follows, the value and the date roll, and pressing pulls the string a little;
         letting go, the crosshair springs back to now and the line hums for a moment. 1D 1W 1M 1Y morph the line
         point by point, each point on its own spring -->
    <section class="card" data-card aria-label="Corvane portfolio">
      <header class="card__head">
        <span class="card__brand">
          <svg class="card__mark" viewBox="0 0 20 20" aria-hidden="true">
            <path d="M3 13.2 7.4 8.6l3.2 2.8L17 5"></path>
            <path d="M12.6 5H17v4.4"></path>
          </svg>
          <span class="card__name">Corvane</span>
        </span>
        <span class="card__span" data-span>Past day</span>
      </header>

      <div class="card__value" data-value aria-live="polite"></div>
      <div class="card__change" data-change>
        <span class="chip" data-chip>
          <svg class="chip__arrow" data-chip-arrow viewBox="0 0 12 12" aria-hidden="true"><path d="M6 9.5V2.8M2.9 5.7 6 2.6l3.1 3.1"></path></svg>
          <span class="chip__amount" data-delta></span>
        </span>
        <span class="card__pct" data-pct></span>
      </div>

      <div class="chart" data-chart>
        <svg class="chart__svg" data-svg aria-hidden="true">
          <defs>
            <linearGradient id="pf-area" x1="0" y1="0" x2="0" y2="1">
              <stop class="stop-acc" offset="0" stop-opacity="0.30"></stop>
              <stop class="stop-acc" offset="0.55" stop-opacity="0.08"></stop>
              <stop class="stop-acc" offset="1" stop-opacity="0"></stop>
            </linearGradient>
            <linearGradient id="pf-hair" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#ffffff" stop-opacity="0"></stop>
              <stop offset="0.25" stop-color="#ffffff" stop-opacity="0.42"></stop>
              <stop offset="1" stop-color="#ffffff" stop-opacity="0.04"></stop>
            </linearGradient>
            <radialGradient id="pf-light" data-light gradientUnits="userSpaceOnUse" cx="0" cy="0" r="64">
              <stop offset="0" stop-color="#ffffff" stop-opacity="0.95"></stop>
              <stop offset="1" stop-color="#ffffff" stop-opacity="0"></stop>
            </radialGradient>
            <radialGradient id="pf-halo">
              <stop class="stop-acc" offset="0" stop-opacity="0.55"></stop>
              <stop class="stop-acc" offset="0.45" stop-opacity="0.16"></stop>
              <stop class="stop-acc" offset="1" stop-opacity="0"></stop>
            </radialGradient>
            <clipPath id="pf-past"><rect data-past x="0" y="0" width="0" height="0"></rect></clipPath>
            <clipPath id="pf-future"><rect data-future x="0" y="0" width="0" height="0"></rect></clipPath>
          </defs>
          <g class="grid" data-grid></g>
          <line class="base" data-base x1="0" x2="0" y1="0" y2="0"></line>
          <g data-plot>
            <path class="area" data-area clip-path="url(#pf-past)" fill="url(#pf-area)"></path>
            <path class="line line--future" data-line-future clip-path="url(#pf-future)"></path>
            <path class="line" data-line clip-path="url(#pf-past)"></path>
            <path class="line line--light" data-line-light clip-path="url(#pf-past)" stroke="url(#pf-light)"></path>
          </g>
          <g class="cross" data-cross>
            <line class="cross__hair" data-hair x1="0" x2="0" y1="0" y2="0" stroke="url(#pf-hair)"></line>
            <circle class="cross__halo" data-halo r="22" fill="url(#pf-halo)"></circle>
            <circle class="cross__ring" data-ring r="7"></circle>
            <circle class="cross__dot" data-dot r="4.2"></circle>
            <circle class="cross__shine" data-shine r="1.3"></circle>
          </g>
        </svg>
        <div class="tag" data-tag>
          <span class="tag__value" data-tag-value></span>
          <span class="tag__date" data-tag-date></span>
        </div>
      </div>

      <div class="axis" data-axis><span></span><span></span><span></span></div>

      <nav class="tabs" data-tabs aria-label="Period">
        <span class="tabs__pill" data-pill aria-hidden="true"></span>
        <button class="tabs__tab" type="button" data-period="1D" aria-pressed="true"><span>1D</span></button>
        <button class="tabs__tab" type="button" data-period="1W" aria-pressed="false"><span>1W</span></button>
        <button class="tabs__tab" type="button" data-period="1M" aria-pressed="false"><span>1M</span></button>
        <button class="tabs__tab" type="button" data-period="1Y" aria-pressed="false"><span>1Y</span></button>
      </nav>
    </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.

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 “Portfolio chart crosshair” 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 a graphite card rises, with round corners, a fine grain and a one pixel edge catching the light at the top. At the head the Corvane mark and the period, ‘Past day’; below it the big total coming in digit by digit from below, ‘$48,213.06’, and the change in a mint green pill with its arrow. Then the value line rises from the bottom point by point, left to right, each on its own spring, with the faded area underneath, the dashed line of the start and the lit point on ‘Now’ with its halo and the glass tag. A drawn pointer takes the point and drags it back: the point runs along the curve, the part after the crosshair dims to grey, a thin white light slides along the line around the point, the value and the date in the tag roll, and the string stretches towards the finger. Released, the crosshair springs back to ‘Now’, knocks on the end and bounces a little, and the line hums like a plucked string, less and less, until it stops. Tapping 1W the pill slides with a bounce and the line redraws with a wave from left to right; dragging below the start the pill turns coral and the arrow flips. Then 1M, 1Y and 1D again, and the loop starts over. With a mouse the crosshair follows the pointer even without pressing; with a finger you drag.

How it works

Forty points and a smooth curve

The line is an SVG in real pixels (the viewBox is rebuilt on resize): forty evenly spaced points joined by Bézier curves with Catmull-Rom tangents. The same Hermite polynomial gives the curve's height anywhere, so the crosshair always sits on the line, even between two points.

A taut string over the data

Each point has its own offset following the wave equation: tension between neighbours, a little friction, both ends fixed. The tension comes from HUM, vibrations per second, and is integrated in small steps per frame, small enough to stay stable. Pressing pulls the point under the finger towards it; released, the string hums on its own.

The crosshair on two springs

While dragged the crosshair chases the finger on a stiff spring with almost no bounce; released, a softer spring brings it back to ‘Now’. The end is a wall: it knocks on it, bounces back a third and gives a small push to the last points of the string, which hums even when it was never pulled.

Rolling figures

Value, date, change and period are made of slots, one per character: when a character changes the old one leaves upwards and the new one comes in from below in the same grid cell, with a one pixel overshoot. Only what changes rolls, in the direction the crosshair goes, and quicker while it is dragged.

The period, point by point

Changing the period each point gets its new height a few milliseconds after its left neighbour and runs there on its own spring: the line redraws like a wave. The period pill slides with a bounce, the start line moves and the dates underneath change with a fade.

Values to change

NameFileDefaultWhat it changes
POINTSscript.js40How many points make the line.
HUMscript.js3.4How fast the string hums after a release, in vibrations per second.
SETTLEscript.js1.1How long the hum lasts, in seconds.
PULLscript.js1How much pressing pulls the string towards the finger (0 = not at all).
RETURN_STIFFNESSscript.js80The spring that brings the crosshair back to now: higher is quicker.
RETURN_DAMPINGscript.js9.5Lower lets the crosshair knock harder on the end and bounce.
MORPH_STIFFNESSscript.js170The spring of each point when the period changes.
MORPH_DAMPINGscript.js18Lower lets each point pass its height and come back.
MORPH_STAGGERscript.js0.012Seconds between a point and the next one when the period changes.
LOOPscript.jstrueThe drawn pointer plays the card again and again.

Try them in the Playground

When to use it

For the home screen of an investing app or an online bank, an account dashboard, the page of a financial product or the showcase of a fintech startup: the chart people want to touch.

On phones

The same animation with adapted sizes: the card is as wide as the box, the chart is measured on the height too, the tag always stays inside the card and a finger drags the crosshair; vertical page scrolling stays free.

With reduced motion

No springs, no hum, no rolling figures: the line is already in place, the crosshair goes where you touch and returns to Now without travelling, the numbers change at once and a period change is a fade.

Pitfalls

  • The wave equation integrated by hand blows up if the step is too long: the step must stay under 1 over the square root of the tension, which is why there are several small steps per frame.
  • The crosshair must sit on the drawn curve, not on the polyline of the points: it uses the same Catmull-Rom as the path, in Hermite form.
  • With Mona Sans tabular-nums the zero is slashed: here the figures stay proportional and each slot takes the width of the wider character while it rolls.
  • The part after the crosshair is the same path with a different clipPath: two rectangles that move every frame, so the line never breaks.

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