Pure CSS Radial Graph

Size
2,363 Kb
Views
12,144

How do I make an pure css radial graph?

This is simple, animatable circle graph/progress meter made with pure CSS. Animations are included using CSS transitions on the rotation values of the fill elements.. What is a pure css radial graph? How do you make a pure css radial graph? This script and codes were developed by Christian Naths on 29 November 2022, Tuesday.

Pure CSS Radial Graph Previews

Pure CSS Radial Graph - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure CSS Radial Graph</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="radial-graph">	<div class="shape">	<div class="mask full-mask">	<div class="fill"></div>	</div>	<div class="mask">	<div class="fill"></div>	<div class="fill shim"></div>	</div>	</div>	<div class="cutout">	</div>
</div>
</body>
</html>

Pure CSS Radial Graph - Script Codes CSS Codes

/* just some container styles */
body, html { height: 100%; }
body { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; }
/* Radial Graph Settings - size: .radial-graph, .shape, .mask, and .fill will all need to receive the same width & height properties. Then .mask and .fill need to have their clip property set accordingly. - width: The stroke width is made by just placing a "cutout" shape on top, and can be sized and positioned as you like (or removed). - progress: adjust the .fill.shim rotation to a percentage of the total radius, and then the .mask.full-mask & .fill rotations to a value of half of that. See inline comments below for the formulas.
*/
.radial-graph,
.shape,
.mask,
.fill { width: 220px; height: 220px; border-radius: 50%;
}
.shape,
.mask,
.fill { position: absolute; background-color: #ebeff1;
}
.mask,
.fill { -webkit-backface-visibility: hidden; -webkit-transition: -webkit-transform 1s; transition: -webkit-transform 1s; transition: transform 1s; transition: transform 1s, -webkit-transform 1s; border-radius: 50%;
}
.mask { clip: rect(0px, 220px, 220px, 110px);
}
.fill { clip: rect(0px, 110px, 220px, 0px); background-color: #50e3c2;
}
.cutout { margin-left: 15px; margin-top: 15px; width: 190px; height: 190px; position: absolute; background-color: white; border-radius: 50%;
}
.mask.full-mask,
.fill { /* For a value of 90% 0.9 * 360 / 2 */ -webkit-transform: rotate(162deg); transform: rotate(162deg);
}
.fill.shim { /* For a value of 90% 0.9 * 360 */ -webkit-transform: rotate(324deg); transform: rotate(324deg);
}
.start .mask.full-mask,
.start .fill { /* For a value of 40% 0.4 * 360 / 2 */ -webkit-transform: rotate(0deg); transform: rotate(0deg);
}
.start .fill.shim { /* For a value of 40% 0.4 * 360 */ -webkit-transform: rotate(0deg); transform: rotate(0deg);
}
.end .mask.full-mask,
.end .fill { /* For a value of 81% 0.81 * 360 / 2 */ -webkit-transform: rotate(145.8deg); transform: rotate(145.8deg);
}
.end .fill.shim { /* For a value of 81% 0.81 * 360 */ -webkit-transform: rotate(291.6deg); transform: rotate(291.6deg);
}
Pure CSS Radial Graph - Script Codes
Pure CSS Radial Graph - Script Codes
Home Page Home
Developer Christian Naths
Username christiannaths
Uploaded November 29, 2022
Rating 3
Size 2,363 Kb
Views 12,144
Do you need developer help for Pure CSS Radial Graph?

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!

Christian Naths (christiannaths) Script Codes
Create amazing video scripts 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!