bkjxxxw/WebContent/static/echarts-2.2.7/doc/slide/js/dist/chart/gauge.js

1 line
9.2 KiB
JavaScript
Raw Normal View History

2024-03-18 10:04:33 +08:00
define("echarts/chart/gauge",["require","./base","../util/shape/GaugePointer","zrender/shape/Text","zrender/shape/Line","zrender/shape/Rectangle","zrender/shape/Circle","zrender/shape/Sector","../config","../util/ecData","../util/accMath","zrender/tool/util","../chart"],function(t){function e(t,e,s,o,a){i.call(this,t,e,s,o,a),this.refresh(o)}var i=t("./base"),s=t("../util/shape/GaugePointer"),o=t("zrender/shape/Text"),a=t("zrender/shape/Line"),n=t("zrender/shape/Rectangle"),r=t("zrender/shape/Circle"),h=t("zrender/shape/Sector"),l=t("../config");l.gauge={zlevel:0,z:2,center:["50%","50%"],clickable:!0,legendHoverLink:!0,radius:"80%",startAngle:225,endAngle:-45,min:0,max:100,precision:0,splitNumber:10,axisLine:{show:!0,lineStyle:{color:[[.2,"#228b22"],[.8,"#48b"],[1,"#ff4500"]],width:20}},axisTick:{show:!0,splitNumber:5,length:8,lineStyle:{color:"#eee",width:1,type:"solid"}},axisLabel:{show:!0,textStyle:{color:"auto"}},splitLine:{show:!0,length:20,lineStyle:{color:"#eee",width:2,type:"solid"}},pointer:{show:!0,length:"80%",width:8,color:"auto"},title:{show:!0,offsetCenter:[0,"-35%"],textStyle:{color:"#333",fontSize:15}},detail:{show:!0,backgroundColor:"rgba(0,0,0,0)",borderWidth:0,borderColor:"#ccc",width:100,height:40,offsetCenter:[0,"50%"],textStyle:{color:"auto",fontSize:30}}};var d=t("../util/ecData"),p=t("../util/accMath"),c=t("zrender/tool/util");return e.prototype={type:l.CHART_TYPE_GAUGE,_buildShape:function(){var t=this.series;this._paramsMap={};for(var e=0,i=t.length;i>e;e++)t[e].type===l.CHART_TYPE_GAUGE&&(t[e]=this.reformOption(t[e]),this.legendHoverLink=t[e].legendHoverLink||this.legendHoverLink,this._buildSingleGauge(e),this.buildMark(e));this.addShapeList()},_buildSingleGauge:function(t){var e=this.series[t];this._paramsMap[t]={center:this.parseCenter(this.zr,e.center),radius:this.parseRadius(this.zr,e.radius),startAngle:e.startAngle.toFixed(2)-0,endAngle:e.endAngle.toFixed(2)-0},this._paramsMap[t].totalAngle=this._paramsMap[t].startAngle-this._paramsMap[t].endAngle,this._colorMap(t),this._buildAxisLine(t),this._buildSplitLine(t),this._buildAxisTick(t),this._buildAxisLabel(t),this._buildPointer(t),this._buildTitle(t),this._buildDetail(t)},_buildAxisLine:function(t){var e=this.series[t];if(e.axisLine.show)for(var i,s,o=e.min,a=e.max-o,n=this._paramsMap[t],r=n.center,h=n.startAngle,l=n.totalAngle,p=n.colorArray,c=e.axisLine.lineStyle,u=this.parsePercent(c.width,n.radius[1]),g=n.radius[1],f=g-u,y=h,m=0,_=p.length;_>m;m++)s=h-l*(p[m][0]-o)/a,i=this._getSector(r,f,g,s,y,p[m][1],c),y=s,i._animationAdd="r",d.set(i,"seriesIndex",t),d.set(i,"dataIndex",m),this.shapeList.push(i)},_buildSplitLine:function(t){var e=this.series[t];if(e.splitLine.show)for(var i,s,o,n=this._paramsMap[t],r=e.splitNumber,h=e.min,l=e.max-h,d=e.splitLine,p=this.parsePercent(d.length,n.radius[1]),c=d.lineStyle,u=c.color,g=n.center,f=n.startAngle*Math.PI/180,y=n.totalAngle*Math.PI/180,m=n.radius[1],_=m-p,x=0;r>=x;x++)i=f-y/r*x,s=Math.sin(i),o=Math.cos(i),this.shapeList.push(new a({zlevel:this.getZlevelBase(),z:this.getZBase()+1,hoverable:!1,style:{xStart:g[0]+o*m,yStart:g[1]-s*m,xEnd:g[0]+o*_,yEnd:g[1]-s*_,strokeColor:"auto"===u?this._getColor(t,h+l/r*x):u,lineType:c.type,lineWidth:c.width,shadowColor:c.shadowColor,shadowBlur:c.shadowBlur,shadowOffsetX:c.shadowOffsetX,shadowOffsetY:c.shadowOffsetY}}))},_buildAxisTick:function(t){var e=this.series[t];if(e.axisTick.show)for(var i,s,o,n=this._paramsMap[t],r=e.splitNumber,h=e.min,l=e.max-h,d=e.axisTick,p=d.splitNumber,c=this.parsePercent(d.length,n.radius[1]),u=d.lineStyle,g=u.color,f=n.center,y=n.startAngle*Math.PI/180,m=n.totalAngle*Math.PI/180,_=n.radius[1],x=_-c,v=0,b=r*p;b>=v;v++)v%p!==0&&(i=y-m/b*v,s=Math.sin(i),o=Math.cos(i),this.shapeList.push(new a({zlevel:this.getZlevelBase(),z:this.getZBase()+1,hoverable:!1,style:{xStart:f[0]+o*_,yStart:f[1]-s*_,xEnd:f[0]+o*x,yEnd:f[1]-s*x,strokeColor:"auto"===g?this._getColor(t,h+l/b*v):g,lineType:u.type,lineWidth:u.width,shadowColor:u.shadowColor,shadowBlur:u.shadowBlur,shadowOffsetX:u.shadowOffsetX,shadowOffsetY:u.shadowOffsetY}})))},_buildAxisLabel:f