# Simple pie charts with fallback, today

DevFeed: [Simple pie charts with fallback, today](<https://devfeed.tech/articles/simple-pie-charts-with-fallback-today-52125.md>)

Original publisher: [Read original article](<https://lea.verou.me/2020/11/simple-pie-charts-with-fallback-today/>)

Author: Lea Verou

Published: 2020-11-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [Data visualization](<https://devfeed.tech/topics/data-visualization.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [web graphics](<https://devfeed.tech/topics/web-graphics.md>), [browser](<https://devfeed.tech/topics/browser.md>), [polyfill](<https://devfeed.tech/topics/polyfill.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [charts](<https://devfeed.tech/tags/charts.md>), [conic-gradient](<https://devfeed.tech/tags/conic-gradient.md>), [css](<https://devfeed.tech/tags/css.md>), [dependency](<https://devfeed.tech/tags/dependency.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [firefox](<https://devfeed.tech/tags/firefox.md>), [graceful-degradation](<https://devfeed.tech/tags/graceful-degradation.md>), [gradient](<https://devfeed.tech/tags/gradient.md>), [pie](<https://devfeed.tech/tags/pie.md>), [pie-charts](<https://devfeed.tech/tags/pie-charts.md>), [polyfill](<https://devfeed.tech/tags/polyfill.md>), [prefix-free](<https://devfeed.tech/tags/prefix-free.md>), [tips](<https://devfeed.tech/tags/tips.md>)

## AI overview

For IE11 support, use a linear-gradient progress bar as a graceful fallback and switch to a conic-gradient pie with `@supports` in capable browsers. The excerpt's example uses matching color stops; CSS variables can avoid duplicating the percentage in relatively modern browsers. A square fallback keeps chart dimensions consistent, though it is not a pie. The older conic-gradient polyfill is discouraged for production unless `-prefix-free` is already in use, because it adds a heavy dependency that reprocesses CSS and loses sourcemaps. Radial-gradient circles are a poor substitute: naive radius scaling misrepresents area, and getting the desired proportions requires a square-root calculation.

## Source excerpt

Five years ago, I had written this extensive Smashing Magazine article detailing multiple different methods for creating simple pie charts, either with clever use of transforms and pseudo-elements, or with SVG stroke-dasharray. In the end, I mentioned creating pie charts with conic gradients, as a future technique. It was actually a writeup of my "The Missing Slice" talk, and an excerpt of my CSS Secrets book, which had just been published. I was reminded of this article today by someone on Twitter: https://twitter.com/sam\_kent\_/status/1326805431390531584 I suggested conic gradients, since they are now supported in >87% of users' browsers, but he needed to support IE11. He suggested using my polyfill from back then, but this is not a very good idea today. https://twitter.com/fcorradini/status/1326880827825905665 Indeed, unless you really need to display conic gradients, even I would not recommend using the polyfill on a production facing site. It requires -prefix-free, which re-fetches (albeit from cache) your entire CSS and sticks it in a <style> element, with no sourcemaps since those were not a thing back when -prefix-free was written. If you're already using -prefix-free, the polyfill is great, but if not, it's way too heavy a dependency. Pie charts with fallback (modern browsers) Instead, what I would recommend is graceful degradation, i.e. to use the same color stops, but in a linear gradient. We can use @supports and have quite an elaborate progress bar fallback. For example, take a look at this 40% pie chart: .pie { height: 20px; background: linear-gradient(to right, deeppink 40%, transparent 0); background-color: gold; } @supports (background: conic-gradient(white, black)) { .pie { width: 200px; height: 200px; background-image: conic-gradient(deeppink 40%, transparent 0); border-radius: 50%; } } This is what it looks like in Firefox 82 (conic gradients are scheduled to ship unflagged in Firefox 83) or IE11: Note that because @supports is only used for the