You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
9.8 KiB
JavaScript
1 line
9.8 KiB
JavaScript
5 years ago
|
define("echarts/chart/bar",["require","./base","zrender/shape/Rectangle","../component/axis","../component/grid","../component/dataZoom","../config","../util/ecData","zrender/tool/util","zrender/tool/color","../chart"],function(e){function t(e,t,n,a,o){i.call(this,e,t,n,a,o),this.refresh(a)}var i=e("./base"),n=e("zrender/shape/Rectangle");e("../component/axis"),e("../component/grid"),e("../component/dataZoom");var a=e("../config");a.bar={zlevel:0,z:2,clickable:!0,legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,barMinHeight:0,barGap:"30%",barCategoryGap:"20%",itemStyle:{normal:{barBorderColor:"#fff",barBorderRadius:0,barBorderWidth:0,label:{show:!1}},emphasis:{barBorderColor:"#fff",barBorderRadius:0,barBorderWidth:0,label:{show:!1}}}};var o=e("../util/ecData"),r=e("zrender/tool/util"),s=e("zrender/tool/color");return t.prototype={type:a.CHART_TYPE_BAR,_buildShape:function(){this._buildPosition()},_buildNormal:function(e,t,i,o,r){for(var s,l,h,d,c,m,p,u,V,U,g,f,y=this.series,b=i[0][0],_=y[b],x="horizontal"==r,k=this.component.xAxis,v=this.component.yAxis,L=x?k.getAxis(_.xAxisIndex):v.getAxis(_.yAxisIndex),w=this._mapSize(L,i),W=w.gap,X=w.barGap,I=w.barWidthMap,S=w.barMaxWidthMap,K=w.barWidth,C=w.barMinHeightMap,T=w.interval,E=this.deepQuery([this.ecTheme,a],"island.r"),z=0,A=t;A>z&&null!=L.getNameByIndex(z);z++){x?d=L.getCoordByIndex(z)-W/2:c=L.getCoordByIndex(z)+W/2;for(var M=0,F=i.length;F>M;M++){var J=y[i[M][0]].yAxisIndex||0,P=y[i[M][0]].xAxisIndex||0;s=x?v.getAxis(J):k.getAxis(P),p=m=V=u=s.getCoord(0);for(var O=0,D=i[M].length;D>O;O++)b=i[M][O],_=y[b],g=_.data[z],f=this.getDataFromOption(g,"-"),o[b]=o[b]||{min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY,sum:0,counter:0,average:0},h=Math.min(S[b]||Number.MAX_VALUE,I[b]||K),"-"!==f&&(f>0?(l=O>0?s.getCoordSize(f):x?p-s.getCoord(f):s.getCoord(f)-p,1===D&&C[b]>l&&(l=C[b]),x?(m-=l,c=m):(d=m,m+=l)):0>f?(l=O>0?s.getCoordSize(f):x?s.getCoord(f)-V:V-s.getCoord(f),1===D&&C[b]>l&&(l=C[b]),x?(c=u,u+=l):(u-=l,d=u)):(l=0,x?(m-=l,c=m):(d=m,m+=l)),o[b][z]=x?d+h/2:c-h/2,o[b].min>f&&(o[b].min=f,x?(o[b].minY=c,o[b].minX=o[b][z]):(o[b].minX=d+l,o[b].minY=o[b][z])),o[b].max<f&&(o[b].max=f,x?(o[b].maxY=c,o[b].maxX=o[b][z]):(o[b].maxX=d+l,o[b].maxY=o[b][z])),o[b].sum+=f,o[b].counter++,z%T===0&&(U=this._getBarItem(b,z,L.getNameByIndex(z),d,c-(x?0:h),x?h:l,x?l:h,x?"vertical":"horizontal"),this.shapeList.push(new n(U))));for(var O=0,D=i[M].length;D>O;O++)b=i[M][O],_=y[b],g=_.data[z],f=this.getDataFromOption(g,"-"),h=Math.min(S[b]||Number.MAX_VALUE,I[b]||K),"-"==f&&this.deepQuery([g,_,this.option],"calculable")&&(x?(m-=E,c=m):(d=m,m+=E),U=this._getBarItem(b,z,L.getNameByIndex(z),d,c-(x?0:h),x?h:E,x?E:h,x?"vertical":"horizontal"),U.hoverable=!1,U.draggable=!1,U.style.lineWidth=1,U.style.brushType="stroke",U.style.strokeColor=_.calculableHolderColor||this.ecTheme.calculableHolderColor||a.calculableHolderColor,this.shapeList.push(new n(U)));x?d+=h+X:c-=h+X}}this._calculMarkMapXY(o,i,x?"y":"x")},_buildHorizontal:function(e,t,i,n){return this._buildNormal(e,t,i,n,"horizontal")},_buildVertical:function(e,t,i,n){return this._buildNormal(e,t,i,n,"vertical")},_buildOther:function(e,t,i,a){for(var o=this.series,r=0,s=i.length;s>r;r++)for(var l=0,h=i[r].length;h>l;l++){var d=i[r][l],c=o[d],m=c.xAxisIndex||0,p=this.component.xAxis.getAxis(m),u=p.getCoord(0),V=c.yAxisIndex||0,U=this.component.yAxis.getAxis(V),g=U.getCoord(0);a[d]=a[d]||{min0:Number.POSITIVE_INFINITY,min1:Number.POSITIVE_INFINITY,max0:Number.NEGATIVE_INFINITY,max1:Number.NEGATIVE_INFINITY,sum0:0,sum1:0,counter0:0,counter1:0,average0:0,average1:0};for(var f=0,y=c.data.length;y>f;f++){var b=c.data[f],_=this.getDataFromOption(b,"-");if(_ instanceof Array){var x,k,v=p.getCoord(_[0]),L=U.getCoord(_[1]),w=[b,c],W=this.deepQuery(w,"barWidth")||10,X=this.deepQuery(w,"barHeight");null!=X?(x="horizontal",_[0]>0?(W=v-u,v-=W):W=_[0]<0?u-v:0,k=this._getBarItem(d,f,_[0],v,L-X/2,W,X,x)):(x="vertical",_[1]>0?X=g-L:_[1]<0?(X=L-g,L-=X):X=0,k=this._getBarItem(d,f,_[0],v-W/2,L,W,X,x)),this.shapeList.push(new n(k)),v=p.getCoord(_[0]),L=U.getCoord(_[1]),a[
|