Файл: templates/backend/default/assets/plugins/jquery-flot/jquery.flot.pie.min.js
Строк: 329
<?php
!function(e){function t(t){function o(e,t){t.series.pie.show&&(t.grid.show=!1,"auto"==t.series.pie.label.show&&(t.series.pie.label.show=t.legend.show?!1:!0),"auto"==t.series.pie.radius&&(t.series.pie.radius=t.series.pie.label.show?.75:1),t.series.pie.tilt>1&&(t.series.pie.tilt=1),t.series.pie.tilt<0&&(t.series.pie.tilt=0),e.hooks.processDatapoints.push(s),e.hooks.drawOverlay.push(E),e.hooks.draw.push(d))}function a(e,t){var n=e.getOptions();n.series.pie.show&&n.grid.hoverable&&t.unbind("mousemove").mousemove(m),n.series.pie.show&&n.grid.clickable&&t.unbind("click").click(g)}function r(e){for(var t=0;t<e.length;++t){var n=parseFloat(e[t].data[0][1]);n&&(O+=n)}}function s(t){A||(A=!0,D=t.getCanvas(),I=e(D).parent(),n=t.getOptions(),t.setData(u(t.getData())))}function l(){K=I.children().filter(".legend").children().width(),_=Math.min(D.width,D.height/n.series.pie.tilt)/2,w=D.height/2+n.series.pie.offset.top,S=D.width/2,"auto"==n.series.pie.offset.left?n.legend.position.match("w")?S+=K/2:S-=K/2:S+=n.series.pie.offset.left,_>S?S=_:S>D.width-_&&(S=D.width-_)}function c(e){for(var t=0;t<e.length;++t)"number"==typeof e[t].data?e[t].data=[[1,e[t].data]]:("undefined"==typeof e[t].data||"undefined"==typeof e[t].data[0])&&("undefined"!=typeof e[t].data&&"undefined"!=typeof e[t].data.label&&(e[t].label=e[t].data.label),e[t].data=[[1,0]]);return e}function u(e){e=c(e),r(e);for(var t=0,i=0,o=n.series.pie.combine.color,a=[],s=0;s<e.length;++s)e[s].data[0][1]=parseFloat(e[s].data[0][1]),e[s].data[0][1]||(e[s].data[0][1]=0),e[s].data[0][1]/O<=n.series.pie.combine.threshold?(t+=e[s].data[0][1],i++,o||(o=e[s].color)):a.push({data:[[1,e[s].data[0][1]]],color:e[s].color,label:e[s].label,angle:e[s].data[0][1]*2*Math.PI/O,percent:100*(e[s].data[0][1]/O)});return i>0&&a.push({data:[[1,t]],color:o,label:n.series.pie.combine.label,angle:t*2*Math.PI/O,percent:100*(t/O)}),a}function d(t,i){function o(){ctx.clearRect(0,0,D.width,D.height),I.children().filter(".pieLabel, .pieLabelBackground").remove()}function a(){var e=5,t=15,i=10,o=.02;if(n.series.pie.radius>1)var a=n.series.pie.radius;else var a=_*n.series.pie.radius;if(!(a>=D.width/2-e||a*n.series.pie.tilt>=D.height/2-t||i>=a)){ctx.save(),ctx.translate(e,t),ctx.globalAlpha=o,ctx.fillStyle="#000",ctx.translate(S,w),ctx.scale(1,n.series.pie.tilt);for(var r=1;i>=r;r++)ctx.beginPath(),ctx.arc(0,0,a,0,2*Math.PI,!1),ctx.fill(),a-=r;ctx.restore()}}function r(){function t(t,n,i){0>=t||(i?ctx.fillStyle=n:(ctx.strokeStyle=n,ctx.lineJoin="round"),ctx.beginPath(),Math.abs(t-2*Math.PI)>1e-9?ctx.moveTo(0,0):e.browser.msie&&(t-=1e-4),ctx.arc(0,0,o,a,a+t,!1),ctx.closePath(),a+=t,i?ctx.fill():ctx.stroke())}function i(){function t(t,i,a){if(0!=t.data[0][1]){var r,s=n.legend.labelFormatter,l=n.series.pie.label.formatter;r=s?s(t.label,t):t.label,l&&(r=l(r,t));var c=(i+t.angle+i)/2,u=S+Math.round(Math.cos(c)*o),d=w+Math.round(Math.sin(c)*o)*n.series.pie.tilt,h='<span class="pieLabel" id="pieLabel'+a+'" style="position:absolute;top:'+d+"px;left:"+u+'px;">'+r+"</span>";I.append(h);var f=I.children("#pieLabel"+a),p=d-f.height()/2,m=u-f.width()/2;if(f.css("top",p),f.css("left",m),(0-p>0||0-m>0||D.height-(p+f.height())<0||D.width-(m+f.width())<0)&&(R=!0),0!=n.series.pie.label.background.opacity){var g=n.series.pie.label.background.color;null==g&&(g=t.color);var v="top:"+p+"px;left:"+m+"px;";e('<div class="pieLabelBackground" style="position:absolute;width:'+f.width()+"px;height:"+f.height()+"px;"+v+"background-color:"+g+';"> </div>').insertBefore(f).css("opacity",n.series.pie.label.background.opacity)}}}var i=startAngle;if(n.series.pie.label.radius>1)var o=n.series.pie.label.radius;else var o=_*n.series.pie.label.radius;for(var a=0;a<s.length;++a)s[a].percent>=100*n.series.pie.label.threshold&&t(s[a],i,a),i+=s[a].angle}if(startAngle=Math.PI*n.series.pie.startAngle,n.series.pie.radius>1)var o=n.series.pie.radius;else var o=_*n.series.pie.radius;ctx.save(),ctx.translate(S,w),ctx.scale(1,n.series.pie.tilt),ctx.save();for(var a=startAngle,r=0;r<s.length;++r)s[r].startAngle=a,t(s[r].angle,s[r].color,!0);ctx.restore(),ctx.save(),ctx.lineWidth=n.series.pie.stroke.width,a=startAngle;for(var r=0;r<s.length;++r)t(s[r].angle,n.series.pie.stroke.color,!1);ctx.restore(),h(ctx),n.series.pie.label.show&&i(),ctx.restore()}if(I){ctx=i,l();for(var s=t.getData(),c=0;R&&k>c;)R=!1,c>0&&(_*=N),c+=1,o(),n.series.pie.tilt<=.8&&a(),r();c>=k&&(o(),I.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>')),t.setSeries&&t.insertLegend&&(t.setSeries(s),t.insertLegend())}}function h(e){n.series.pie.innerRadius>0&&(e.save(),innerRadius=n.series.pie.innerRadius>1?n.series.pie.innerRadius:_*n.series.pie.innerRadius,e.globalCompositeOperation="destination-out",e.beginPath(),e.fillStyle=n.series.pie.stroke.color,e.arc(0,0,innerRadius,0,2*Math.PI,!1),e.fill(),e.closePath(),e.restore(),e.save(),e.beginPath(),e.strokeStyle=n.series.pie.stroke.color,e.arc(0,0,innerRadius,0,2*Math.PI,!1),e.stroke(),e.closePath(),e.restore())}function f(e,t){for(var n=!1,i=-1,o=e.length,a=o-1;++i<o;a=i)(e[i][1]<=t[1]&&t[1]<e[a][1]||e[a][1]<=t[1]&&t[1]<e[i][1])&&t[0]<(e[a][0]-e[i][0])*(t[1]-e[i][1])/(e[a][1]-e[i][1])+e[i][0]&&(n=!n);return n}function p(e,n){for(var i=t.getData(),o=t.getOptions(),a=o.series.pie.radius>1?o.series.pie.radius:_*o.series.pie.radius,r=0;r<i.length;++r){var s=i[r];if(s.pie.show){if(ctx.save(),ctx.beginPath(),ctx.moveTo(0,0),ctx.arc(0,0,a,s.startAngle,s.startAngle+s.angle,!1),ctx.closePath(),x=e-S,y=n-w,ctx.isPointInPath){if(ctx.isPointInPath(e-S,n-w))return ctx.restore(),{datapoint:[s.percent,s.data],dataIndex:0,series:s,seriesIndex:r}}else if(p1X=a*Math.cos(s.startAngle),p1Y=a*Math.sin(s.startAngle),p2X=a*Math.cos(s.startAngle+s.angle/4),p2Y=a*Math.sin(s.startAngle+s.angle/4),p3X=a*Math.cos(s.startAngle+s.angle/2),p3Y=a*Math.sin(s.startAngle+s.angle/2),p4X=a*Math.cos(s.startAngle+s.angle/1.5),p4Y=a*Math.sin(s.startAngle+s.angle/1.5),p5X=a*Math.cos(s.startAngle+s.angle),p5Y=a*Math.sin(s.startAngle+s.angle),arrPoly=[[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]],arrPoint=[x,y],f(arrPoly,arrPoint))return ctx.restore(),{datapoint:[s.percent,s.data],dataIndex:0,series:s,seriesIndex:r};ctx.restore()}}return null}function m(e){v("plothover",e)}function g(e){v("plotclick",e)}function v(e,i){var o=t.offset(),a=parseInt(i.pageX-o.left),r=parseInt(i.pageY-o.top),s=p(a,r);if(n.grid.autoHighlight)for(var l=0;l<L.length;++l){var c=L[l];c.auto!=e||s&&c.series==s.series||T(c.series)}s&&b(s.series,e);var u={pageX:i.pageX,pageY:i.pageY};I.trigger(e,[u,s])}function b(e,n){"number"==typeof e&&(e=series[e]);var i=C(e);-1==i?(L.push({series:e,auto:n}),t.triggerRedrawOverlay()):n||(L[i].auto=!1)}function T(e){null==e&&(L=[],t.triggerRedrawOverlay()),"number"==typeof e&&(e=series[e]);var n=C(e);-1!=n&&(L.splice(n,1),t.triggerRedrawOverlay())}function C(e){for(var t=0;t<L.length;++t){var n=L[t];if(n.series==e)return t}return-1}function E(e,t){function n(e){e.angle<0||(t.fillStyle="rgba(255, 255, 255, "+o.series.pie.highlight.opacity+")",t.beginPath(),Math.abs(e.angle-2*Math.PI)>1e-9&&t.moveTo(0,0),t.arc(0,0,a,e.startAngle,e.startAngle+e.angle,!1),t.closePath(),t.fill())}var o=e.getOptions(),a=o.series.pie.radius>1?o.series.pie.radius:_*o.series.pie.radius;for(t.save(),t.translate(S,w),t.scale(1,o.series.pie.tilt),i=0;i<L.length;++i)n(L[i].series);h(t),t.restore()}var D=null,I=null,_=null,S=null,w=null,O=0,R=!0,k=10,N=.95,K=0,A=!1,L=[];t.hooks.processOptions.push(o),t.hooks.bindEvents.push(a)}var n={series:{pie:{show:!1,radius:"auto",innerRadius:0,startAngle:1.5,tilt:1,offset:{top:0,left:"auto"},stroke:{color:"#FFF",width:1},label:{show:"auto",formatter:function(e,t){return'<div style="font-size:x-small;text-align:center;padding:2px;color:'+t.color+';">'+e+"<br/>"+Math.round(t.percent)+"%</div>"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:.5}}}};e.plot.plugins.push({init:t,options:n,name:"pie",version:"1.0"})}(jQuery);
?>