All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.flot.jquery.flot.pie.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.4
Show newest version
(function(b){function c(D){var h=null;var L=null;var n=null;var B=null;var p=null;var M=0;var F=true;var o=10;var w=0.95;var A=0;var d=false;var z=false;var j=[];D.hooks.processOptions.push(g);D.hooks.bindEvents.push(e);function g(O,N){if(N.series.pie.show){N.grid.show=false;if(N.series.pie.label.show=="auto"){if(N.legend.show){N.series.pie.label.show=false}else{N.series.pie.label.show=true}}if(N.series.pie.radius=="auto"){if(N.series.pie.label.show){N.series.pie.radius=3/4}else{N.series.pie.radius=1}}if(N.series.pie.tilt>1){N.series.pie.tilt=1}if(N.series.pie.tilt<0){N.series.pie.tilt=0}O.hooks.processDatapoints.push(E);O.hooks.drawOverlay.push(H);O.hooks.draw.push(r)}}function e(P,N){var O=P.getOptions();if(O.series.pie.show&&O.grid.hoverable){N.unbind("mousemove").mousemove(t)}if(O.series.pie.show&&O.grid.clickable){N.unbind("click").click(l)}}function G(O){var P="";function N(S,T){if(!T){T=0}for(var R=0;Rh.width-n){B=h.width-n}}}function v(O){for(var N=0;N0){R.push({data:[[1,P]],color:N,label:a.series.pie.combine.label,angle:(P*(Math.PI*2))/M,percent:(P/M*100)})}return R}function r(S,Q){if(!L){return}ctx=Q;I();var T=S.getData();var P=0;while(F&&P0){n*=w}P+=1;N();if(a.series.pie.tilt<=0.8){O()}R()}if(P>=o){N();L.prepend('
Could not draw pie with labels contained inside canvas
')}if(S.setSeries&&S.insertLegend){S.setSeries(T);S.insertLegend()}function N(){ctx.clearRect(0,0,h.width,h.height);L.children().filter(".pieLabel, .pieLabelBackground").remove()}function O(){var Z=5;var Y=15;var W=10;var X=0.02;if(a.series.pie.radius>1){var U=a.series.pie.radius}else{var U=n*a.series.pie.radius}if(U>=(h.width/2)-Z||U*a.series.pie.tilt>=(h.height/2)-Y||U<=W){return}ctx.save();ctx.translate(Z,Y);ctx.globalAlpha=X;ctx.fillStyle="#000";ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);for(var V=1;V<=W;V++){ctx.beginPath();ctx.arc(0,0,U,0,Math.PI*2,false);ctx.fill();U-=V}ctx.restore()}function R(){var X=Math.PI*a.series.pie.startAngle;var U;if(a.series.pie.radius>1){U=a.series.pie.radius}else{U=n*a.series.pie.radius}ctx.save();ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);ctx.save();var Z=X;for(var W=0;W0){ctx.save();ctx.lineWidth=a.series.pie.stroke.width;Z=X;for(var W=0;W1e-9){ctx.moveTo(0,0)}else{if(b.browser.msie){ac-=0.0001}}ctx.arc(0,0,U,Z,Z+ac,false);ctx.closePath();Z+=ac;if(ab){ctx.fill()}else{ctx.stroke()}}function V(){var ad=X;if(a.series.pie.label.radius>1){var aa=a.series.pie.label.radius}else{var aa=n*a.series.pie.label.radius}for(var ac=0;ac=a.series.pie.label.threshold*100){ab(T[ac],ad,ac)}ad+=T[ac].angle}function ab(aq,aj,ah){if(aq.data[0][1]==0){return}var at=a.legend.labelFormatter,ar,af=a.series.pie.label.formatter;if(at){ar=at(aq.label,aq)}else{ar=aq.label}if(af){ar=af(ar,aq)}var ak=((aj+aq.angle)+aj)/2;var ap=B+Math.round(Math.cos(ak)*aa);var an=p+Math.round(Math.sin(ak)*aa)*a.series.pie.tilt;var ag=''+ar+"";L.append(ag);var ao=L.children("#pieLabel"+ah);var ae=(an-ao.height()/2);var ai=(ap-ao.width()/2);ao.css("top",ae);ao.css("left",ai);if(0-ae>0||0-ai>0||h.height-(ae+ao.height())<0||h.width-(ai+ao.width())<0){F=true}if(a.series.pie.label.background.opacity!=0){var al=a.series.pie.label.background.color;if(al==null){al=aq.color}var am="top:"+ae+"px;left:"+ai+"px;";b('
').insertBefore(ao).css("opacity",a.series.pie.label.background.opacity)}}}}}function J(N){if(a.series.pie.innerRadius>0){N.save();innerRadius=a.series.pie.innerRadius>1?a.series.pie.innerRadius:n*a.series.pie.innerRadius;N.globalCompositeOperation="destination-out";N.beginPath();N.fillStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.fill();N.closePath();N.restore();N.save();N.beginPath();N.strokeStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.stroke();N.closePath();N.restore()}}function s(Q,R){for(var S=false,P=-1,N=Q.length,O=N-1;++P1?O.series.pie.radius:n*O.series.pie.radius;for(var Q=0;Q1?P.series.pie.radius:n*P.series.pie.radius;R.save();R.translate(B,p);R.scale(1,P.series.pie.tilt);for(i=0;i1e-9){R.moveTo(0,0)}R.arc(0,0,N,S.startAngle,S.startAngle+S.angle,false);R.closePath();R.fill()}}}var a={series:{pie:{show:false,radius:"auto",innerRadius:0,startAngle:3/2,tilt:1,offset:{top:0,left:"auto"},stroke:{color:"#FFF",width:1},label:{show:"auto",formatter:function(d,e){return'
'+d+"
"+Math.round(e.percent)+"%
"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:0.5}}}};b.plot.plugins.push({init:c,options:a,name:"pie",version:"1.0"})})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy