Data✨ Premium

Pie Chart Reveal

SVG pie chart with a legend: when it comes into view, each slice starts at the top of the disc and glides to its place while widening, one after the other.

SVGSegments

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →

3 usage examples

A small town's participatory budget split, revealed on reaching “Where the money goes” — Pie Chart Reveal example 1

① A small town's participatory budget split, revealed on reaching “Where the money goes”

WhenA town's participatory budget results page: a banner announces the €120,000 voted and the number of voters, then the “Where the money goes” section shows the pie and its legend (cycle lanes, playground, shared gardens, benches and shade). In the capture the page scrolls down to the section by itself.
WhyResidents want to see at a glance which project won. Slices settling one by one give time to read the legend in order.
SettingsAmounts in euros in data-value (45,600, 28,800, 26,400, 19,200) turned into percentages by the script, --pcs-size: 168px, colours #2563eb, #16a34a, #f59e0b, #db2777, dark text on a light background.
Share of carbohydrates, protein, fat and fibre in a recipe's “Nutrition” tab — Pie Chart Reveal example 2

② Share of carbohydrates, protein, fat and fibre in a recipe's “Nutrition” tab

WhenA tabbouleh recipe on a cooking blog, with three tabs. “Ingredients” is open by default; clicking “Nutrition” shows the calories and a small 116 px pie with its legend, grams turned into percentages.
WhyThe information is secondary: it stays tucked away in a tab and only reveals itself on request, as the tab opens.
SettingsValues in grams (38, 9, 12, 6), --pcs-size: 116px, --pcs-min-height: 0, amber, green, raspberry and teal colours; the tab is a real role="tab" and the panel a hidden removed on click.
Time spent in each role on the end-of-round screen of a co-op game — Pie Chart Reveal example 3

③ Time spent in each role on the end-of-round screen of a co-op game

WhenAn online board game: at the end of the round a “Victory” banner shows for a moment, then the results screen lists the four players and their role with a colour swatch. On the right, the pie of play time reveals itself.
WhyThe round summary becomes a small game moment: everyone watches for their slice to arrive. The player list acts as the legend; the effect's own legend is hidden on screen but still read out.
Settingsdata-legend="hidden", minutes per role (28, 22, 31, 19), --pcs-size: 156px, colours #38bdf8, #4ade80, #fb923c, #c084fc repeated on the player swatches.

How it works

The .fx-0227-root root holds an empty .pcs-pie slot and a ul.pcs-legend list. Each li in the list is a slice: its text is the label, its data-value attribute the amount. The script adds up the total and gives every slice a proportional angle, so the disc is always 100% full, whatever the units (euros, grams, minutes).

The drawing is a 120-unit SVG, turned a quarter turn so it starts at the top: one circle per slice, radius 30 and stroke width 60, which makes a solid disc. Each stroke's length (stroke-dasharray) is its share of the circumference and its offset (stroke-dashoffset) is where it starts. In the legend the script adds a colour swatch and the percentage, written in the page language's format (“38%” in English, “38 %” in French).

At first every slice has zero length. As soon as 35% of the disc is visible, the pcs-on class gives each circle its final length and offset, with a 1 s transition (ease-out) delayed by 0.2 s and 0.2 s more per slice. This only happens once. The disc measures --pcs-size (180 px) without ever exceeding the container width; when space runs out, the legend moves below the disc.

Accessibility

  • The legend is the chart's text: a real list named by its aria-label, each item read as “Yes 30%”. The SVG is hidden from screen readers so the information is not repeated.
  • Hidden legend: with data-legend="hidden", the list disappears from the screen but is still read out; give the colours another visual key then (such as the swatches of a player list).
  • Reduced motion: under prefers-reduced-motion: reduce, the transition is removed and the full pie shows at once.
  • No interaction: nothing takes focus, nothing reacts to hover or touch. Six colours follow each other then repeat: beyond six slices, tell them apart through the legend.

Browser compatibility

SVG created by the script, CSS transitions on stroke-dasharray and stroke-dashoffset, aspect-ratio, IntersectionObserver and Intl.NumberFormat. Measured on 8 Nov 2026 in Chromium 151, Firefox 153 and WebKit 26.5 (Playwright): correct slices (30/25/20/25 → 100%), two independent copies, reduced motion, 390 px wide, no errors.

Chrome 88+✓ Full (measured in Chromium 151)
Firefox 89+✓ Full (measured in Firefox 153)
Safari 15+✓ Measured in WebKit 26.5, not in real Safari
Edge 88+✓ Full (Chromium engine)
Safari iOS 15+✓ Not checked on a device
Chrome Android 88+✓ Full (Chromium engine)

Without IntersectionObserver, the pie reveals itself on load. Without JavaScript only the list of labels shows, with no disc and no percentages.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0227-root">
  <div class="pcs-pie"></div>
  <ul class="pcs-legend" aria-label="Survey answers">
    <li data-value="30">Yes</li>
    <li data-value="25">Rather yes</li>
    <li data-value="20">Rather no</li>
    <li data-value="25">No</li>
  </ul>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Slices (HTML — one li data-value="…" per slice in .pcs-legend) Yes 30, Rather yes 25, Rather no 20, No 25 The li text is the label; values can be in any unit, the script turns them into shares of the total.
List name (HTML — aria-label of .pcs-legend) “Survey answers” Announced by screen readers before the slices: describe what the chart shows.
Visible legend (HTML — data-legend="hidden" on the root) Legend shown Hides the legend on screen while keeping it readable by screen readers.
Colours (CSS — --pcs-c1 to --pcs-c6) #6366f1, #8b5cf6, #d946ef, #ec4899, #f43f5e, #06b6d4 One colour per slice, in list order; the legend swatches follow.
Size (CSS — --pcs-size, --pcs-min-height) 180 px, 300 px Maximum disc diameter (never wider than the container) and minimum root height.
Background and text (CSS — --pcs-bg, --pcs-text, --pcs-muted) #0a0a0f, 80% white, 50% white Root background, colour of the labels and of the percentages.

FAQ

No. The script adds up the values and works out each share: €45,600 out of €120,000 gives 38%. The disc is always complete and the legend percentages are computed for you, to one decimal place.
The root is a flex box that wraps by itself when space runs out. To force the legend below, add flex-direction: column on .fx-0227-root in your CSS.
No, the effect is a display: there is no hover or click on the slices. The figures are in the legend, which always stays readable.