/**! * easypiechart * lightweight plugin to render simple, animated and retina optimized pie charts * * @license * @author robert fleischmann (http://robert-fleischmann.de) * @version 2.1.6 **/ !function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],b):b(a.jquery)}(this,function(a){var b=function(a,b){var c,d=document.createelement("canvas");a.appendchild(d),"undefined"!=typeof g_vmlcanvasmanager&&g_vmlcanvasmanager.initelement(d);var e=d.getcontext("2d");d.width=d.height=b.size;var f=1;window.devicepixelratio>1&&(f=window.devicepixelratio,d.style.width=d.style.height=[b.size,"px"].join(""),d.width=d.height=b.size*f,e.scale(f,f)),e.translate(b.size/2,b.size/2),e.rotate((-0.5+b.rotate/180)*math.pi);var g=(b.size-b.linewidth)/2;b.scalecolor&&b.scalelength&&(g-=b.scalelength+2),date.now=date.now||function(){return+new date};var h=function(a,b,c){c=math.min(math.max(-1,c||0),1);var d=0>=c?!0:!1;e.beginpath(),e.arc(0,0,g,0,2*math.pi*c,d),e.strokestyle=a,e.linewidth=b,e.stroke()},i=function(){var a,c;e.linewidth=1,e.fillstyle=b.scalecolor,e.save();for(var d=24;d>0;--d)d%6===0?(c=b.scalelength,a=0):(c=.6*b.scalelength,a=b.scalelength-c),e.fillrect(-b.size/2+a,0,c,1),e.rotate(math.pi/12);e.restore()},j=function(){return window.requestanimationframe||window.webkitrequestanimationframe||window.mozrequestanimationframe||function(a){window.settimeout(a,1e3/60)}}(),k=function(){b.scalecolor&&i(),b.trackcolor&&h(b.trackcolor,b.trackwidth||b.linewidth,1)};this.getcanvas=function(){return d},this.getctx=function(){return e},this.clear=function(){e.clearrect(b.size/-2,b.size/-2,b.size,b.size)},this.draw=function(a){b.scalecolor||b.trackcolor?e.getimagedata&&e.putimagedata?c?e.putimagedata(c,0,0):(k(),c=e.getimagedata(0,0,b.size*f,b.size*f)):(this.clear(),k()):this.clear(),e.linecap=b.linecap;var d;d="function"==typeof b.barcolor?b.barcolor(a):b.barcolor,h(d,b.linewidth,a/100)}.bind(this),this.animate=function(a,c){var d=date.now();b.onstart(a,c);var e=function(){var f=math.min(date.now()-d,b.animate.duration),g=b.easing(this,f,a,c-a,b.animate.duration);this.draw(g),b.onstep(a,c,g),f>=b.animate.duration?b.onstop(a,c):j(e)}.bind(this);j(e)}.bind(this)},c=function(a,c){var d={barcolor:"#ef1e25",trackcolor:"#f9f9f9",scalecolor:"#dfe0e0",scalelength:5,linecap:"round",linewidth:3,trackwidth:void 0,size:110,rotate:0,animate:{duration:1e3,enabled:!0},easing:function(a,b,c,d,e){return b/=e/2,1>b?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},onstart:function(){},onstep:function(){},onstop:function(){}};if("undefined"!=typeof b)d.renderer=b;else{if("undefined"==typeof svgrenderer)throw new error("please load either the svg- or the canvasrenderer");d.renderer=svgrenderer}var e={},f=0,g=function(){this.el=a,this.options=e;for(var b in d)d.hasownproperty(b)&&(e[b]=c&&"undefined"!=typeof c[b]?c[b]:d[b],"function"==typeof e[b]&&(e[b]=e[b].bind(this)));e.easing="string"==typeof e.easing&&"undefined"!=typeof jquery&&jquery.isfunction(jquery.easing[e.easing])?jquery.easing[e.easing]:d.easing,"number"==typeof e.animate&&(e.animate={duration:e.animate,enabled:!0}),"boolean"!=typeof e.animate||e.animate||(e.animate={duration:1e3,enabled:e.animate}),this.renderer=new e.renderer(a,e),this.renderer.draw(f),a.dataset&&a.dataset.percent?this.update(parsefloat(a.dataset.percent)):a.getattribute&&a.getattribute("data-percent")&&this.update(parsefloat(a.getattribute("data-percent")))}.bind(this);this.update=function(a){return a=parsefloat(a),e.animate.enabled?this.renderer.animate(f,a):this.renderer.draw(a),f=a,this}.bind(this),this.disableanimation=function(){return e.animate.enabled=!1,this},this.enableanimation=function(){return e.animate.enabled=!0,this},g()};a.fn.easypiechart=function(b){return this.each(function(){var d;a.data(this,"easypiechart")||(d=a.extend({},b,a(this).data()),a.data(this,"easypiechart",new c(this,d)))})}});