//>>built
define("dojox/charting/plot2d/Pie","dojo/_base/lang dojo/_base/array dojo/_base/declare dojo/dom-geometry dojo/_base/Color ./Base ./_PlotEvents ./common dojox/gfx dojox/gfx/matrix dojox/lang/functional dojox/lang/utils dojo/has".split(" "),function(Q,N,ja,aa,ka,la,ma,na,K,ba,E,ca,da){return ja("dojox.charting.plot2d.Pie",[la,ma],{defaultParams:{labels:!0,ticks:!1,fixed:!0,precision:1,labelOffset:20,labelStyle:"default",htmlLabels:!0,radGrad:"native",fanSize:5,startAngle:0,innerRadius:0,minWidth:0,
zeroDataMessage:""},optionalParams:{radius:0,omitLabels:!1,stroke:{},outline:{},shadow:{},fill:{},filter:{},styleFunc:null,font:"",fontColor:"",labelWiring:{}},constructor:function(k,a){this.opt=Q.clone(this.defaultParams);ca.updateWithObject(this.opt,a);ca.updateWithPattern(this.opt,a,this.optionalParams);this.axes=[];this.run=null;this.dyn=[];this.runFilter=[];a&&a.hasOwnProperty("innerRadius")&&(this._plotSetInnerRadius=!0)},clear:function(){this.inherited(arguments);this.dyn=[];this.run=null;
return this},setAxis:function(k){return this},addSeries:function(k){this.run=k;return this},getSeriesStats:function(){return Q.delegate(na.defaultStats)},getRequiredColors:function(){return this.run?this.run.data.length:0},render:function(k,a){if(!this.dirty)return this;this.resetEvents();this.dirty=!1;this._eventSeries={};this.cleanGroup();var f=this.group,p=this.chart.theme;!this._plotSetInnerRadius&&p&&p.pieInnerRadius&&(this.opt.innerRadius=p.pieInnerRadius);var t=(k.width-a.l-a.r)/2,q=(k.height-
a.t-a.b)/2,g=Math.min(t,q),u="font"in this.opt?this.opt.font:p.axis.tick.titleFont||"",B=u?K.normalizedLength(K.splitFontString(u).size):0,z=this.opt.hasOwnProperty("fontColor")?this.opt.fontColor:p.axis.tick.fontColor,L=ba._degToRad(this.opt.startAngle),C=L,F,M=this.run.data,U=this.events(),O=Q.hitch(this,function(){var d=p.clone(),e=E.map(M,function(r){var x=[this.opt,this.run];null!==r&&"number"!=typeof r&&x.push(r);this.opt.styleFunc&&x.push(this.opt.styleFunc(r));return d.next("slice",x,!0)},
this);"radius"in this.opt&&(g=this.opt.radius<g?this.opt.radius:g);var c={cx:a.l+t,cy:a.t+q,r:g},h=new ka(z);this.opt.innerRadius&&(h.a=.1);var w=this._createRing(f,c).setStroke(h);this.opt.innerRadius&&w.setFill(h);this.opt.zeroDataMessage&&this.renderLabel(f,c.cx,c.cy+B/3,this.opt.zeroDataMessage,{series:{font:u,fontColor:z}},null,"middle");this.dyn=[];N.forEach(M,function(r,x){this.dyn.push({fill:this._plotFill(e[x].series.fill,k,a),stroke:e[x].series.stroke})},this)});if(!this.run&&!this.run.data.ength)return O(),
this;if("number"==typeof M[0]){var y=E.map(M,"x ? Math.max(x, 0) : 0");if(E.every(y,"\x3c\x3d 0"))return O(),this;var D=E.map(y,"/this",E.foldl(y,"+",0));this.opt.labels&&(F=N.map(D,function(d){return 0<d?this._getLabel(100*d)+"%":""},this))}else{y=E.map(M,"x ? Math.max(x.y, 0) : 0");if(!y.length||E.every(y,"\x3c\x3d 0"))return O(),this;D=E.map(y,"/this",E.foldl(y,"+",0));this.opt.labels&&(F=N.map(D,function(d,e){if(0>d)return"";var c=M[e];return c.hasOwnProperty("text")?c.text:this._getLabel(100*
d)+"%"},this))}var P=E.map(M,function(d){var e=[this.opt,this.run];null!==d&&"number"!=typeof d&&e.push(d);this.opt.styleFunc&&e.push(this.opt.styleFunc(d));return p.next("slice",e,!0)},this);this.opt.labels&&(y=E.foldl1(E.map(F,function(d,e){return K._base._getTextBox(d,{font:P[e].series.font}).w},this),"Math.max(a, b)")/2,0>this.opt.labelOffset&&(g=Math.min(t-2*y,q-B)+this.opt.labelOffset));this.opt.hasOwnProperty("radius")&&(g=this.opt.radius<.9*g?this.opt.radius:.9*g);!this.opt.radius&&this.opt.labels&&
"columns"==this.opt.labelStyle?(g/=2,t>q&&t>2*g&&(g*=t/(2*g)),g>=.8*q&&(g=.8*q)):g>=.9*q&&(g=.9*q);var ea=g-this.opt.labelOffset;var b={cx:a.l+t,cy:a.t+q,r:g};this.dyn=[];var S=Array(D.length),m=[],n=C,V=this.opt.minWidth;N.forEach(D,function(d,e){if(0===d)m[e]={step:0,end:n,start:n,weak:!1};else{var c=n+2*d*Math.PI;e===D.length-1&&(c=L+2*Math.PI);var h=c-n;m[e]={step:h,start:n,end:c,weak:h*g<V};n=c}});if(0<V){y=0;var I=V/g;O=0;var l;for(l=m.length-1;0<=l;l--)m[l].weak&&(++y,O+=m[l].step,m[l].step=
I);I*=y;if(I>Math.PI){I=Math.PI/y;for(l=0;l<m.length;++l)m[l].weak&&(m[l].step=I);I=Math.PI}if(0<y)for(I=1-(I-O)/2/Math.PI,l=0;l<m.length;++l)m[l].weak||(m[l].step*=I);for(l=0;l<m.length;++l)m[l].start=l?m[l].end:n,m[l].end=m[l].start+m[l].step;for(l=m.length-1;0<=l;--l)if(0!==m[l].step){m[l].end=n+2*Math.PI;break}}n=C;var J,v;N.some(D,function(d,e){var c=M[e],h=P[e];if(1<=d){v=this._plotFill(h.series.fill,k,a);v=this._shapeFill(v,{x:b.cx-b.r,y:b.cy-b.r,width:2*b.r,height:2*b.r});v=this._pseudoRadialFill(v,
{x:b.cx,y:b.cy},b.r);var w=this._createRing(f,b).setFill(v).setStroke(h.series.stroke);this.dyn.push({fill:v,stroke:h.series.stroke});U&&(J={element:"slice",index:e,run:this.run,shape:w,x:e,y:"number"==typeof c?c:c.y,cx:b.cx,cy:b.cy,cr:g},this._connectEvents(J),S[e]=J);for(c=e+1;c<D.length;c++)h=P[c],this.dyn.push({fill:h.series.fill,stroke:h.series.stroke});return!0}if(0===m[e].step)return this.dyn.push({fill:h.series.fill,stroke:h.series.stroke}),!1;var r=m[e].step;w=b.cx+g*Math.cos(n);var x=b.cy+
g*Math.sin(n),A=b.cx+g*Math.cos(n+r),W=b.cy+g*Math.sin(n+r),G=ba._degToRad(this.opt.fanSize);if(h.series.fill&&"radial"===h.series.fill.type&&"fan"===this.opt.radGrad&&r>G){var X=f.createGroup();G=Math.ceil(r/G);var R=r/G;v=this._shapeFill(h.series.fill,{x:b.cx-b.r,y:b.cy-b.r,width:2*b.r,height:2*b.r});var H;for(H=0;H<G;++H){var Y=n+(H-.2)*R;var T=n+(H+1+.2)*R;var oa=0==H?w:b.cx+g*Math.cos(Y);var pa=0==H?x:b.cy+g*Math.sin(Y);var qa=H==G-1?A:b.cx+g*Math.cos(T);T=H==G-1?W:b.cy+g*Math.sin(T);this._createSlice(X,
b,g,oa,pa,qa,T,Y,R).setFill(this._pseudoRadialFill(v,{x:b.cx,y:b.cy},g,n+(H+.5)*R,n+(H+.5)*R))}G=h.series.stroke;this._createSlice(X,b,g,w,x,A,W,n,r).setStroke(G);w=X}else{G=h.series.stroke;w=this._createSlice(f,b,g,w,x,A,W,n,r).setStroke(G);if((v=h.series.fill)&&"radial"===v.type)v=this._shapeFill(v,{x:b.cx-b.r,y:b.cy-b.r,width:2*b.r,height:2*b.r}),"linear"===this.opt.radGrad&&(v=this._pseudoRadialFill(v,{x:b.cx,y:b.cy},g,n,n+r));else if(v&&"linear"===v.type){x=Q.clone(w.getBoundingBox());if("svg"===
K.renderer){A={w:0,h:0};try{A=aa.position(w.rawNode)}catch(va){}A.h>x.height&&(x.height=A.h);A.w>x.width&&(x.width=A.w)}v=this._plotFill(v,k,a);v=this._shapeFill(v,x)}w.setFill(v)}this.dyn.push({fill:v,stroke:h.series.stroke});U&&(J={element:"slice",index:e,run:this.run,shape:w,x:e,y:"number"==typeof c?c:c.y,cx:b.cx,cy:b.cy,cr:g},this._connectEvents(J),S[e]=J);n+=r;return!1},this);if(this.opt.labels){var ra=da("dojo-bidi")&&this.chart.isRightToLeft();if("default"==this.opt.labelStyle)n=C=L,N.some(D,
function(d,e){if(0>=d&&!this.opt.minWidth)return!1;var c=P[e];if(1<=d)return this.renderLabel(f,b.cx,b.cy+B/2,F[e],c,0<this.opt.labelOffset),!0;var h=C+2*d*Math.PI;e+1==D.length&&(h=L+2*Math.PI);if(this.opt.omitLabels&&.001>h-C)return!1;var w=n+m[e].step/2,r=b.cx+ea*Math.cos(w);this.renderLabel(f,ra?k.width-r:r,b.cy+ea*Math.sin(w)+B/2,F[e],c,0<this.opt.labelOffset);n+=m[e].step;C=h;return!1},this);else if("columns"==this.opt.labelStyle){var sa=this.opt.omitLabels;n=C=L;var Z=[],fa=0;for(y=D.length-
1;0<=y;--y)D[y]&&++fa;N.forEach(D,function(d,e){var c=C+2*d*Math.PI;e+1==D.length&&(c=L+2*Math.PI);if(0!==this.minWidth||.001<=c-C){var h=n+m[e].step/2;1!==fa||this.opt.minWidth||(h=(C+c)/2);Z.push({angle:h,left:0>Math.cos(h),theme:P[e],index:e,omit:sa?.001>c-C:!1})}C=c;n+=m[e].step},this);var ha=K._base._getTextBox("a",{font:u,whiteSpace:"nowrap"}).h;this._getProperLabelRadius(Z,ha,1.1*b.r);var ia=b.cx-2*b.r,ta=b.cx+2*b.r;N.forEach(Z,function(d){if(!d.omit){var e=P[d.index],c=0;e&&e.axis&&e.axis.tick&&
e.axis.tick.labelGap&&(c=e.axis.tick.labelGap);var h=K._base._getTextBox(F[d.index],{font:e.series.font,whiteSpace:"nowrap",paddingLeft:c+"px"}).w,w=b.cx+d.labelR*Math.cos(d.angle),r=b.cy+d.labelR*Math.sin(d.angle),x=d.left?ia+h:ta-h;c=d.left?ia:x+c;var A=b.r;A=f.createPath().moveTo(b.cx+A*Math.cos(d.angle),b.cy+A*Math.sin(d.angle));Math.abs(d.labelR*Math.cos(d.angle))<2*b.r-h&&A.lineTo(w,r);A.lineTo(x,r).setStroke(d.theme.series.labelWiring);A.moveToBack();w=this.renderLabel(f,c,ha/3+r||0,F[d.index],
e,!1,"left");U&&!this.opt.htmlLabels&&(e=K._base._getTextBox(F[d.index],{font:d.theme.series.font}).w||0,h=K.normalizedLength(K.splitFontString(d.theme.series.font).size),J={element:"labels",index:d.index,run:this.run,shape:w,x:c,y:r,label:F[d.index]},c=w.getShape(),r=aa.position(this.chart.node,!0),c=Q.mixin({type:"rect"},{x:c.x,y:c.y-2*h}),c.x+=r.x,c.y+=r.y,c.x=Math.round(c.x),c.y=Math.round(c.y),c.width=Math.ceil(e),c.height=Math.ceil(h),J.aroundRect=c,this._connectEvents(J),S[D.length+d.index]=
J)}},this)}}var ua=0;this._eventSeries[this.run.name]=E.map(M,function(d){return 0>=d?null:S[ua++]});da("dojo-bidi")&&this._checkOrientation(this.group,k,a);return this},_getProperLabelRadius:function(k,a,f){if(1==k.length)k[0].labelR=f;else{var p={},t={},q=2,g=2,u;for(u=0;u<k.length;++u){var B=Math.abs(Math.sin(k[u].angle));k[u].left?q>B&&(q=B,p=k[u]):g>B&&(g=B,t=k[u])}p.labelR=t.labelR=f;this._caculateLabelR(p,k,a);this._caculateLabelR(t,k,a)}},_caculateLabelR:function(k,a,f){var p,t=a.length,q=
k.labelR,g=a[k.index].left?-f:f;var u=0;f=k.index;for(p=(f+1)%t;u<t&&a[f].left===a[p].left;++u)q=(Math.sin(a[f].angle)*q+g)/Math.sin(a[p].angle),q=Math.max(k.labelR,q),a[p].labelR=q,f=(f+1)%t,p=(p+1)%t;u>=t&&(a[0].labelR=k.labelR);u=0;f=k.index;for(p=(f||t)-1;u<t&&a[f].left===a[p].left;++u)q=(Math.sin(a[f].angle)*q-g)/Math.sin(a[p].angle),q=Math.max(k.labelR,q),a[p].labelR=q,f=(f||t)-1,p=(p||t)-1},_createRing:function(k,a){var f=this.opt.innerRadius;0<f?f=f/100*a.r:0>f&&(f=-f);return f?k.createPath({}).setAbsoluteMode(!0).moveTo(a.cx,
a.cy-a.r).arcTo(a.r,a.r,0,!1,!0,a.cx+a.r,a.cy).arcTo(a.r,a.r,0,!0,!0,a.cx,a.cy-a.r).closePath().moveTo(a.cx,a.cy-f).arcTo(f,f,0,!1,!0,a.cx+f,a.cy).arcTo(f,f,0,!0,!0,a.cx,a.cy-f).closePath():k.createCircle(a)},_createSlice:function(k,a,f,p,t,q,g,u,B){var z=this.opt.innerRadius;0<z?z=z/100*a.r:0>z&&(z=-z);if(z){var L=a.cx+z*Math.cos(u),C=a.cy+z*Math.sin(u),F=a.cx+z*Math.cos(u+B);a=a.cy+z*Math.sin(u+B);return k.createPath({}).setAbsoluteMode(!0).moveTo(L,C).lineTo(p,t).arcTo(f,f,0,B>Math.PI,!0,q,g).lineTo(F,
a).arcTo(z,z,0,B>Math.PI,!1,L,C).closePath()}return k.createPath({}).setAbsoluteMode(!0).moveTo(a.cx,a.cy).lineTo(p,t).arcTo(f,f,0,B>Math.PI,!0,q,g).lineTo(a.cx,a.cy).closePath()}})});