Skip to content
animorio
IT
All components

Revenue range chart

Charts, Hover, SVGGSAPAdvancedCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

The revenue card of a dashboard, clean on white: the total in tabular digits that roll like an odometer, the badge with the change and a violet line. Under the pointer a cursor snaps from day to day and the total rolls to that day; dragging across the chart picks a range, the line outside it turns grey, two handles appear to move it and the total rolls to the range's sum. 7D, 30D and 90D bend the line into the new period, with the white pill sliding under the choice.

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>
<!--
  "Revenue range 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 revenue range chart</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>
    <!-- the revenue card of a dashboard: the total in rolling tabular digits, the change against the previous period
         and a line chart. Point at a day and the figure rolls to it; drag across the chart and the range lights up,
         the figure rolls to the range's total and the badge to its change. 7D, 30D and 90D bend the line into
         the new period -->
    <article class="rev" data-rev>
      <header class="rev__head">
        <div class="rev__title">
          <svg class="rev__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 13.5h11 M4 11V8.5 M7 11V5.5 M10 11V7 M13 11V3.5"></path></svg>
          <span data-metric>Revenue</span>
        </div>
        <div class="seg" role="tablist" aria-label="Period" data-seg>
          <span class="seg__pill" data-pill aria-hidden="true"></span>
          <button class="seg__btn" type="button" role="tab" data-range="0">7D</button>
          <button class="seg__btn" type="button" role="tab" data-range="1">30D</button>
          <button class="seg__btn" type="button" role="tab" data-range="2">90D</button>
        </div>
      </header>

      <div class="rev__fig">
        <div class="num" data-num aria-hidden="true"></div>
        <span class="badge" data-badge>
          <svg class="badge__arrow" data-arrow viewBox="0 0 12 12" aria-hidden="true"><path d="M6 9.5V2.8 M2.9 5.6 6 2.5l3.1 3.1"></path></svg>
          <span class="badge__num" data-badge-num></span>
        </span>
      </div>
      <div class="rev__subrow">
        <p class="rev__sub" data-sub></p>
        <button class="clear" type="button" data-clear aria-label="Clear the range" tabindex="-1">
          <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3.2 3.2l5.6 5.6 M8.8 3.2 3.2 8.8"></path></svg>
          <span>Clear</span>
        </button>
      </div>

      <div class="plot" data-plot tabindex="0" role="img" aria-label="Revenue chart. Arrow keys move along the days, Shift and the arrows select a range, Escape clears it.">
        <svg class="plot__svg" data-svg aria-hidden="true">
          <defs>
            <linearGradient id="rev-fill" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="var(--accent)" stop-opacity=".22"></stop>
              <stop offset="1" stop-color="var(--accent)" stop-opacity="0"></stop>
            </linearGradient>
            <linearGradient id="rev-fill-dim" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="var(--dim)" stop-opacity=".45"></stop>
              <stop offset="1" stop-color="var(--dim)" stop-opacity="0"></stop>
            </linearGradient>
            <clipPath id="rev-clip"><rect data-clip x="0" y="-20" width="0" height="400"></rect></clipPath>
          </defs>
          <g data-grid></g>
          <rect class="plot__band" data-band x="0" y="0" width="0" height="0" rx="6"></rect>
          <path class="plot__area plot__area--dim" data-area-dim></path>
          <path class="plot__line plot__line--dim" data-line-dim></path>
          <g clip-path="url(#rev-clip)">
            <path class="plot__area" data-area></path>
            <path class="plot__line" data-line></path>
          </g>
          <g class="handle" data-handle="a"><line class="handle__bar" x1="0" x2="0"></line><rect class="handle__grip" x="-3.5" width="7" height="16" rx="3.5"></rect></g>
          <g class="handle" data-handle="b"><line class="handle__bar" x1="0" x2="0"></line><rect class="handle__grip" x="-3.5" width="7" height="16" rx="3.5"></rect></g>
          <g class="cursor" data-cursor>
            <line class="cursor__line" x1="0" x2="0"></line>
            <circle class="cursor__halo" r="9"></circle>
            <circle class="cursor__dot" r="4"></circle>
          </g>
        </svg>
        <div class="tip" data-tip><span data-tip-day></span><span class="tip__val" data-tip-val></span></div>
      </div>
      <div class="axis" data-axis aria-hidden="true"></div>
      <p class="sr" aria-live="polite" data-live></p>
    </article>

    <svg class="fake" data-fake viewBox="0 0 20 24" aria-hidden="true"><path d="M3 2.2v17.4l4.6-4.4 3 6.6 2.9-1.3-3-6.5h6.3Z"></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 “Revenue range 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 white background a card 480 pixels wide, with 20 pixel corners, a thin grey border and a wide soft shadow. Top left Revenue with a small line drawn bar icon, on the right the 7D, 30D, 90D picker on a light grey track with a white pill under the choice. Below, the big total in Mona Sans with tabular digits, the $ and the thousands commas in light grey, and next to it a violet badge with an arrow and the change against the period before; a grey line gives the dates and vs. previous 30 days. Below that the violet line of daily revenue, with a fading area, two light dashed rules and the dates on the axis. Over the chart a dashed cursor with a white dot ringed in violet snaps from one day to the next on a short spring, a black label gives the day and the amount, and the total rolls to that amount, digit by digit from the right, with the badge comparing it with the day before. Dragging picks a range: outside it the line turns grey, inside it stays violet on a faintly tinted band, with two white handles at its sides to move it; the total rolls to the sum, the badge to the change from the first to the last day and Clear appears. Changing the period the pill slides with a small bounce and the line bends into the new one, the dates swap and any extra digits come in widening. When nobody touches it, a pretend pointer uses it: it points, picks a range, narrows it, clears it and changes the period.

How it works

The rolling digits

The total is a row of slots, one per character, lined up from the right. Every digit is a column from 0 to 9, ten lines tall, in a slot that shows one line: to change digit GSAP moves the column by -10% per unit, with back.out(1.15) and a delay of ROLL_STAGGER from the right. Extra slots come in widening from zero, the ones no longer needed shrink away on the left; the digits are tabular, so nothing jiggles.

A line that bends into another

Every period, 7, 30 or 90 days, is read with a Catmull-Rom curve at 180 points, normalised between its own lowest and highest. Changing period GSAP takes every point from one curve to the other in MORPH seconds and redraws the path on every frame: the line bends instead of vanishing.

The range

The line is drawn twice, grey underneath and violet on top inside a clipPath. With no range the clip rectangle covers everything; dragging narrows it between the two handles, together with the tinted band, with short power3.out tweens. Near a handle the drag takes that handle instead of starting a new range; a tap without dragging clears it.

The pointer that shows it

A GSAP timeline moves a pointer drawn in SVG and calls the same functions as the real pointer: it points, presses, drags, releases, presses Clear and the periods. The positions are functions read at the start of every stretch, so they follow the card even when it changes size. At the first real gesture the timeline stops, and starts again after IDLE quiet seconds.

Accessible

The periods are tabs with aria-selected and the arrow keys; the chart takes focus: the arrows move the cursor, Shift and the arrows widen the range, Escape clears it, and an aria-live line reads out the total. With reduced motion the digits change with a fade, the line jumps to the new period without bending and there is no pretend pointer.

Values to change

NameFileDefaultWhat it changes
METRICscript.jsRevenueThe name of the figure, top left.
CURRENCYscript.js$The sign before the amounts.
STARTscript.js1The period at the start: 0 is 7 days, 1 is 30, 2 is 90.
MORPHscript.js0.8The seconds the line takes to bend into the new period.
ROLLscript.js0.6The seconds a digit takes to roll to its new value.
ROLL_STAGGERscript.js0.025The seconds between one digit and the next, from the right.
CURSORscript.js0.22The seconds the cursor takes to reach the day under the pointer.
IDLEscript.js3.5The quiet seconds before the pointer that shows it comes back.

Try them in the Playground

When to use it

For the main figure of a dashboard: an online shop's revenue, an app's subscriptions, a hotel's bookings, an event's ticket sales, anywhere a number needs to be read over time and two days or a range compared.

On phones

The card takes the screen's width minus 16 pixels a side, the total and the chart are measured on the height too, so everything fits in the box. With a finger: a tap shows the day, dragging sideways picks a range, dragging up or down scrolls the page as usual.

With reduced motion

The digits change with a fade instead of rolling, the line jumps to the new period without bending, the pill and the range go to their places without sliding and there is no pretend pointer: only the periods change on their own.

Pitfalls

  • The digits have to be tabular (font-variant-numeric: tabular-nums), otherwise the column of a digit as narrow as 1 and that of an 8 do not fit the same slot and the total jiggles as it rolls.
  • Line the slots up from the right: between $9,870.20 and $48,210.40 the length changes, and comparing from the left the dollar sign would land in a digit's place. From the right the cents, the point and the thousands stay put and only the leading slots change.
  • The clip tween has to be stopped when the card changes size: started with the old width, it would keep taking the rectangle towards a number that no longer holds and the line would stay cut.
  • The pretend pointer's positions are functions read when every stretch starts, not numbers worked out when it is built: the preview box changes height while you look at it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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