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