jumpserver/static/js/echarts/chart/pie.js

1 line
12 KiB
JavaScript
Raw Normal View History

2015-12-19 09:27:12 +00:00
define("echarts/chart/pie",["require","./base","zrender/shape/Text","zrender/shape/Ring","zrender/shape/Circle","zrender/shape/Sector","zrender/shape/Polyline","../config","../util/ecData","zrender/tool/util","zrender/tool/math","zrender/tool/color","../chart"],function(e){function t(e,t,n,a,o){i.call(this,e,t,n,a,o);var r=this;r.shapeHandler.onmouseover=function(e){var t=e.target,i=h.get(t,"seriesIndex"),n=h.get(t,"dataIndex"),a=h.get(t,"special"),o=[t.style.x,t.style.y],s=t.style.startAngle,l=t.style.endAngle,d=((l+s)/2+360)%360,c=t.highlightStyle.color,m=r.getLabel(i,n,a,o,d,c,!0);m&&r.zr.addHoverShape(m);var p=r.getLabelLine(i,n,o,t.style.r0,t.style.r,d,c,!0);p&&r.zr.addHoverShape(p)},this.refresh(a)}var i=e("./base"),n=e("zrender/shape/Text"),a=e("zrender/shape/Ring"),o=e("zrender/shape/Circle"),r=e("zrender/shape/Sector"),s=e("zrender/shape/Polyline"),l=e("../config");l.pie={zlevel:0,z:2,clickable:!0,legendHoverLink:!0,center:["50%","50%"],radius:[0,"75%"],clockWise:!0,startAngle:90,minAngle:0,selectedOffset:10,itemStyle:{normal:{borderColor:"rgba(0,0,0,0)",borderWidth:1,label:{show:!0,position:"outer"},labelLine:{show:!0,length:20,lineStyle:{width:1,type:"solid"}}},emphasis:{borderColor:"rgba(0,0,0,0)",borderWidth:1,label:{show:!1},labelLine:{show:!1,length:20,lineStyle:{width:1,type:"solid"}}}}};var h=e("../util/ecData"),d=e("zrender/tool/util"),c=e("zrender/tool/math"),m=e("zrender/tool/color");return t.prototype={type:l.CHART_TYPE_PIE,_buildShape:function(){var e=this.series,t=this.component.legend;this.selectedMap={},this._selected={};var i,n,r;this._selectedMode=!1;for(var s,d=0,c=e.length;c>d;d++)if(e[d].type===l.CHART_TYPE_PIE){if(e[d]=this.reformOption(e[d]),this.legendHoverLink=e[d].legendHoverLink||this.legendHoverLink,s=e[d].name||"",this.selectedMap[s]=t?t.isSelected(s):!0,!this.selectedMap[s])continue;i=this.parseCenter(this.zr,e[d].center),n=this.parseRadius(this.zr,e[d].radius),this._selectedMode=this._selectedMode||e[d].selectedMode,this._selected[d]=[],this.deepQuery([e[d],this.option],"calculable")&&(r={zlevel:e[d].zlevel,z:e[d].z,hoverable:!1,style:{x:i[0],y:i[1],r0:n[0]<=10?0:n[0]-10,r:n[1]+10,brushType:"stroke",lineWidth:1,strokeColor:e[d].calculableHolderColor||this.ecTheme.calculableHolderColor||l.calculableHolderColor}},h.pack(r,e[d],d,void 0,-1),this.setCalculable(r),r=n[0]<=10?new o(r):new a(r),this.shapeList.push(r)),this._buildSinglePie(d),this.buildMark(d)}this.addShapeList()},_buildSinglePie:function(e){for(var t,i=this.series,n=i[e],a=n.data,o=this.component.legend,r=0,s=0,l=0,h=Number.NEGATIVE_INFINITY,d=[],c=0,m=a.length;m>c;c++)t=a[c].name,this.selectedMap[t]=o?o.isSelected(t):!0,this.selectedMap[t]&&!isNaN(a[c].value)&&(0!==+a[c].value?r++:s++,l+=+a[c].value,h=Math.max(h,+a[c].value));if(0!==l){for(var p,u,g,V,U,y,f=100,_=n.clockWise,b=(n.startAngle.toFixed(2)-0+360)%360,x=n.minAngle||.01,k=360-x*r-.01*s,v=n.roseType,c=0,m=a.length;m>c;c++)if(t=a[c].name,this.selectedMap[t]&&!isNaN(a[c].value)){if(u=o?o.getColor(t):this.zr.getColor(c),f=a[c].value/l,p="area"!=v?_?b-f*k-(0!==f?x:.01):f*k+b+(0!==f?x:.01):_?b-360/m:360/m+b,p=p.toFixed(2)-0,f=(100*f).toFixed(2),g=this.parseCenter(this.zr,n.center),V=this.parseRadius(this.zr,n.radius),U=+V[0],y=+V[1],"radius"===v?y=a[c].value/h*(y-U)*.8+.2*(y-U)+U:"area"===v&&(y=Math.sqrt(a[c].value/h)*(y-U)+U),_){var L;L=b,b=p,p=L}this._buildItem(d,e,c,f,a[c].selected,g,U,y,b,p,u),_||(b=p)}this._autoLabelLayout(d,g,y);for(var c=0,m=d.length;m>c;c++)this.shapeList.push(d[c]);d=null}},_buildItem:function(e,t,i,n,a,o,r,s,l,d,c){var m=this.series,p=((d+l)/2+360)%360,u=this.getSector(t,i,n,a,o,r,s,l,d,c);h.pack(u,m[t],t,m[t].data[i],i,m[t].data[i].name,n),e.push(u);var g=this.getLabel(t,i,n,o,p,c,!1),V=this.getLabelLine(t,i,o,r,s,p,c,!1);V&&(h.pack(V,m[t],t,m[t].data[i],i,m[t].data[i].name,n),e.push(V)),g&&(h.pack(g,m[t],t,m[t].data[i],i,m[t].data[i].name,n),g._labelLine=V,e.push(g))},getSector:function(e,t,i,n,a,o,s,l,h,d){var p=this.series,u=p[e],g=u.data[t],V=[g,u],U=this.deepMerge(V,"itemStyle.normal")||{},y=this.deepMerge(V,"itemStyle.emphasis")||{}