String.prototype.format||(String.prototype.format=function(){var t=arguments;if(t[0]instanceof Array){var e=t[0];return this.replace(/{(\d+)}/g,function(t,n){return"undefined"!=typeof e[n]?e[n]:t})}return this.replace(/{(\d+)}/g,function(e,n){return"undefined"!=typeof t[n]?t[n]:e})}),function(t){"use strict";jQuery.fn.pieChart=function(e,n){function i(t,e,n){void 0!==t&&void 0!==e&&void 0!==n&&t.setAttributeNS(null,e,n)}function a(t,e,n,a,r){var u=document.createElementNS(x,"text");return i(u,"index",e),i(u,"x",n),i(u,"y",a),i(u,"class",r),u.textContent=t,u}function r(t,e){var n=document.createElementNS(x,"path");return i(n,"d",t),i(n,"class",e),n}function u(t,e){}function c(){M.find(".pieChart").each(function(){var e=t(this),n={cssClass:e.attr("class"),value:e.attr("value"),title:e.text()};E.push(n),j+=parseFloat(e.attr("value"))}),t(E).each(function(){this.percentage=this.value/j*100})}function s(t,e,n,i){var a=(i-90)*Math.PI/180,r=new Array;return r.push(t+n*Math.cos(a)),r.push(e+n*Math.sin(a)),r}function o(t,e,n,i,a){var r=C.format(s(t,e,n,i)),u=s(t,e,n,a),c=a-i>180?1:0;return r+=A.format(n,n,0,c,1,u[0],u[1]),r+=S.format(t,e),r+="Z"}function h(){n&&N.append('<div class="caption">'+n+"</div>"),d=document.createElementNS(x,"svg"),N.append(d);var e=t('<ul class="legend"></ul>');t(E).each(function(n){var i=t('<li index="'+n+'"><span class="icon pie'+n+'"></span>'+this.title+"</li>");i.mouseenter(function(){u(this,!0)}).mouseleave(function(){u(this,!1)}),e.append(i)})}function f(){v=N.width(),g=N.height()-t(".legend").height()-t(".caption").height()-20,i(d,"width",v),i(d,"height",g),m=v/2,y=g/2,w=(v>g?g:v)/2-Q}function p(){var e=0,n=0;t(E).each(function(){var c=n+3.6*this.percentage,h=r(o(m,y,w,n,c),this.cssClass+" pie"+e),f=n+1.8*this.percentage;i(h,"value",this.value),i(h,"middleAngle",f),i(h,"index",e),t(h).mouseenter(function(){u(this,!0)}),t(h).mouseleave(function(){u(this,!1)}),d.appendChild(h);var p=s(m,y,w/2,f);d.appendChild(a(Math.round(100*this.percentage)/100+"%",e,p[0]-20,p[1],"percentage")),e++,n=c})}function l(){c(),h(),f(),p()}var d,v,g,m,y,w,x="http://www.w3.org/2000/svg",C="M {0} {1} ",S="L {0} {1} ",A="A {0} {1} {2} {3} {4} {5} {6} ",M=t(this),N=t(e),E=[],j=0,Q=10;l()}}(jQuery);