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