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(c){var e=10;var a=0.95;function d(v){var h=null,A=null,m=null,s=null,n=null,f=false,u=null;var i=[];v.hooks.processOptions.push(function(C,B){if(B.series.pie.show){B.grid.show=false;if(B.series.pie.label.show=="auto"){if(B.legend.show){B.series.pie.label.show=false}else{B.series.pie.label.show=true}}if(B.series.pie.radius=="auto"){if(B.series.pie.label.show){B.series.pie.radius=3/4}else{B.series.pie.radius=1}}if(B.series.pie.tilt>1){B.series.pie.tilt=1}else{if(B.series.pie.tilt<0){B.series.pie.tilt=0}}}});v.hooks.bindEvents.push(function(D,B){var C=D.getOptions();if(C.series.pie.show){if(C.grid.hoverable){B.unbind("mousemove").mousemove(r)}if(C.grid.clickable){B.unbind("click").click(k)}}});v.hooks.processDatapoints.push(function(F,C,D,E){var B=F.getOptions();if(B.series.pie.show){w(F,C,D,E)}});v.hooks.drawOverlay.push(function(C,D){var B=C.getOptions();if(B.series.pie.show){x(C,D)}});v.hooks.draw.push(function(D,C){var B=D.getOptions();if(B.series.pie.show){o(D,C)}});function w(D,B,C){if(!f){f=true;h=D.getCanvas();A=c(h).parent();b=D.getOptions();D.setData(z(D.getData()))}}function z(G){var E=0,D=0,I=0,B=b.series.pie.combine.color,H=[];for(var C=0;Cb.series.pie.combine.threshold){H.push({data:[[1,F]],color:G[C].color,label:G[C].label,angle:F*Math.PI*2/E,percent:F/(E/100)})}}if(I>1){H.push({data:[[1,D]],color:B,label:b.series.pie.combine.label,angle:D*Math.PI*2/E,percent:D/(E/100)})}return H}function o(G,J){if(!A){return}var C=G.getPlaceholder().width(),E=G.getPlaceholder().height(),I=A.children().filter(".legend").children().width()||0;u=J;f=false;m=Math.min(C,E/b.series.pie.tilt)/2;n=E/2+b.series.pie.offset.top;s=C/2;if(b.series.pie.offset.left=="auto"){if(b.legend.position.match("w")){s+=I/2}else{s-=I/2}}else{s+=b.series.pie.offset.left}if(sC-m){s=C-m}}var H=G.getData(),K=0;do{if(K>0){m*=a}K+=1;F();if(b.series.pie.tilt<=0.8){D()}}while(!B()&&K=e){F();A.prepend("
Could not draw pie with labels contained inside canvas
")}if(G.setSeries&&G.insertLegend){G.setSeries(H);G.insertLegend()}function F(){u.clearRect(0,0,C,E);A.children().filter(".pieLabel, .pieLabelBackground").remove()}function D(){var Q=b.series.pie.shadow.left;var P=b.series.pie.shadow.top;var N=10;var O=b.series.pie.shadow.alpha;var L=b.series.pie.radius>1?b.series.pie.radius:m*b.series.pie.radius;if(L>=C/2-Q||L*b.series.pie.tilt>=E/2-P||L<=N){return}u.save();u.translate(Q,P);u.globalAlpha=O;u.fillStyle="#000";u.translate(s,n);u.scale(1,b.series.pie.tilt);for(var M=1;M<=N;M++){u.beginPath();u.arc(0,0,L,0,Math.PI*2,false);u.fill();L-=M}u.restore()}function B(){var O=Math.PI*b.series.pie.startAngle;var L=b.series.pie.radius>1?b.series.pie.radius:m*b.series.pie.radius;u.save();u.translate(s,n);u.scale(1,b.series.pie.tilt);u.save();var Q=O;for(var N=0;N0){u.save();u.lineWidth=b.series.pie.stroke.width;Q=O;for(var N=0;N1e-9){u.moveTo(0,0)}u.arc(0,0,L,Q,Q+T/2,false);u.arc(0,0,L,Q+T/2,Q+T,false);u.closePath();Q+=T;if(S){u.fill()}else{u.stroke()}}function M(){var U=O;var R=b.series.pie.label.radius>1?b.series.pie.label.radius:m*b.series.pie.label.radius;for(var T=0;T=b.series.pie.label.threshold*100){if(!S(H[T],U,T)){return false}}U+=H[T].angle}return true;function S(ah,aa,Y){if(ah.data[0][1]==0){return true}var aj=b.legend.labelFormatter,ai,W=b.series.pie.label.formatter;if(aj){ai=aj(ah.label,ah)}else{ai=ah.label}if(W){ai=W(ai,ah)}var ab=((aa+ah.angle)+aa)/2;var ag=s+Math.round(Math.cos(ab)*R);var ae=n+Math.round(Math.sin(ab)*R)*b.series.pie.tilt;var X=""+ai+"";A.append(X);var af=A.children("#pieLabel"+Y);var V=(ae-af.height()/2);var Z=(ag-af.width()/2);af.css("top",V);af.css("left",Z);if(0-V>0||0-Z>0||E-(V+af.height())<0||C-(Z+af.width())<0){return false}if(b.series.pie.label.background.opacity!=0){var ac=b.series.pie.label.background.color;if(ac==null){ac=ah.color}var ad="top:"+V+"px;left:"+Z+"px;";c("
").css("opacity",b.series.pie.label.background.opacity).insertBefore(af)}return true}}}}function y(B){if(b.series.pie.innerRadius>0){B.save();var C=b.series.pie.innerRadius>1?b.series.pie.innerRadius:m*b.series.pie.innerRadius;B.globalCompositeOperation="destination-out";B.beginPath();B.fillStyle=b.series.pie.stroke.color;B.arc(0,0,C,0,Math.PI*2,false);B.fill();B.closePath();B.restore();B.save();B.beginPath();B.strokeStyle=b.series.pie.stroke.color;B.arc(0,0,C,0,Math.PI*2,false);B.stroke();B.closePath();B.restore()}}function p(E,F){for(var G=false,D=-1,B=E.length,C=B-1;++D1?G.series.pie.radius:m*G.series.pie.radius,M,K;for(var T=0;T1?D.series.pie.radius:m*D.series.pie.radius;G.save();G.translate(s,n);G.scale(1,D.series.pie.tilt);for(var E=0;E1e-9){G.moveTo(0,0)}G.arc(0,0,B,H.startAngle,H.startAngle+H.angle/2,false);G.arc(0,0,B,H.startAngle+H.angle/2,H.startAngle+H.angle,false);G.closePath();G.fill()}}}var b={series:{pie:{show:false,radius:"auto",innerRadius:0,startAngle:3/2,tilt:1,shadow:{left:5,top:15,alpha:0.02},offset:{top:0,left:"auto"},stroke:{color:"#fff",width:1},label:{show:"auto",formatter:function(f,g){return"
"+f+"
"+Math.round(g.percent)+"%
"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:0.5}}}};c.plot.plugins.push({init:d,options:b,name:"pie",version:"1.1"})})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy