!function(e){var i={series:{pie:{show:!1,radius:"auto",innerRadius:0,startAngle:1.5,tilt:1,shadow:{left:5,top:15,alpha:.02},offset:{top:0,left:"auto"},stroke:{color:"#fff",width:1},label:{show:"auto",formatter:function(e,i){return"
"+e+"
"+Math.round(i.percent)+"%
"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:.5}}}};e.plot.plugins.push({init:function(s){var t=null,r=null,a=null,l=null,n=null,o=!1,p=null,h=[];function c(s,a,l){o||(o=!0,t=s.getCanvas(),r=e(t).parent(),i=s.getOptions(),s.setData(function(s){for(var t=0,r=0,a=0,l=i.series.pie.combine.color,n=[],o=0;oi.series.pie.combine.threshold)&&n.push({data:[[1,p]],color:s[o].color,label:s[o].label,angle:p*Math.PI*2/t,percent:p/(t/100)});return a>1&&n.push({data:[[1,r]],color:l,label:i.series.pie.combine.label,angle:r*Math.PI*2/t,percent:r/(t/100)}),n}(s.getData())))}function g(s,t){if(r){var h=s.getPlaceholder().width(),c=s.getPlaceholder().height(),g=r.children().filter(".legend").children().width()||0;p=t,o=!1,a=Math.min(h,c/i.series.pie.tilt)/2,n=c/2+i.series.pie.offset.top,l=h/2,"auto"==i.series.pie.offset.left?i.legend.position.match("w")?l+=g/2:l-=g/2:l+=i.series.pie.offset.left,lh-a&&(l=h-a);var d=s.getData(),f=0;do{f>0&&(a*=.95),f+=1,v(),i.series.pie.tilt<=.8&&b()}while(!w()&&f<10);f>=10&&(v(),r.prepend("
Could not draw pie with labels contained inside canvas
")),s.setSeries&&s.insertLegend&&(s.setSeries(d),s.insertLegend())}function v(){p.clearRect(0,0,h,c),r.children().filter(".pieLabel, .pieLabelBackground").remove()}function b(){var e=i.series.pie.shadow.left,s=i.series.pie.shadow.top,t=i.series.pie.shadow.alpha,r=i.series.pie.radius>1?i.series.pie.radius:a*i.series.pie.radius;if(!(r>=h/2-e||r*i.series.pie.tilt>=c/2-s||r<=10)){p.save(),p.translate(e,s),p.globalAlpha=t,p.fillStyle="#000",p.translate(l,n),p.scale(1,i.series.pie.tilt);for(var o=1;o<=10;o++)p.beginPath(),p.arc(0,0,r,0,2*Math.PI,!1),p.fill(),r-=o;p.restore()}}function w(){var s=Math.PI*i.series.pie.startAngle,t=i.series.pie.radius>1?i.series.pie.radius:a*i.series.pie.radius;p.save(),p.translate(l,n),p.scale(1,i.series.pie.tilt),p.save();for(var o=s,g=0;g0){for(p.save(),p.lineWidth=i.series.pie.stroke.width,o=s,g=0;g1?i.series.pie.label.radius:a*i.series.pie.label.radius,p=0;p=100*i.series.pie.label.threshold&&!g(d[p],t,p))return!1;t+=d[p].angle}return!0;function g(s,t,a){if(0==s.data[0][1])return!0;var p,g=i.legend.labelFormatter,u=i.series.pie.label.formatter;p=g?g(s.label,s):s.label,u&&(p=u(p,s));var d=(t+s.angle+t)/2,f=l+Math.round(Math.cos(d)*o),v=n+Math.round(Math.sin(d)*o)*i.series.pie.tilt,b=""+p+"";r.append(b);var w=r.children("#pieLabel"+a),k=v-w.height()/2,M=f-w.width()/2;if(w.css("top",k),w.css("left",M),0-k>0||0-M>0||c-(k+w.height())<0||h-(M+w.width())<0)return!1;if(0!=i.series.pie.label.background.opacity){var P=i.series.pie.label.background.color;null==P&&(P=s.color);var m="top:"+k+"px;left:"+M+"px;";e("
").css("opacity",i.series.pie.label.background.opacity).insertBefore(w)}return!0}}();function f(e,i,s){e<=0||isNaN(e)||(s?p.fillStyle=i:(p.strokeStyle=i,p.lineJoin="round"),p.beginPath(),Math.abs(e-2*Math.PI)>1e-9&&p.moveTo(0,0),p.arc(0,0,t,o,o+e/2,!1),p.arc(0,0,t,o+e/2,o+e,!1),p.closePath(),o+=e,s?p.fill():p.stroke())}}}function u(e){if(i.series.pie.innerRadius>0){e.save();var s=i.series.pie.innerRadius>1?i.series.pie.innerRadius:a*i.series.pie.innerRadius;e.globalCompositeOperation="destination-out",e.beginPath(),e.fillStyle=i.series.pie.stroke.color,e.arc(0,0,s,0,2*Math.PI,!1),e.fill(),e.closePath(),e.restore(),e.save(),e.beginPath(),e.strokeStyle=i.series.pie.stroke.color,e.arc(0,0,s,0,2*Math.PI,!1),e.stroke(),e.closePath(),e.restore()}}function d(e,i){for(var s=!1,t=-1,r=e.length,a=r-1;++t1?h.series.pie.radius:a*h.series.pie.radius,g=0;g1?i.series.pie.tilt=1:i.series.pie.tilt<0&&(i.series.pie.tilt=0))})),s.hooks.bindEvents.push((function(e,i){var s=e.getOptions();s.series.pie.show&&(s.grid.hoverable&&i.unbind("mousemove").mousemove(f),s.grid.clickable&&i.unbind("click").click(v))})),s.hooks.processDatapoints.push((function(e,i,s,t){e.getOptions().series.pie.show&&c(e)})),s.hooks.drawOverlay.push((function(e,i){e.getOptions().series.pie.show&&function(e,i){var s=e.getOptions(),t=s.series.pie.radius>1?s.series.pie.radius:a*s.series.pie.radius;i.save(),i.translate(l,n),i.scale(1,s.series.pie.tilt);for(var r=0;r1e-9&&i.moveTo(0,0),i.arc(0,0,t,e.startAngle,e.startAngle+e.angle/2,!1),i.arc(0,0,t,e.startAngle+e.angle/2,e.startAngle+e.angle,!1),i.closePath(),i.fill())}u(i),i.restore()}(e,i)})),s.hooks.draw.push((function(e,i){e.getOptions().series.pie.show&&g(e,i)}))},options:i,name:"pie",version:"1.1"})}(jQuery);