I am looking for a pure CSS3 or SVG animated doughnut chart.
- Need to have the middle circle fill colour
- the outer circle to be split with a grey and a blue ie: blue 80% complete, grey 20% left remaining.
- need text in the middle of the circle.
I have found one example http://jsfiddle.net/4azpfk3r/
Can anyone help creating / editing the above to what i need please? Its half way there.
<div class="item css">
<h2>CSS</h2>
<svg width="160" height="160" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Layer 1</title>
<circle id="circle" class="circle_animation" r="69.85699" cy="81" cx="81" stroke-width="8" stroke="#69aff4" fill="none"/>
</g>
</svg>
</div>
Thanks
Try this, it uses
stroke-dasharray
to create strokes with a length of 251.2 see here for more reference . The stroke-dashoffset attribute specifies the distance into the dash pattern to start the dash see hereHere the stroke fills 80% (calculated using 251.2 - 251.2*80/100, 251.2 is the perimeter of the circle calculated using 2 * 3.14 * 40). ie
stroke-dashoffset = perimeter - perimeter * amount / 100
also setstroke-dasharray
toperimeter
.perimeter = 2 * 3.14 * radius
.You can check this blog post that explains the creation of doughnut charts easily.
See a 50% filled circle
Demo with multiple rings :
Demo with animation (not tested in all browsers)
Solution using jquery :
Give
data-fill=amount
to each of the.progress
and jquery will do the rest