Anyone know how to create a circle "progressbar" in svg? I need to specify the percentage of the circle, så that a color grows in the shape of a cake.
The growing can be static as long as I have a attribute to change its current status.
Anyone know how to create a circle "progressbar" in svg? I need to specify the percentage of the circle, så that a color grows in the shape of a cake.
The growing can be static as long as I have a attribute to change its current status.
Shamelessly copy and pasting from the specification:
The path uses the "elliptical arc" command to draw a partial circle. You can either draw several of them, each describing a different circular section, or you give one of them an ID and reference it with
<use xlink:href="#ID" />
. Then you can rotate the<use/>
. Draw as many of them as you need for granularity (e.g., 100 sectors allow you steps of 0% to 100%).To colorize them, just set the
fill=""
attribute of each single sector to the fitting value.Following is the idea I used to use. With a bit of modification in
css
andanimation
tag we can achieve more effects for intuitive user experiences.---SAMPLE CODE----
Hope you were looking for something kind of this. :)
Some time ago, I was needing one so I studied a lot to get it done. All you need is a simple SVG markup with the right coordinates, a bit of CSS for it and a little bit of JS (to allow change the % of the progress bar). But at same time you can generate the SVG on the back-end with the right coordinates based on the % you want and unless your progress cannot be read-only, that would work as well.
This is the implementation: http://codepen.io/leandroico/pen/zwIHl
And this is the sample of the SVG markup:
Thanks, boldewyn.
To answer my own question, I found the following solution:
One can use the following path in template:
And use this function from Raphael js-framework to update x and y. If total is 100, value is the percentage of progress:
The returned path variable is the value for the d attribute on the path element.
This works perfect, if your browser supports SVG Full with the Elliptical Arc command for the path-element. In my case I only have SVG tiny, so this wont work for me :(
Use this self implemented method in JavaScript for example here percentage=85
HTML Code:
jQuery Code:
Demo : Click Here