!function(b,e,F,x){var a=b.fn.peity=function(e,n){return i&&this.each(function(){var t=b(this),i=t.data("_peity");i?(e&&(i.type=e),b.extend(i.opts,n)):(i=new r(t,e,b.extend({},a.defaults[e],t.data("peity"),n)),t.change(function(){i.draw()}).data("_peity",i)),i.draw()}),this},r=function(t,i,e){this.$el=t,this.type=i,this.opts=e},t=r.prototype,S=t.svgElement=function(t,i){return b(e.createElementNS("http://www.w3.org/2000/svg",t)).attr(i)},i="createElementNS"in e&&S("svg",{})[0].createSVGRect;t.draw=function(){var t=this.opts;a.graphers[this.type].call(this,t),t.after&&t.after.call(this,t)},t.fill=function(){var e=this.opts.fill;return b.isFunction(e)?e:function(t,i){return e[i%e.length]}},t.prepare=function(t,i){return this.$svg||this.$el.hide().after(this.$svg=S("svg",{class:"peity"})),this.$svg.empty().data("_peity",this).attr({height:i,width:t})},t.values=function(){return b.map(this.$el.text().split(this.opts.delimiter),function(t){return parseFloat(t)})},a.defaults={},a.graphers={},a.register=function(t,i,e){this.defaults[t]=i,this.graphers[t]=e},a.register("pie",{fill:["#ff9900","#fff4dd","#ffc66e"],radius:8},function(t){if(!t.delimiter){var i=this.$el.text().match(/[^0-9\.]/);t.delimiter=i?i[0]:","}var e=b.map(this.values(),function(t){return 0<t?t:0});if("/"==t.delimiter){var n=e[0],a=e[1];e=[n,F.max(0,a-n)]}for(var r=0,s=e.length,h=0;r<s;r++)h+=e[r];h||(s=2,e=[0,h=1]);var l=2*t.radius,p=this.prepare(t.width||l,t.height||l),o=p.width(),d=p.height(),u=o/2,c=d/2,f=F.min(u,c),g=t.innerRadius;"donut"!=this.type||g||(g=.5*f);var v=F.PI,m=this.fill(),y=this.scale=function(t,i){var e=t/h*v*2-v/2;return[i*F.cos(e)+u,i*F.sin(e)+c]},w=0;for(r=0;r<s;r++){var x,$=e[r],k=$/h;if(0!=k){if(1==k)if(g){var j=u-.01,A=c-f,E=c-g;x=S("path",{d:["M",u,A,"A",f,f,0,1,1,j,A,"L",j,E,"A",g,g,0,1,0,u,E].join(" "),"data-value":$})}else x=S("circle",{cx:u,cy:c,"data-value":$,r:f});else{var L=w+$,M=["M"].concat(y(w,f),"A",f,f,0,.5<k?1:0,1,y(L,f),"L");g?M=M.concat(y(L,g),"A",g,g,0,.5<k?1:0,0,y(w,g)):M.push(u,c),w+=$,x=S("path",{d:M.join(" "),"data-value":$})}x.attr("fill",m.call(this,$,r,e)),p.append(x)}}}),a.register("donut",b.extend(!0,{},a.defaults.pie),function(t){a.graphers.pie.call(this,t)}),a.register("line",{delimiter:",",fill:"#c6d9fd",height:16,min:0,stroke:"#4d89f9",strokeWidth:1,width:32},function(t){var i=this.values();1==i.length&&i.push(i[0]);for(var e=F.max.apply(F,t.max==x?i:i.concat(t.max)),n=F.min.apply(F,t.min==x?i:i.concat(t.min)),a=this.prepare(t.width,t.height),r=t.strokeWidth,s=a.width(),h=a.height()-r,l=e-n,p=this.x=function(t){return t*(s/(i.length-1))},o=this.y=function(t){var i=h;return l&&(i-=(t-n)/l*h),i+r/2},d=o(F.max(n,0)),u=[0,d],c=0;c<i.length;c++)u.push(p(c),o(i[c]));u.push(s,d),t.fill&&a.append(S("polygon",{fill:t.fill,points:u.join(" ")})),r&&a.append(S("polyline",{fill:"none",points:u.slice(2,u.length-2).join(" "),stroke:t.stroke,"stroke-width":r,"stroke-linecap":"square"}))}),a.register("bar",{delimiter:",",fill:["#4D89F9"],height:16,min:0,padding:.1,width:32},function(t){for(var i=this.values(),e=F.max.apply(F,t.max==x?i:i.concat(t.max)),n=F.min.apply(F,t.min==x?i:i.concat(t.min)),a=this.prepare(t.width,t.height),r=a.width(),s=a.height(),h=e-n,l=t.padding,p=this.fill(),o=this.x=function(t){return t*r/i.length},d=this.y=function(t){return s-(h?(t-n)/h*s:1)},u=0;u<i.length;u++){var c,f=o(u+l),g=o(u+1-l)-f,v=i[u],m=d(v),y=m,w=m;h?v<0?y=d(F.min(e,0)):w=d(F.max(n,0)):c=1,0==(c=w-y)&&(c=1,0<e&&h&&y--),a.append(S("rect",{"data-value":v,fill:p.call(this,v,u,i),x:f,y:y,width:g,height:c}))}})}(jQuery,document,Math),document.addEventListener("DOMContentLoaded",function(){$(".peity-pie").peity("pie"),$(".peity-donut").peity("donut"),$(".peity-line").peity("line"),$(".peity-bar").peity("bar")});