How do you animate charts and numbers without a charting library?

Small data visualizations such as counters, progress rings, bar and line charts can be drawn with HTML, CSS and SVG alone. Bars grow with a CSS transform, rings and lines animate SVG stroke-dashoffset, and counters are incremented in JavaScript when they enter the viewport, detected with IntersectionObserver.

How to choose, performance and accessibility
  • Use Animated Counter or Stat Cards for key figures on a landing page, Progress Ring or Gauge Meter for completion, and Line Chart Draw or Sparkline for trends in a dashboard.
  • Keep the final value in the HTML so it reads correctly without animation and for screen readers, label axes and units, and move to a charting library only when you need zooming, dense tooltips or live data.
  • Animated Counter is free with its full code; the rest come with Premium.
8,547 Active users

Animated Counter

Counter that animates toward the target value.

JS Numbers
Effect page →
View source code
HTML
<div class="fx-0223-root">
  <div class="ctup-box">
    <span class="ctup-value" data-target="8547">8,547</span>
    <span class="ctup-label">Active users</span>
  </div>
</div>
CSS
.fx-0223-root,
.fx-0223-root *,
.fx-0223-root *::before,
.fx-0223-root *::after {
  box-sizing: border-box
}

.fx-0223-root {
  --ctup-bg: rgb(26, 26, 36);
  --ctup-from: #6366f1;
  --ctup-to: #d946ef;
  --ctup-muted: rgba(255, 255, 255, .6);
  --ctup-size: 3rem;
  --ctup-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--ctup-height);
  overflow: hidden;
  position: relative;
  background: var(--ctup-bg);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.ctup-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ctup-value {
  font-size: var(--ctup-size);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--ctup-from), var(--ctup-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ctup-label {
  font-size: 0.875rem;
  color: var(--ctup-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Final value for screen readers (the moving number is hidden from them) */
.ctup-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
JavaScript
(function () {
  'use strict';
  // Animated Counter: the number counts from 0 up to data-target when half visible, only once.
  var calm = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : { matches: false };

  // Page language (closest lang attribute): 8 547 in French, 8,547 in English
  function pageLang(el) {
    var host = el.closest('[lang]');
    return (host && host.lang) || navigator.language || 'fr';
  }

  function init(el) {
    if (el.hasAttribute('data-ctup-ready')) return;
    el.setAttribute('data-ctup-ready', '');
    var raw = (el.getAttribute('data-target') || '0').trim();
    var target = parseFloat(raw) || 0;
    var decimals = raw.indexOf('.') > -1 ? raw.split('.')[1].length : 0;
    var duration = parseFloat(el.getAttribute('data-duration')) || 2000;
    var fmt = new Intl.NumberFormat(pageLang(el), {
      minimumFractionDigits: decimals,
      maximumFractionDigits: decimals
    });

    // Screen readers read the final value, never the counting steps
    var sr = document.createElement('span');
    sr.className = 'ctup-sr';
    sr.textContent = fmt.format(target);
    el.parentNode.insertBefore(sr, el.nextSibling);
    el.setAttribute('aria-hidden', 'true');

    if (calm.matches || !('IntersectionObserver' in window)) {
      el.textContent = fmt.format(target);
      return;
    }
    el.textContent = fmt.format(0);

    function count() {
      if (calm.matches) {
        el.textContent = fmt.format(target);
        return;
      }
      var start = performance.now();
      requestAnimationFrame(function step(t) {
        var p = Math.min((t - start) / duration, 1);
        var v = target * (1 - Math.pow(1 - p, 3)); // cubic ease-out
        el.textContent = fmt.format(decimals ? v : Math.floor(v));
        if (p < 1) requestAnimationFrame(step);
        else el.textContent = fmt.format(target);
      });
    }

    var obs = new IntersectionObserver(function (entries) {
      if (!entries[0].isIntersecting) return;
      obs.disconnect();
      count();
    }, { threshold: 0.5 });
    obs.observe(el);
  }

  document.querySelectorAll('.fx-0223-root .ctup-value[data-target]').forEach(init);
})();

Progress Ring

Animated circular progress ring.

SVG CSS JS

Bar Chart Animated

Bar chart with animated growth effect.

CSS JS Stagger

Line Chart Draw

Line that draws itself progressively.

SVG Path

Pie Chart Reveal

Pie chart with segments that appear sequentially.

SVG Segments

Gauge Meter

Half-circle gauge whose needle swings to the value, green to red.

SVG CSS JS

Stat Cards

Stat cards with animated counters.

JS Cards

Comparison Bars

Horizontal bars to compare values.

CSS JS Progress

Donut Chart

Donut chart whose slices appear one after another.

SVG Circular

Sparkline

Key figure with a small trend line that draws itself.

SVG Trend

Counter Animation CSS

Pure CSS animated counter using @property.

CSS @property

Circular Progress SVG

Progress circle with animation.

SVG CSS JS

Animated Bar Chart

Bar chart with animated growth.

CSS Animation

Donut Chart CSS

Conic-gradient donut chart that appears with a turn.

CSS Gradient

Gauge Meter CSS

Semi-circular gauge in pure CSS.

CSS Border

Step Progress Indicator

Step indicator with animation.

CSS Steps

Star Rating Animated

Real 1–5 star rating: click, touch or keyboard, sent with the form.

JS Interactive

Line Chart Drawing

SVG line chart with drawing animation.

SVG Path

Counter Odometer

Digits that roll like an odometer, each in its own cell.

CSS Transform Counter

Animated Donut Chart

Donut chart with a legend: segments glide to new values (conic-gradient and @property).

CSS @property conic-gradient

Live Sparkline

Sparkline that draws itself on view and glides with each new value.

SVG JS Path

Needle Gauge

Half-dial needle gauge with five coloured zones, value set by data-value.

CSS JS Transform Gauge

Bar Chart Race

Ranked horizontal bars: when a value changes, they grow and rows glide to their new rank.

CSS Transition Race

Morphing Pie Chart

Pie chart whose slices glide from one data set to the next; percentage legend.

CSS @property Morph

Animated Stat Counter

Counters that climb to their value and ease out, with thousands separator, prefix and suffix.

JS rAF Easing

Progress Steps

Current step in indigo, past steps in green, a line that fills in.

CSS JS Steps

Data Table Row Animation

Real HTML table: changed rows slide in and light up one by one; hover highlight.

CSS JS Table

Heatmap Cell Animation

Heat calendar: cells coloured by value, in a wave.

CSS Grid Heatmap

Year in Pixels

The “one day = one tile” calendar, premium edition: embossed tiles lit from above that press in on click and fill with a warm colour spreading from the point of contact (four intensities, from ember to gold). Consecutive days form a streak: a continuous luminous trace links them in order and a golden flow runs along it up to today, while the “streak” and “record” counters roll. The default view frames the latest weeks around today; the whole year is one click away. Keyboard, tooltip, upcoming days cannot be checked; with prefers-reduced-motion everything renders directly, with no flow or wave.

💡 Perfect for: habit or sports dashboards, “my year in pixels” reviews, resolution tracking, app statistics (streaks, records).

CSS + SVG Dataviz Streak Accessible Premium

Frequently Asked Questions

How to animate a bar chart in CSS? +

Set the final height with a CSS variable (--value). Start from height:0 and animate to height:var(--value) with @keyframes. Add an incremental transition-delay so bars appear in sequence.

How to create an animated pie chart in CSS? +

Use a conic-gradient with the percentage value. Animate the value with @property (CSS Houdini) for a smooth transition. Alternative: SVG circle with animated stroke-dasharray.

How to create an animated counter in JavaScript? +

Use requestAnimationFrame with linear or ease-out interpolation. Calculate the current value between 0 and the target, update textContent. Recommended duration: 1-2 seconds.

Which library for web data visualization? +

For simple charts, vanilla CSS and JavaScript are sufficient (like our examples). For complex dashboards, Chart.js (lightweight) or D3.js (powerful). Avoid heavy libraries for simple charts.

How to make a chart accessible? +

Add an aria-label with the data description. Use colors with sufficient contrast. Provide a text alternative (HTML table) via a 'View data' link. Avoid conveying information through color alone.