How To Create Dynamic Donut Charts With TailwindCSS And React
In this article, Paul Scanlon shares a super lightweight approach to creating a Donut chart using conic-gradient(). There are no additional libraries to install or maintain, and there’s no heavy JavaScript that needs to be downloaded by the browser in order for them to work.CSS is amazing — I’m regularly surprised at how far it has come in the years I’ve been using it (~2005 – present). One such surprise came when I noticed this tweet by Shruti Balasa which demonstrated how to create a pie chart using conic-gradient(). It’s fairly straightforward. Here’s a code snippet: div { background: conic-gradient(red 36deg, orange 36deg 170deg, yellow 170deg); border-radius: 50%; } Using this tiny amount of CSS, you can create gradients that start and stop at specific angles and define a color for each ‘segment’ of the pie chart. Happy Days! Brills, I thought I could use this instead of a charting library for a data dashboard project I’m working on for the new CockroachDB Cloud API, but I had a problem. I didn’t know the values for my chart ahead of time, and the values I was receiving from the API weren’t in degrees! Here’s a preview link and Open-source repo
Related Posts

Social Media Marketing

190 ChatGPT Prompts Marketers Should Use

16 Great Examples of Welcome Emails for New Customers [Templates]

(Un)Made in Currituck: East Coast Demolition

Entering Top 150 ETFs: BlackRock’s IBIT Bitcoin Fund Surpasses $10 Billion in AUM
