SVG PIE Chart with CSS animation

Size
2,107 Kb
Views
30,360

How do I make an svg pie chart with css animation?

Pie percentage made by stroke-dasharray. stroke-dasharray format is below. keyframe 100% : 0 offset this-percentage rest. What is a svg pie chart with css animation? How do you make a svg pie chart with css animation? This script and codes were developed by Keisuke Takahashi on 19 November 2022, Saturday.

SVG PIE Chart with CSS animation Previews

SVG PIE Chart with CSS animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SVG PIE Chart with CSS animation</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <figure> <figcaption>SVG PIE Chart with CSS animation</figcaption>	<svg viewBox="0 0 63.6619772368 63.6619772368">	<circle class="pie1" cx="31.8309886184" cy="31.8309886184" r="15.9154943092"/>	<circle class="pie2" cx="31.8309886184" cy="31.8309886184" r="15.9154943092"/>	<circle class="pie3" cx="31.8309886184" cy="31.8309886184" r="15.9154943092"/>	<circle class="pie4" cx="31.8309886184" cy="31.8309886184" r="15.9154943092"/>	</svg>
</figure>
</body>
</html>

SVG PIE Chart with CSS animation - Script Codes CSS Codes

figure { background-color: #eee; display: block; height: 0; margin: 0 auto; position: relative; font-size:16px; font-size:1vw; width: 40em; padding-bottom: 40em;
}
figcaption { font-size:1rem; text-align:center; color:#fff; width: 100%; position: absolute; left: 0; top:40%; z-index:2;
}
svg { display: block; height: 100%; width: 100%; position: absolute; top: 0; left: 0; overflow: visible;
}
circle {	fill:rgba(0,0,0,0); stroke-width:31.8309886184; stroke-dasharray: 0,0,0,100; stroke-dashoffset: 25; -webkit-animation: pie1 3s infinite ease both; animation: pie1 6s infinite ease both;
}
.pie1 { stroke:hsl(180,70%,30%);
}
.pie2 { stroke:hsl(180,70%,50%); -webkit-animation-name: pie2; animation-name: pie2;
}
.pie3 { stroke:hsl(180,70%,20%); -webkit-animation-name: pie3; animation-name: pie3;
}
.pie4 { stroke:hsl(180,0%,70%); -webkit-animation-name: pie4; animation-name: pie4;
}
/* pie percentage made by stroke-dasharray. stroke-dasharray format is... keyframe 100% : 0 offset this-percentage rest I added keyframe 50% for infinite presentation.
*/
/* 1st pie is 40% */
@-webkit-keyframes pie1 { 50%,100% {stroke-dasharray: 40,60,0,0;}
}
@keyframes pie1 { 50%,100% {stroke-dasharray: 40,60,0,0;}
}
/* 2nd pie is 30% */
@-webkit-keyframes pie2 { 50%,100% {stroke-dasharray: 0,40,30,30;}
}
@keyframes pie2 { 50%,100% {stroke-dasharray: 0,40,30,30;}
}
/* 3rd pie is 30% */
@-webkit-keyframes pie3 { 50%,100% {stroke-dasharray: 0,70,20,10;}
}
@keyframes pie3 { 50%,100% {stroke-dasharray: 0,70,20,10;}
}
/* 4th pie is 10% */
@-webkit-keyframes pie4 { 50%,100% {stroke-dasharray: 0,90,10,0;}
}
@keyframes pie4 { 50%,100% {stroke-dasharray: 0,90,10,0;}
}
SVG PIE Chart with CSS animation - Script Codes
SVG PIE Chart with CSS animation - Script Codes
Home Page Home
Developer Keisuke Takahashi
Username ksksoft
Uploaded November 19, 2022
Rating 4
Size 2,107 Kb
Views 30,360
Do you need developer help for SVG PIE Chart with CSS animation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Keisuke Takahashi (ksksoft) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!