Skip to content
animorio
IT
Back to the library

Charts that draw themselves

Scroll, SVGGSAPMediumCompressed weight: Demo 4.4 KBGSAP + ScrollTrigger 45 KBFreeDownload the zip

Scroll inside the preview

Bars, a donut and a dot grid draw along with scrolling, with numbers counting; scrolling back takes them apart.

Rebuilt from scratch studying arttechreport.com by MoreSleep: the idea is theirs; code, copy and images are ours. Read how it’s made

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>
<!--
  "Charts that draw themselves" 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="it">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Grafici che si disegnano</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/standard.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main>
    <section class="apertura">
      <p class="sopra">Un rapporto che si legge scorrendo</p>
      <p class="grande">Barre, ciambella e punti si disegnano insieme allo scorrimento: se torni su, tornano indietro.</p>
    </section>

    <section class="capitolo">
      <div class="testo">
        <h2>Che cosa notano i visitatori</h2>
        <p>Le barre crescono dal basso e i numeri contano con loro: il grafico dice il dato mentre lo mostra.</p>
      </div>
      <figure class="carta" data-grafico="barre">
        <svg viewBox="0 0 300 230" aria-labelledby="t-barre">
          <title id="t-barre">Il movimento 72%, i colori 64%, i testi 41%</title>
          <rect class="barra b1" x="20" y="30" width="72" height="170" rx="10" />
          <rect class="barra b2" x="114" y="30" width="72" height="170" rx="10" />
          <rect class="barra b3" x="208" y="30" width="72" height="170" rx="10" />
          <line class="base" x1="10" y1="200" x2="290" y2="200" />
        </svg>
        <div class="valori">
          <span><b data-valore="72">0</b>% il movimento</span>
          <span><b data-valore="64">0</b>% i colori</span>
          <span><b data-valore="41">0</b>% i testi</span>
        </div>
        <figcaption>Numeri di esempio</figcaption>
      </figure>
    </section>

    <section class="capitolo capitolo--rovescio">
      <div class="testo">
        <h2>Chi scorre fino in fondo</h2>
        <p>La ciambella si chiude seguendo lo scorrimento: è un solo cerchio con il tratto tagliato.</p>
      </div>
      <figure class="carta" data-grafico="ciambella">
        <svg viewBox="0 0 300 230" aria-labelledby="t-ciambella">
          <title id="t-ciambella">68 per cento</title>
          <circle class="anello-fondo" cx="150" cy="115" r="80" />
          <circle class="anello" cx="150" cy="115" r="80" data-fino="0.68" />
          <text class="centro" x="150" y="130"><tspan data-valore="68">0</tspan>%</text>
        </svg>
        <figcaption>Numeri di esempio</figcaption>
      </figure>
    </section>

    <section class="capitolo">
      <div class="testo">
        <h2>Su cento visite, quante tornano</h2>
        <p>Cento punti, e si accendono uno dopo l’altro fino al numero giusto.</p>
      </div>
      <figure class="carta" data-grafico="punti">
        <svg viewBox="0 0 280 280" aria-labelledby="t-punti">
          <title id="t-punti">37 su cento</title>
          <circle class="punto" cx="14" cy="14" r="9" />
          <circle class="punto" cx="41" cy="14" r="9" />
          <circle class="punto" cx="68" cy="14" r="9" />
          <circle class="punto" cx="95" cy="14" r="9" />
          <circle class="punto" cx="122" cy="14" r="9" />
          <circle class="punto" cx="149" cy="14" r="9" />
          <circle class="punto" cx="176" cy="14" r="9" />
          <circle class="punto" cx="203" cy="14" r="9" />
          <circle class="punto" cx="230" cy="14" r="9" />
          <circle class="punto" cx="257" cy="14" r="9" />
          <circle class="punto" cx="14" cy="41" r="9" />
          <circle class="punto" cx="41" cy="41" r="9" />
          <circle class="punto" cx="68" cy="41" r="9" />
          <circle class="punto" cx="95" cy="41" r="9" />
          <circle class="punto" cx="122" cy="41" r="9" />
          <circle class="punto" cx="149" cy="41" r="9" />
          <circle class="punto" cx="176" cy="41" r="9" />
          <circle class="punto" cx="203" cy="41" r="9" />
          <circle class="punto" cx="230" cy="41" r="9" />
          <circle class="punto" cx="257" cy="41" r="9" />
          <circle class="punto" cx="14" cy="68" r="9" />
          <circle class="punto" cx="41" cy="68" r="9" />
          <circle class="punto" cx="68" cy="68" r="9" />
          <circle class="punto" cx="95" cy="68" r="9" />
          <circle class="punto" cx="122" cy="68" r="9" />
          <circle class="punto" cx="149" cy="68" r="9" />
          <circle class="punto" cx="176" cy="68" r="9" />
          <circle class="punto" cx="203" cy="68" r="9" />
          <circle class="punto" cx="230" cy="68" r="9" />
          <circle class="punto" cx="257" cy="68" r="9" />
          <circle class="punto" cx="14" cy="95" r="9" />
          <circle class="punto" cx="41" cy="95" r="9" />
          <circle class="punto" cx="68" cy="95" r="9" />
          <circle class="punto" cx="95" cy="95" r="9" />
          <circle class="punto" cx="122" cy="95" r="9" />
          <circle class="punto" cx="149" cy="95" r="9" />
          <circle class="punto" cx="176" cy="95" r="9" />
          <circle class="punto" cx="203" cy="95" r="9" />
          <circle class="punto" cx="230" cy="95" r="9" />
          <circle class="punto" cx="257" cy="95" r="9" />
          <circle class="punto" cx="14" cy="122" r="9" />
          <circle class="punto" cx="41" cy="122" r="9" />
          <circle class="punto" cx="68" cy="122" r="9" />
          <circle class="punto" cx="95" cy="122" r="9" />
          <circle class="punto" cx="122" cy="122" r="9" />
          <circle class="punto" cx="149" cy="122" r="9" />
          <circle class="punto" cx="176" cy="122" r="9" />
          <circle class="punto" cx="203" cy="122" r="9" />
          <circle class="punto" cx="230" cy="122" r="9" />
          <circle class="punto" cx="257" cy="122" r="9" />
          <circle class="punto" cx="14" cy="149" r="9" />
          <circle class="punto" cx="41" cy="149" r="9" />
          <circle class="punto" cx="68" cy="149" r="9" />
          <circle class="punto" cx="95" cy="149" r="9" />
          <circle class="punto" cx="122" cy="149" r="9" />
          <circle class="punto" cx="149" cy="149" r="9" />
          <circle class="punto" cx="176" cy="149" r="9" />
          <circle class="punto" cx="203" cy="149" r="9" />
          <circle class="punto" cx="230" cy="149" r="9" />
          <circle class="punto" cx="257" cy="149" r="9" />
          <circle class="punto" cx="14" cy="176" r="9" />
          <circle class="punto" cx="41" cy="176" r="9" />
          <circle class="punto" cx="68" cy="176" r="9" />
          <circle class="punto" cx="95" cy="176" r="9" />
          <circle class="punto" cx="122" cy="176" r="9" />
          <circle class="punto" cx="149" cy="176" r="9" />
          <circle class="punto" cx="176" cy="176" r="9" />
          <circle class="punto" cx="203" cy="176" r="9" />
          <circle class="punto" cx="230" cy="176" r="9" />
          <circle class="punto" cx="257" cy="176" r="9" />
          <circle class="punto" cx="14" cy="203" r="9" />
          <circle class="punto" cx="41" cy="203" r="9" />
          <circle class="punto" cx="68" cy="203" r="9" />
          <circle class="punto" cx="95" cy="203" r="9" />
          <circle class="punto" cx="122" cy="203" r="9" />
          <circle class="punto" cx="149" cy="203" r="9" />
          <circle class="punto" cx="176" cy="203" r="9" />
          <circle class="punto" cx="203" cy="203" r="9" />
          <circle class="punto" cx="230" cy="203" r="9" />
          <circle class="punto" cx="257" cy="203" r="9" />
          <circle class="punto" cx="14" cy="230" r="9" />
          <circle class="punto" cx="41" cy="230" r="9" />
          <circle class="punto" cx="68" cy="230" r="9" />
          <circle class="punto" cx="95" cy="230" r="9" />
          <circle class="punto" cx="122" cy="230" r="9" />
          <circle class="punto" cx="149" cy="230" r="9" />
          <circle class="punto" cx="176" cy="230" r="9" />
          <circle class="punto" cx="203" cy="230" r="9" />
          <circle class="punto" cx="230" cy="230" r="9" />
          <circle class="punto" cx="257" cy="230" r="9" />
          <circle class="punto" cx="14" cy="257" r="9" />
          <circle class="punto" cx="41" cy="257" r="9" />
          <circle class="punto" cx="68" cy="257" r="9" />
          <circle class="punto" cx="95" cy="257" r="9" />
          <circle class="punto" cx="122" cy="257" r="9" />
          <circle class="punto" cx="149" cy="257" r="9" />
          <circle class="punto" cx="176" cy="257" r="9" />
          <circle class="punto" cx="203" cy="257" r="9" />
          <circle class="punto" cx="230" cy="257" r="9" />
          <circle class="punto" cx="257" cy="257" r="9" />
        </svg>
        <p class="grande-numero"><b data-valore="37" data-punti>0</b> su cento</p>
        <figcaption>Numeri di esempio</figcaption>
      </figure>
    </section>

    <section class="apertura apertura--fine">
      <p class="grande">Fine del rapporto. Torna su: i grafici si smontano all’indietro.</p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.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.

38 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 “Charts that draw themselves” 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

A report page with three charts. As you scroll, the bars grow from the bottom one after another, the donut closes its arc up to the value and a hundred dots light up one at a time up to the right number; each number counts along with its drawing. The chart is not an animation that starts and ends: it is tied to scrolling, so it can stop halfway, and scrolling back takes it apart.

How it works

Hand-made SVG charts

No chart library: three rectangles, two circles and a hundred small circles. Values live in data-valore attributes, so the chart can be read in the code too.

Bars from the bottom

Each bar goes from scaleY 0 to its value divided by a hundred. On SVG the origin must be given to GSAP (transformOrigin 50% 100%): a CSS one adds to it and the bar ends up below the baseline.

The donut

A circle with a wide stroke: stroke-dasharray equal to the circumference, and stroke-dashoffset going down to the part to leave empty. Rotated by -90 degrees, it starts at noon.

Numbers and dots tied to the timeline

Numbers count through an object { n } in the same timeline as the drawing. Dots light up with a class: going backwards the class must be removed by hand in onUpdate, because scrub does not remove it.

Values to change

NameFileDefaultWhat it changes
INIZIO / FINEscript.jstop 78% / center 48%When the chart starts and finishes drawing.
PARALLASSEscript.js6How far the card slides while crossing the screen.
data-valoreindex.html72, 64, 41, 68, 37The values: sample numbers, put yours.

Try them in the Playground

When to use it

For reports, annual results, impact pages, project data. Keep the figure written next to the chart: screen reader users find it in the SVG title.

On phones

Text above, chart below, full width. The drawing stays tied to scrolling.

With reduced motion

The charts are already drawn and the numbers already at their value.

Pitfalls

  • On SVG do not set transform-origin in CSS if you animate with GSAP: give it to GSAP. The two add up and the shape moves.
  • Classes added with call() in a scrubbed timeline are not removed when going backwards: manage them in onUpdate from the progress.
  • A scroll-bound chart must finish before the card leaves the screen, or nobody sees it complete: here it finishes when the card’s centre is mid-screen.

Libraries

GSAP 3.15.0, ScrollTrigger (GSAP) 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 4.4 KB; the libraries: GSAP + ScrollTrigger 45 KB.

Testing

Tested on 27 September 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