radar.js 6.3 KB

1234567891011
  1. (function(){var d=window.AmCharts;d.AmRadarChart=d.Class({inherits:d.AmCoordinateChart,construct:function(a){this.type="radar";d.AmRadarChart.base.construct.call(this,a);this.cname="AmRadarChart";this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=0;this.radius="35%";d.applyTheme(this,a,this.cname)},initChart:function(){d.AmRadarChart.base.initChart.call(this);if(this.dataChanged)this.parseData();else this.onDataUpdated()},onDataUpdated:function(){this.drawChart()},updateGraphs:function(){var a=
  2. this.graphs,b;for(b=0;b<a.length;b++){var c=a[b];c.index=b;c.width=this.realRadius;c.height=this.realRadius;c.x=this.marginLeftReal;c.y=this.marginTopReal;c.data=this.chartData}},parseData:function(){d.AmRadarChart.base.parseData.call(this);this.parseSerialData(this.dataProvider)},updateValueAxes:function(){var a=this.valueAxes,b;for(b=0;b<a.length;b++){var c=a[b];c.axisRenderer=d.RadAxis;c.guideFillRenderer=d.RadarFill;c.axisItemRenderer=d.RadItem;c.autoGridCount=!1;c.rMultiplier=1;c.x=this.marginLeftReal;
  3. c.y=this.marginTopReal;c.width=this.realRadius;c.height=this.realRadius;c.marginsChanged=!0;c.titleDY=c.y}},drawChart:function(){d.AmRadarChart.base.drawChart.call(this);var a=this.updateWidth(),b=this.updateHeight(),c=this.marginTop+this.getTitleHeight(),f=this.marginLeft,m=this.marginBottom,n=this.marginRight,e=b-c-m;this.marginLeftReal=f+(a-f-n)/2;this.marginTopReal=c+e/2;this.realRadius=d.toCoordinate(this.radius,Math.min(a-f-n,b-c-m),e);this.updateValueAxes();this.updateGraphs();a=this.chartData;
  4. if(d.ifArray(a)){if(0<this.realWidth&&0<this.realHeight){a=a.length-1;c=this.valueAxes;for(b=0;b<c.length;b++)c[b].zoom(0,a);c=this.graphs;for(b=0;b<c.length;b++)c[b].zoom(0,a);(a=this.legend)&&a.invalidateSize()}}else this.cleanChart();this.dispDUpd();this.gridSet.toBack();this.axesSet.toBack();this.set.toBack()},formatString:function(a,b,c){var f=b.graph;-1!=a.indexOf("[[category]]")&&(a=a.replace(/\[\[category\]\]/g,String(b.serialDataItem.category)));f=f.numberFormatter;f||(f=this.nf);a=d.formatValue(a,
  5. b.values,["value"],f,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);-1!=a.indexOf("[[")&&(a=d.formatDataContextValue(a,b.dataContext));return a=d.AmRadarChart.base.formatString.call(this,a,b,c)},cleanChart:function(){d.callMethod("destroy",[this.valueAxes,this.graphs])}})})();(function(){var d=window.AmCharts;d.RadAxis=d.Class({construct:function(a){var b=a.chart,c=a.axisThickness,f=a.axisColor,m=a.axisAlpha;this.set=b.container.set();this.set.translate(a.x,a.y);b.axesSet.push(this.set);var n=a.axisTitleOffset,e=a.radarCategoriesEnabled,r=a.chart.fontFamily,h=a.fontSize;void 0===h&&(h=a.chart.fontSize);var k=a.color;void 0===k&&(k=a.chart.color);if(b){this.axisWidth=a.height;var p=b.chartData,l=p.length,w,z=this.axisWidth;"middle"==a.pointPosition&&"circles"!=a.gridType&&
  6. (a.rMultiplier=Math.cos(180/l*Math.PI/180),z*=a.rMultiplier);for(w=0;w<l;w++){var q=180-360/l*w,g=q;"middle"==a.pointPosition&&(g-=180/l);var t=this.axisWidth*Math.sin(q/180*Math.PI),q=this.axisWidth*Math.cos(q/180*Math.PI);0<m&&(t=d.line(b.container,[0,t],[0,q],f,m,c),this.set.push(t),d.setCN(b,t,a.bcn+"line"));if(e){var x="start",t=(z+n)*Math.sin(g/180*Math.PI),q=(z+n)*Math.cos(g/180*Math.PI);if(180==g||0===g)x="middle",t-=5;0>g&&(x="end",t-=10);180==g&&(q-=5);0===g&&(q+=5);g=d.text(b.container,
  7. p[w].category,k,r,h,x);g.translate(t+5,q);this.set.push(g);d.setCN(b,g,a.bcn+"title")}}}}})})();(function(){var d=window.AmCharts;d.RadItem=d.Class({construct:function(a,b,c,f,m,n,e,r){f=a.chart;void 0===c&&(c="");var h=a.chart.fontFamily,k=a.fontSize;void 0===k&&(k=a.chart.fontSize);var p=a.color;void 0===p&&(p=a.chart.color);var l=a.chart.container;this.set=m=l.set();var w=a.axisColor,z=a.axisAlpha,q=a.tickLength,g=a.gridAlpha,t=a.gridThickness,x=a.gridColor,D=a.dashLength,E=a.fillColor,B=a.fillAlpha,F=a.labelsEnabled;n=a.counter;var G=a.inside,H=a.gridType,u,J=a.labelOffset,A;b-=a.height;
  8. var y;e?(F=!0,void 0!==e.id&&(A=f.classNamePrefix+"-guide-"+e.id),isNaN(e.tickLength)||(q=e.tickLength),void 0!=e.lineColor&&(x=e.lineColor),isNaN(e.lineAlpha)||(g=e.lineAlpha),isNaN(e.dashLength)||(D=e.dashLength),isNaN(e.lineThickness)||(t=e.lineThickness),!0===e.inside&&(G=!0),void 0!==e.boldLabel&&(r=e.boldLabel)):c||(g/=3,q/=2);var I="end",C=-1;G&&(I="start",C=1);var v;F&&(v=d.text(l,c,p,h,k,I,r),v.translate((q+3+J)*C,b),m.push(v),d.setCN(f,v,a.bcn+"label"),e&&d.setCN(f,v,"guide"),d.setCN(f,
  9. v,A,!0),this.label=v,y=d.line(l,[0,q*C],[b,b],w,z,t),m.push(y),d.setCN(f,y,a.bcn+"tick"),e&&d.setCN(f,y,"guide"),d.setCN(f,y,A,!0));b=Math.abs(b);r=[];h=[];if(0<g){if("polygons"==H){u=a.data.length;for(k=0;k<u;k++)p=180-360/u*k,r.push(b*Math.sin(p/180*Math.PI)),h.push(b*Math.cos(p/180*Math.PI));r.push(r[0]);h.push(h[0]);g=d.line(l,r,h,x,g,t,D)}else g=d.circle(l,b,"#FFFFFF",0,t,x,g);m.push(g);d.setCN(f,g,a.bcn+"grid");d.setCN(f,g,A,!0);e&&d.setCN(f,g,"guide")}if(1==n&&0<B&&!e&&""!==c){e=a.previousCoord;
  10. if("polygons"==H){for(k=u;0<=k;k--)p=180-360/u*k,r.push(e*Math.sin(p/180*Math.PI)),h.push(e*Math.cos(p/180*Math.PI));u=d.polygon(l,r,h,E,B)}else u=d.wedge(l,0,0,0,360,b,b,e,0,{fill:E,"fill-opacity":B,stroke:"#000","stroke-opacity":0,"stroke-width":1});m.push(u);d.setCN(f,u,a.bcn+"fill");d.setCN(f,u,A,!0)}!1===a.visible&&(y&&y.hide(),v&&v.hide());""!==c&&(a.counter=0===n?1:0,a.previousCoord=b)},graphics:function(){return this.set},getLabel:function(){return this.label}})})();(function(){var d=window.AmCharts;d.RadarFill=d.Class({construct:function(a,b,c,f){b-=a.axisWidth;c-=a.axisWidth;var m=Math.min(b,c);c=Math.max(b,c);b=a.chart;var n=b.container,e=f.fillAlpha,r=f.fillColor;c=Math.abs(c);var m=Math.abs(m),h=Math.min(c,m);c=Math.max(c,m);var m=h,h=f.angle+90,k=f.toAngle+90;isNaN(h)&&(h=0);isNaN(k)&&(k=360);this.set=n.set();void 0===r&&(r="#000000");isNaN(e)&&(e=0);if("polygons"==a.gridType){var k=[],p=[];a=a.data.length;var l;for(l=0;l<a;l++)h=180-360/a*l,k.push(c*Math.sin(h/
  11. 180*Math.PI)),p.push(c*Math.cos(h/180*Math.PI));k.push(k[0]);p.push(p[0]);for(l=a;0<=l;l--)h=180-360/a*l,k.push(m*Math.sin(h/180*Math.PI)),p.push(m*Math.cos(h/180*Math.PI));n=d.polygon(n,k,p,r,e)}else n=d.wedge(n,0,0,h,k-h,c,c,m,0,{fill:r,"fill-opacity":e,stroke:"#000","stroke-opacity":0,"stroke-width":1});d.setCN(b,n,"guide-fill");f.id&&d.setCN(b,n,"guide-fill-"+f.id);this.set.push(n);this.fill=n},graphics:function(){return this.set},getLabel:function(){}})})();