12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /*
- I loved Virgil's Dribble shot and decided to remake
- it with some SVG animations :) I didn't really want
- to recreate the curvy line since I believe straight
- lines are more accurate. Sorry Virgil, I might make
- them curvy one day :)! With a bit of time on my
- hands I could make it even more detailed.
- I hope you like it and post some feedback on how to
- make this better :)!
- Don't forget to check out the original at
- http://goo.gl/0aKiS0
- Kudos Virgil!*/
- function drawCircle(container,id,progress,parent){
- var paper = Snap(container);
- var prog = paper.path("M5,50 A45,45,0 1 1 95,50 A45,45,0 1 1 5,50");
- var lineL = prog.getTotalLength();
- var oneUnit = lineL/100;
- var toOffset = lineL - oneUnit * progress;
- var myID = 'circle-graph-'+id;
- prog.attr({
- 'stroke-dashoffset':lineL,
- 'stroke-dasharray':lineL,
- 'id':myID
- });
-
- var animTime = 1300/*progress / 100*/
-
- prog.animate({
- 'stroke-dashoffset':toOffset
- },animTime,mina.easein);
-
- function countCircle(animtime,parent,progress){
- var textContainer = $(parent).find('.circle-percentage');
- var i = 0;
- var time = 1300;
- var intervalTime = Math.abs(time / progress);
- var timerID = setInterval(function () {
- i++;
- textContainer.text(i+"%");
- if (i === progress) clearInterval(timerID);
- }, intervalTime);
- }
- countCircle(animTime,parent,progress);
- }
- drawCircle('#chart-3',1,77,'#circle-1');
- drawCircle('#chart-4',2,53,'#circle-2');
|