Skip to content
animorio
IT
Back to the library

Budget donut chart

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

The October budget card of a made-up personal finance app, white on warm paper: a donut in five tones of deep teal draws itself slice after slice, each going a degree past its end and back. Pointing at a slice, or at its legend row, a thin ink thread with a caret runs round the donut on a spring to embrace it, the slice lifts outward over its shadow, the others darken a touch and the number in the middle rolls to its category.

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>
<!--
  "Budget donut 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 budget donut chart with the thread that runs round to the slice</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 October budget card of a personal finance app: a donut of five tones of one colour drawn slice after slice,
         a thin ink thread with a caret outside the ring that runs round to embrace the slice you point at, the slice
         lifting out over its shadow, the number in the middle rolling to it and the legend answering at once -->
    <section class="card" data-card aria-label="Orra, October budget">
      <header class="card__head">
        <div class="card__brand">
          <svg class="card__mark" viewBox="0 0 24 24" aria-hidden="true">
            <circle cx="12" cy="12" r="8.2"></circle>
            <path d="M12 3.8a8.2 8.2 0 0 1 8.2 8.2"></path>
          </svg>
          <div>
            <p class="card__name">October budget</p>
            <p class="card__sub">Orra &middot; Joint account</p>
          </div>
        </div>
        <span class="card__chip">Oct 1 &ndash; 31</span>
      </header>

      <div class="card__body">
        <div class="donut" data-donut>
          <svg class="donut__svg" viewBox="-6 -6 212 212" aria-hidden="true">
            <defs>
              <filter id="shade" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="3.2"></feGaussianBlur></filter>
            </defs>
            <g data-ticks></g>
            <circle class="donut__bed" cx="100" cy="100" r="70"></circle>
            <g data-shadows></g>
            <g data-slices></g>
            <circle class="donut__gloss" cx="100" cy="100" r="79.4"></circle>
            <circle class="donut__inner" cx="100" cy="100" r="60.4"></circle>
            <g class="thread" data-thread>
              <path class="thread__arc" data-arc></path>
              <path class="thread__end" data-end-a></path>
              <path class="thread__end" data-end-b></path>
              <g data-caret><path class="thread__caret" d="M100 13.2 96.6 7.4h6.8Z"></path></g>
            </g>
          </svg>
          <div class="donut__center">
            <p class="donut__label" data-label>Spent</p>
            <p class="donut__value"><span class="donut__cur">$</span><span class="roll" data-roll></span></p>
            <p class="donut__note" data-note>of $4,200</p>
          </div>
        </div>

        <ul class="legend" data-legend aria-label="Categories"></ul>
      </div>

      <footer class="card__foot">
        <svg class="card__trend" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 5.5 8 10.5l5-5"></path></svg>
        <p class="card__insight"><b>$1,016</b> under budget, moved to Savings</p>
      </footer>
    </section>
    <p class="sr" aria-live="polite" data-live></p>

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

23 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 “Budget donut 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 paper background a white card rises with a soft layered shadow: at the top the mark of Orra, a made-up personal finance app (a grey ring with one quarter in deep teal), «October budget», «Orra · Joint account» and on the right the «Oct 1 – 31» pill. Below, on the left, around a very light grey bed the 72 thin ticks of a dial light up one after the other; then the five slices draw themselves clockwise, each going a degree and a half past its end and back: Housing in the darkest teal, then Groceries, Shopping, Transport and Dining out lighter and lighter, split by a thread of empty space, with a white glint on the outer edge. In the middle «Spent» and the total, $3,184, rolling digit by digit from the right, with «of $4,200» below. On the right the legend: each category with its amount and a small bar in its tone that stretches out on a spring. Once the ring is closed it breathes once. Pointing at a slice, or at its row, a thin ink thread with a tick at each end and a caret in the middle appears outside the donut and embraces it; moving to another slice the thread runs round the short way, the leading end gets there first and the trailing one catches up a touch past and back, the dial ticks under the thread darken and the caret, once there, dips in by one unit and settles. The slice lifts outward a few units over its blurred shadow, the others darken a touch, the legend row lights up on a pale ground, widens on the wdth axis, its bar thickens and the other rows fade; in the middle the category name, its amount rolling (the thousands digit and the comma squeeze away when they are not needed) and its share, «45.5% of spent». Pressing makes the slice lift a little more and spring back, and the number gives a small nod. A drawn pointer does it all by itself and starts again; it also really works, with the mouse, a finger and the keyboard.

How it works

Slices as computed arcs

Each slice is an SVG arc path on radius 70 with a 20 wide stroke, from one angle to another (degrees, clockwise from twelve o’clock), with 2.2 degrees of empty space between neighbours. On entry GSAP runs the end of the arc OVERSHOOT degrees past its place and back, and the path is rebuilt at every step: so the overshoot is always a degree and a half, even on the large slice, and never steps on its neighbour.

The thread running round

The thread is an arc on radius 86 with a radial tick at each end and a caret rotated to its middle. Its two ends are two tweened numbers: the one in the direction of travel arrives in 0.7 of the time with back.out(1.15), the one behind leaves a moment later and lands with back.out(1.7), a touch past and back. Before it sets off the angles are brought back between 0 and 360 and the target is moved by 360 degrees when that makes the way shorter.

Ticks that darken

At each update of the thread the script checks which of the 72 ticks fall between its two ends (with a modulo, since the thread can cross twelve o’clock): those darken in 0.18 s, the rest go light again in half a second, so the thread leaves a small trail on the dial.

The slice lifting over its shadow

The slice’s group moves along the direction of its middle by LIFT units with back.out(2.2). Underneath, where it was and three units lower, a copy of the slice blurred with feGaussianBlur fades in: the slice seems to rise over its shadow. The other slices move towards a darker tone mixed into their colour by DIM.

Rolling digits

The number is four windows one line tall, each holding a strip from 0 to 9 that moves by yPercent -10 per digit, from the right digit to the left one with 45 ms of delay. For amounts under a thousand the thousands window and the comma squeeze to zero width, measured in em at start so they follow the size of the donut.

Legend, finger and keyboard

Each row is an element with tabindex: hover, focus and the arrow keys call the same function as the slices. With a finger a tap lights the slice and keeps it until you tap outside; an 80 ms delay between a leave and an enter stops the thread from closing when moving from one slice to the next. The autopilot stops at the first real gesture and comes back after eight seconds.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0f766eThe colour of the donut: the five slices are its tones, from darkest to lightest.
DRAW_TIMEscript.js0.55Seconds each slice takes to draw itself on entry.
OVERSHOOTscript.js1.8How many degrees each slice goes past its end before settling back, on entry.
LIFTscript.js4.5How far the pointed slice lifts outward, in drawing units (the donut is 200 wide).
DIMscript.js0.24How much the other slices darken: 0 not at all, 1 almost black.
THREAD_TIMEscript.js0.6Seconds the thread takes to run round the donut to the new slice.
ROLL_TIMEscript.js0.7Seconds the digits in the middle take to roll.
PAUSEscript.js1.5Seconds the autopilot stays on each slice.

Try them in the Playground

When to use it

For the dashboard or summary page of a finance app, a bank, an expense tracker or a subscription service: anywhere a donut splits a total into a few parts and they need to be read one at a time, with the legend beside it answering together.

On phones

The same animation with adapted sizes: the donut stays beside the legend and is sized on the smaller of width and height, the words in the middle follow its size through container units. A tap on a slice or a row lights it and keeps it; a tap outside goes back to the total.

With reduced motion

The card fades in with the donut already whole; on hover only colours, shadows and words change with a fade, the thread appears in place without running, no slice lifting and no rolling digits.

Pitfalls

  • The draw overshoot is not a back.out on the length: on the large slice (164 degrees) a back.out would overshoot by more than ten degrees and step on its neighbour. Here the end goes a fixed number of degrees past and back.
  • The thread going from Dining out to Housing has to cross twelve o’clock: without bringing the angles back between 0 and 360 and picking the short way it would run all the way round backwards.
  • Moving from one slice to the next, the leave arrives before the enter: without a small delay the thread would start to close and open again, with a jump.
  • With a finger pointerleave fires as soon as the finger lifts: it has to be ignored, or the tapped slice switches off at once.
  • The widths of the digit windows are tweened in em, not pixels: the donut changes size with its container and in pixels they would stay at their starting size.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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