1 |
- 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".split(" "),function(d){function q(b,a,c,e,g){x.call(this,b,a,c,e,g);this.refresh(e)}var x=d("./base"),y=d("../util/shape/GaugePointer"),p=d("zrender/shape/Text"),k=d("zrender/shape/Line"),u=d("zrender/shape/Rectangle"),l=d("zrender/shape/Circle"),n=d("zrender/shape/Sector"),r=d("../config");r.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 w=d("../util/ecData"),z=d("../util/accMath"),A=d("zrender/tool/util");return q.prototype={type:r.CHART_TYPE_GAUGE,_buildShape:function(){var b=this.series;this._paramsMap={};for(var a=0,c=b.length;c>a;a++)b[a].type===r.CHART_TYPE_GAUGE&&(b[a]=this.reformOption(b[a]),this.legendHoverLink=b[a].legendHoverLink||this.legendHoverLink,this._buildSingleGauge(a),this.buildMark(a));this.addShapeList()},_buildSingleGauge:function(b){var a=this.series[b];this._paramsMap[b]={center:this.parseCenter(this.zr,a.center),radius:this.parseRadius(this.zr,a.radius),startAngle:a.startAngle.toFixed(2)-0,endAngle:a.endAngle.toFixed(2)-0};this._paramsMap[b].totalAngle=this._paramsMap[b].startAngle-this._paramsMap[b].endAngle;this._colorMap(b);this._buildAxisLine(b);this._buildSplitLine(b);this._buildAxisTick(b);this._buildAxisLabel(b);this._buildPointer(b);this._buildTitle(b);this._buildDetail(b)},_buildAxisLine:function(b){var a=this.series[b];if(a.axisLine.show){var c,e,g=a.min,h=a.max-g,f=this._paramsMap[b],p=f.center,k=f.startAngle,m=f.totalAngle,d=f.colorArray,a=a.axisLine.lineStyle;c=this.parsePercent(a.width,f.radius[1]);for(var f=f.radius[1],l=f-c,v=k,t=0,n=d.length;n>t;t++)e=k-m*(d[t][0]-g)/h,c=this._getSector(p,l,f,e,v,d[t][1],a),v=e,c._animationAdd="r",w.set(c,"seriesIndex",b),w.set(c,"dataIndex",t),this.shapeList.push(c)}},_buildSplitLine:function(b){var a=this.series[b];if(a.splitLine.show){var c,e,g=this._paramsMap[b],h=a.splitNumber,f=a.min,p=a.max-f,a=a.splitLine;e=this.parsePercent(a.length,g.radius[1]);for(var a=a.lineStyle,d=a.color,m=g.center,l=g.startAngle*Math.PI/180,n=g.totalAngle*Math.PI/180,g=g.radius[1],v=g-e,t=0;h>=t;t++)c=l-n/h*t,e=Math.sin(c),c=Math.cos(c),this.shapeList.push(new k({zlevel:this.getZlevelBase(),z:this.getZBase()+1,hoverable:!1,style:{xStart:m[0]+c*g,yStart:m[1]-e*g,xEnd:m[0]+c*v,yEnd:m[1]-e*v,strokeColor:"auto"===d?this._getColor(b,f+p/h*t):d,lineType:a.type,lineWidth:a.width,shadowColor:a.shadowColor,shadowBlur:a.shadowBlur,shadowOffsetX:a.shadowOffsetX,shadowOffsetY:a.shadowOffsetY}}))}},_buildAxisTick:function(b){var a=this.series[b];if(a.axisTick.show)for(var c,e,g,h=this._paramsMap[b],f=a.splitNumber,p=a.min,d=a.max-p,m=a.axisTick,a=m.splitNumber,l=this.parsePercent(m.length,h.radius[1]),m=m.lineStyle,n=m.color,v=h.center,t=h.startAngle*Math.PI/180,u=h.totalAngle*Math.PI/180,h=h.radius[1],l=h-l,r=0,f=f*a;f>=r;r++)0!==r%a&&(c=t-u/f*r,e=Math.sin(c),g=Math.cos(c),this.shapeList.push(new k({zlevel:this.getZlevelBase(),z:this.getZBase()+1,hoverable:!1,style:{xStart:v[0]+g*h,yStart:v[1]-e*h,xEnd:v[0]+g*l,yEnd:v[1]-e*l,strokeColor:"auto"===n?this._getColor(b,p+d/f*r):n,lineType:m.type,lineWidth:m.width,shadowColor:m.shadowColor,shadowBlur:m.shadowBlur,shadowOffsetX:m.shadowOffsetX,shadowOffsetY:m.shadowOffsetY}})))},_buildAxisLabel:function(b){var a=this.series[b];if(a.axisLabel.show){var c,e,g,h,f=a.splitNumber,d=a.min,k=a.max-d,m=a.axisLabel.textStyle,l=this.getFont(m),n=m.color;c=this._paramsMap[b];for(var r=c.center,t=c.startAngle,u=c.totalAngle,q=c.radius[1]-this.parsePercent(a.splitLine.length,c.radius[1])-5,w=0;f>=w;w++)h=z.accAdd(d,z.accMul(z.accDiv(k,f),w)),c=t-u/f*w,e=Math.sin(c*Math.PI/180),g=Math.cos(c*Math.PI/180),c=(c+360)%360,this.shapeList.push(new p({zlevel:this.getZlevelBase(),z:this.getZBase()+1,hoverable:!1,style:{x:r[0]+g*q,y:r[1]-e*q,color:"auto"===n?this._getColor(b,h):n,text:this._getLabelText(a.axisLabel.formatter,h),textAlign:110<=c&&250>=c?"left":70>=c||290<=c?"right":"center",textBaseline:10<=c&&170>=c?"top":190<=c&&350>=c?"bottom":"middle",textFont:l,shadowColor:m.shadowColor,shadowBlur:m.shadowBlur,shadowOffsetX:m.shadowOffsetX,shadowOffsetY:m.shadowOffsetY}}))}},_buildPointer:function(b){var a=this.series[b];if(a.pointer.show){var c=a.max-a.min,e=a.pointer,g=this._paramsMap[b],h=this.parsePercent(e.length,g.radius[1]),f=this.parsePercent(e.width,g.radius[1]),p=g.center,d=this._getValue(b),d=d<a.max?d:a.max,c=(g.startAngle-g.totalAngle/c*(d-a.min))*Math.PI/180,k="auto"===e.color?this._getColor(b,d):e.color,a=new y({zlevel:this.getZlevelBase(),z:this.getZBase()+1,clickable:this.query(a,"clickable"),style:{x:p[0],y:p[1],r:h,startAngle:g.startAngle*Math.PI/180,angle:c,color:k,width:f,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},highlightStyle:{brushType:"fill",width:2<f?2:f/2,color:"#fff"}});w.pack(a,this.series[b],b,this.series[b].data[0],0,this.series[b].data[0].name,d);this.shapeList.push(a);this.shapeList.push(new l({zlevel:this.getZlevelBase(),z:this.getZBase()+2,hoverable:!1,style:{x:p[0],y:p[1],r:e.width/2.5,color:"#fff"}}))}},_buildTitle:function(b){var a=this.series[b];if(a.title.show){var c=a.data[0],c=null!=c.name?c.name:"";if(""!==c){var e=a.title,a=e.offsetCenter,e=e.textStyle,g=e.color,h=this._paramsMap[b],f=h.center[0]+this.parsePercent(a[0],h.radius[1]),a=h.center[1]+this.parsePercent(a[1],h.radius[1]);this.shapeList.push(new p({zlevel:this.getZlevelBase(),z:this.getZBase()+(Math.abs(f-h.center[0])+Math.abs(a-h.center[1])<2*e.fontSize?2:1),hoverable:!1,style:{x:f,y:a,color:"auto"===g?this._getColor(b):g,text:c,textAlign:"center",textFont:this.getFont(e),shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY}}))}}},_buildDetail:function(b){var a=this.series[b];if(a.detail.show){var a=a.detail,c=a.offsetCenter,e=a.backgroundColor,g=a.textStyle,h=g.color,f=this._paramsMap[b],d=this._getValue(b),p=f.center[0]-a.width/2+this.parsePercent(c[0],f.radius[1]),c=f.center[1]+this.parsePercent(c[1],f.radius[1]);this.shapeList.push(new u({zlevel:this.getZlevelBase(),z:this.getZBase()+(Math.abs(p+a.width/2-f.center[0])+Math.abs(c+a.height/2-f.center[1])<g.fontSize?2:1),hoverable:!1,style:{x:p,y:c,width:a.width,height:a.height,brushType:"both",color:"auto"===e?this._getColor(b,d):e,lineWidth:a.borderWidth,strokeColor:a.borderColor,shadowColor:a.shadowColor,shadowBlur:a.shadowBlur,shadowOffsetX:a.shadowOffsetX,shadowOffsetY:a.shadowOffsetY,text:this._getLabelText(a.formatter,d),textFont:this.getFont(g),textPosition:"inside",textColor:"auto"===h?this._getColor(b,d):h}}))}},_getValue:function(b){return this.getDataFromOption(this.series[b].data[0])},_colorMap:function(b){var a=this.series[b],c=a.min,e=a.max-c,a=a.axisLine.lineStyle.color;a instanceof Array||(a=[[1,a]]);for(var g=[],d=0,f=a.length;f>d;d++)g.push([a[d][0]*e+c,a[d][1]]);this._paramsMap[b].colorArray=g},_getColor:function(b,a){null==a&&(a=this._getValue(b));for(var c=this._paramsMap[b].colorArray,e=0,d=c.length;d>e;e++)if(c[e][0]>=a)return c[e][1];return c[c.length-1][1]},_getSector:function(b,a,c,e,d,p,f){return new n({zlevel:this.getZlevelBase(),z:this.getZBase(),hoverable:!1,style:{x:b[0],y:b[1],r0:a,r:c,startAngle:e,endAngle:d,brushType:"fill",color:p,shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}})},_getLabelText:function(b,a){if(b){if("function"==typeof b)return b.call(this.myChart,a);if("string"==typeof b)return b.replace("{value}",a)}return a},refresh:function(b){b&&(this.option=b,this.series=b.series);this.backupShapeList();this._buildShape()}},A.inherits(q,x),d("../chart").define("gauge",q),q});define("echarts/util/shape/GaugePointer",["require","zrender/shape/Base","zrender/tool/util","./normalIsCover"],function(d){function q(d){x.call(this,d)}var x=d("zrender/shape/Base"),y=d("zrender/tool/util");return q.prototype={type:"gauge-pointer",buildPath:function(d,k){var u=k.r,l=k.width,n=k.angle,r=k.x-Math.cos(n)*l*(l>=u/3?1:2),q=k.y+Math.sin(n)*l*(l>=u/3?1:2),n=k.angle-Math.PI/2;d.moveTo(r,q);d.lineTo(k.x+Math.cos(n)*l,k.y-Math.sin(n)*l);d.lineTo(k.x+Math.cos(k.angle)*u,k.y-Math.sin(k.angle)*u);d.lineTo(k.x-Math.cos(n)*l,k.y+Math.sin(n)*l);d.lineTo(r,q)},getRect:function(d){if(d.__rect)return d.__rect;var k=2*d.width,q=d.x,l=d.y,n=q+Math.cos(d.angle)*d.r,r=l-Math.sin(d.angle)*d.r;return d.__rect={x:Math.min(q,n)-k,y:Math.min(l,r)-k,width:Math.abs(q-n)+k,height:Math.abs(l-r)+k},d.__rect},isCover:d("./normalIsCover")},y.inherits(q,x),q});
|