//>>built
define("dojox/charting/plot2d/Spider","dojo/_base/lang dojo/_base/declare dojo/_base/connect dojo/_base/array dojo/dom-geometry dojo/_base/fx dojo/fx dojo/sniff ./Base ./_PlotEvents ./common ../axis2d/common dojox/gfx dojox/gfx/matrix dojox/gfx/fx dojox/lang/functional dojox/lang/utils dojo/fx/easing".split(" "),function(C,V,J,K,Q,L,W,M,X,Y,R,S,D,Z,ca,T,U,aa){return V("dojox.charting.plot2d.Spider",[X,Y],{defaultParams:{labels:!0,ticks:!1,fixed:!0,precision:1,labelOffset:-10,labelStyle:"default",
htmlLabels:!0,startAngle:-90,divisions:3,axisColor:"",axisWidth:0,spiderColor:"",spiderWidth:0,seriesWidth:0,seriesFillAlpha:.2,spiderOrigin:.16,markerSize:3,spiderType:"polygon",animationType:aa.backOut,animate:null,axisTickFont:"",axisTickFontColor:"",axisFont:"",axisFontColor:""},optionalParams:{radius:0,font:"",fontColor:""},constructor:function(a,e){this.opt=C.clone(this.defaultParams);U.updateWithObject(this.opt,e);U.updateWithPattern(this.opt,e,this.optionalParams);this.dyn=[];this.datas={};
this.labelKey=[];this.oldSeriePoints={};this.animate=null===this.opt.animate?{}:this.opt.animate;this.animations={}},clear:function(){this.inherited(arguments);this.dyn=[];this.axes=[];this.datas={};this.labelKey=[];this.oldSeriePoints={};this.animations={};return this},setAxis:function(a){a&&(void 0!=a.opt.min&&(this.datas[a.name].min=a.opt.min),void 0!=a.opt.max&&(this.datas[a.name].max=a.opt.max));return this},addSeries:function(a){this.series.push(a);for(var e in a.data){var c=a.data[e],h=this.datas[e];
h?(h.vlist.push(c),h.min=Math.min(h.min,c),h.max=Math.max(h.max,c)):(h="__"+e,this.axes.push(h),this[h]=e,this.datas[e]={min:c,max:c,vlist:[c]})}if(0>=this.labelKey.length)for(e in a.data)this.labelKey.push(e);return this},getSeriesStats:function(){return R.collectSimpleStats(this.series,function(a){return null===a})},render:function(a,e){if(!this.dirty)return this;this.dirty=!1;this.cleanGroup();var c=this.group,h=this.chart.theme;this.resetEvents();if(!this.series||!this.series.length)return this;
var b=this.opt,f=h.axis,d=(a.width-e.l-e.r)/2,k=(a.height-e.t-e.b)/2,m=Math.min(d,k),q=b.font||f.majorTick&&f.majorTick.font||f.tick&&f.tick.font||"normal normal normal 7pt Tahoma",p=b.axisFont||f.tick&&f.tick.titleFont||"normal normal normal 11pt Tahoma",w=b.axisTickFontColor||f.majorTick&&f.majorTick.fontColor||f.tick&&f.tick.fontColor||"silver",O=b.axisFontColor||f.tick&&f.tick.titleFontColor||"black",y=b.axisColor||f.tick&&f.tick.axisColor||"silver",l=b.spiderColor||f.tick&&f.tick.spiderColor||
"silver",ba=b.axisWidth||f.stroke&&f.stroke.width||2,z=b.spiderWidth||f.stroke&&f.stroke.width||2,f=b.seriesWidth||f.stroke&&f.stroke.width||2,t=D.normalizedLength(D.splitFontString(p).size),F=Z._degToRad(b.startAngle),C,u,N,v,r,A,x=b.spiderOrigin,E=3<=b.divisions?b.divisions:3,J=b.markerSize,L=b.spiderType,M=b.animationType,g=-10>b.labelOffset?b.labelOffset:-10,n;b.labels&&(m=K.map(this.series,function(a){return a.name},this),m=T.foldl1(T.map(m,function(a){return D._base._getTextBox(a,{font:h.series.font}).w},
this),"Math.max(a, b)")/2,m=Math.min(d-2*m,k-t)+g,C=m-g);"radius"in b&&(m=b.radius,C=m-g);m/=1.2;d={cx:e.l+d,cy:e.t+k,r:m};for(k=0;k<this.series.length;k++)if(n=this.series[k],this.dirty||n.dirty){if(n.cleanGroup(),g=n.data,null!==g&&(t=this._getObjectLength(g),!u||0>=u.length))if(u=[],N=[],A=[],this._buildPoints(u,t,d,m,F,!0,a),this._buildPoints(N,t,d,m*x,F,!0,a),this._buildPoints(A,t,d,C,F,!1,a),2<E)for(v=[],r=[],g=0;g<E-2;g++)v[g]=[],this._buildPoints(v[g],t,d,m*(x+(1-x)*(g+1)/(E-1)),F,!0,a),r[g]=
m*(x+(1-x)*(g+1)/(E-1))}else h.skip();t=c.createGroup();y={color:y,width:ba};k={color:l,width:z};for(g=u.length-1;0<=g;--g)l=u[g],z={x:l.x+.2*(l.x-d.cx),y:l.y+.2*(l.y-d.cy)},l={x:l.x+.2*(l.x-d.cx)/2,y:l.y+.2*(l.y-d.cy)/2},t.createLine({x1:d.cx,y1:d.cy,x2:z.x,y2:z.y}).setStroke(y),this._drawArrow(t,z,l,y);t=c.createGroup();for(g=A.length-1;0<=g;--g)l=A[g],z=D._base._getTextBox(this.labelKey[g],{font:p}).w||0,y=this.opt.htmlLabels&&"vml"!=D.renderer?"html":"gfx",l=S.createText[y](this.chart,t,Q.isBodyLtr()||
"html"!=y?l.x:l.x+z-a.width,l.y,"middle",this.labelKey[g],p,O),this.opt.htmlLabels&&this.htmlElements.push(l);p=c.createGroup();if("polygon"==L){if(p.createPolyline(u).setStroke(k),p.createPolyline(N).setStroke(k),0<v.length)for(g=v.length-1;0<=g;--g)p.createPolyline(v[g]).setStroke(k)}else if(p.createCircle({cx:d.cx,cy:d.cy,r:m}).setStroke(k),p.createCircle({cx:d.cx,cy:d.cy,r:m*x}).setStroke(k),0<r.length)for(g=r.length-1;0<=g;--g)p.createCircle({cx:d.cx,cy:d.cy,r:r[g]}).setStroke(k);t=this._getObjectLength(this.datas);
O=c.createGroup();v=0;for(var G in this.datas){r=this.datas[G];u=r.min;r=r.max;r-=u;p=F+2*Math.PI*v/t;for(k=0;k<E;k++)A=u+r*k/(E-1),l=this._getCoordinate(d,m*(x+(1-x)*k/(E-1)),p,a),A=this._getLabel(A),z=D._base._getTextBox(A,{font:q}).w||0,y=this.opt.htmlLabels&&"vml"!=D.renderer?"html":"gfx",this.opt.htmlLabels&&this.htmlElements.push(S.createText[y](this.chart,O,Q.isBodyLtr()||"html"!=y?l.x:l.x+z-a.width,l.y,"start",A,q,w));v++}this.chart.seriesShapes={};for(k=this.series.length-1;0<=k;k--)if(n=
this.series[k],g=n.data,null!==g){var q=h.next("spider",[b,n]),H=D.normalizeColor(q.series.fill),q={color:q.series.fill,width:f};H.a=b.seriesFillAlpha;n.dyn={fill:H,stroke:q};if(!n.hidden){var B=[],I=[];v=0;for(G in g)r=this.datas[G],u=r.min,r=r.max,r-=u,w=g[G],p=F+2*Math.PI*v/t,l=this._getCoordinate(d,m*(x+(1-x)*(w-u)/r),p,a),B.push(l),I.push({sname:n.name,key:G,data:w}),v++;B[B.length]=B[0];I[I.length]=I[0];var w=this._getBoundary(B),P=n.group,q=this._createSeriesEntry(P,this.oldSeriePoints[n.name]||
N,B,H,q,m,x,J,M);this.chart.seriesShapes[n.name]=q;this.oldSeriePoints[n.name]=B;this._connectEvents({element:"spider_poly",index:k,id:"spider_poly_"+n.name,run:n,plot:this,shape:q.poly,parent:P,brect:w,cx:d.cx,cy:d.cy,cr:m,f:H,s:c});this._connectEvents({element:"spider_plot",index:k,id:"spider_plot_"+n.name,run:n,plot:this,shape:n.group});K.forEach(q.circles,function(a,b){this._connectEvents({element:"spider_circle",index:b,id:"spider_circle_"+n.name+b,run:n,plot:this,shape:a,parent:P,tdata:I[b],
cx:B[b].x,cy:B[b].y,f:H,s:c})},this)}}return this},_createSeriesEntry:function(a,e,c,h,b,f,d,k,m){f=this.animate?e:c;var q=a.createPolyline(f).setFill(h).setStroke(b),p=[];for(d=0;d<f.length;d++){var w=f[d],w=a.createCircle({cx:w.x,cy:w.y,r:k}).setFill(h).setStroke(b);p.push(w)}this.animate&&(h=K.map(c,function(a,b){var c=new L.Animation(C.delegate({duration:1E3,easing:m,curve:[e[b].y,a.y]},this.animate)),d=p[b];J.connect(c,"onAnimate",function(a){var c=q.getShape();c.points[b].y=a;q.setShape(c);
c=d.getShape();c.cy=a;d.setShape(c)});return c},this),c=K.map(c,function(a,b){var c=new L.Animation(C.delegate({duration:1E3,easing:m,curve:[e[b].x,a.x]},this.animate)),d=p[b];J.connect(c,"onAnimate",function(a){var c=q.getShape();c.points[b].x=a;q.setShape(c);c=d.getShape();c.cx=a;d.setShape(c)});return c},this),W.combine(h.concat(c)).play());return{group:a,poly:q,circles:p}},plotEvent:function(a){"spider_plot"==a.element&&("onmouseover"!=a.type||M("ie")||a.shape.moveToFront())},tooltipFunc:function(a){return"spider_circle"==
a.element?a.tdata.sname+"\x3cbr/\x3e"+a.tdata.key+"\x3cbr/\x3e"+a.tdata.data:null},_getBoundary:function(a){for(var e=a[0].x,c=a[0].x,h=a[0].y,b=a[0].y,f=0;f<a.length;f++)var d=a[f],e=Math.max(d.x,e),h=Math.max(d.y,h),c=Math.min(d.x,c),b=Math.min(d.y,b);return{x:c,y:b,width:e-c,height:h-b}},_drawArrow:function(a,e,c,h){var b=Math.sqrt(Math.pow(c.x-e.x,2)+Math.pow(c.y-e.y,2)),f=(c.y-e.y)/b,d=(c.x-e.x)/b;a.createPolyline([e,{x:c.x+b/3*-f,y:c.y+b/3*d},{x:c.x+b/3*f,y:c.y+b/3*-d}]).setFill(h.color).setStroke(h)},
_buildPoints:function(a,e,c,h,b,f,d){for(var k=0;k<e;k++)a.push(this._getCoordinate(c,h,b+2*Math.PI*k/e,d));f&&a.push(this._getCoordinate(c,h,b+2*Math.PI,d))},_getCoordinate:function(a,e,c,h){var b=a.cx+e*Math.cos(c);M("dojo-bidi")&&this.chart.isRightToLeft()&&h&&(b=h.width-b);return{x:b,y:a.cy+e*Math.sin(c)}},_getObjectLength:function(a){var e=0;if(C.isObject(a))for(var c in a)e++;return e},_getLabel:function(a){return R.getLabel(a,this.opt.fixed,this.opt.precision)}})});