2 lines
61 KiB
JavaScript
2 lines
61 KiB
JavaScript
|
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(t){function e(t,e,o,s,n){i.call(this,t,e,o,s,n),this.refresh(s)}var i=t("./base"),o=t("zrender/shape/Rectangle");t("../component/axis"),t("../component/grid"),t("../component/dataZoom");var s=t("../config");s.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 n=t("../util/ecData"),r=t("zrender/tool/util"),a=t("zrender/tool/color");return e.prototype={type:s.CHART_TYPE_BAR,_buildShape:function(){this._buildPosition()},_buildNormal:function(t,e,i,n,r){for(var a,h,l,d,c,p,u,g,f,m,y,_,v=this.series,x=i[0][0],b=v[x],S="horizontal"==r,T=this.component.xAxis,z=this.component.yAxis,L=S?T.getAxis(b.xAxisIndex):z.getAxis(b.yAxisIndex),C=this._mapSize(L,i),w=C.gap,M=C.barGap,A=C.barWidthMap,E=C.barMaxWidthMap,k=C.barWidth,O=C.barMinHeightMap,I=C.interval,P=this.deepQuery([this.ecTheme,s],"island.r"),R=0,D=e;D>R&&null!=L.getNameByIndex(R);R++){S?d=L.getCoordByIndex(R)-w/2:c=L.getCoordByIndex(R)+w/2;for(var B=0,N=i.length;N>B;B++){var H=v[i[B][0]].yAxisIndex||0,Y=v[i[B][0]].xAxisIndex||0;a=S?z.getAxis(H):T.getAxis(Y),u=p=f=g=a.getCoord(0);for(var F=0,W=i[B].length;W>F;F++)x=i[B][F],b=v[x],y=b.data[R],_=this.getDataFromOption(y,"-"),n[x]=n[x]||{min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY,sum:0,counter:0,average:0},l=Math.min(E[x]||Number.MAX_VALUE,A[x]||k),"-"!==_&&(_>0?(h=F>0?a.getCoordSize(_):S?u-a.getCoord(_):a.getCoord(_)-u,1===W&&O[x]>h&&(h=O[x]),S?(p-=h,c=p):(d=p,p+=h)):0>_?(h=F>0?a.getCoordSize(_):S?a.getCoord(_)-f:f-a.getCoord(_),1===W&&O[x]>h&&(h=O[x]),S?(c=g,g+=h):(g-=h,d=g)):(h=0,S?(p-=h,c=p):(d=p,p+=h)),n[x][R]=S?d+l/2:c-l/2,n[x].min>_&&(n[x].min=_,S?(n[x].minY=c,n[x].minX=n[x][R]):(n[x].minX=d+h,n[x].minY=n[x][R])),n[x].max<_&&(n[x].max=_,S?(n[x].maxY=c,n[x].maxX=n[x][R]):(n[x].maxX=d+h,n[x].maxY=n[x][R])),n[x].sum+=_,n[x].counter++,R%I===0&&(m=this._getBarItem(x,R,L.getNameByIndex(R),d,c-(S?0:l),S?l:h,S?h:l,S?"vertical":"horizontal"),this.shapeList.push(new o(m))));for(var F=0,W=i[B].length;W>F;F++)x=i[B][F],b=v[x],y=b.data[R],_=this.getDataFromOption(y,"-"),l=Math.min(E[x]||Number.MAX_VALUE,A[x]||k),"-"==_&&this.deepQuery([y,b,this.option],"calculable")&&(S?(p-=P,c=p):(d=p,p+=P),m=this._getBarItem(x,R,L.getNameByIndex(R),d,c-(S?0:l),S?l:P,S?P:l,S?"vertical":"horizontal"),m.hoverable=!1,m.draggable=!1,m.style.lineWidth=1,m.style.brushType="stroke",m.style.strokeColor=b.calculableHolderColor||this.ecTheme.calculableHolderColor||s.calculableHolderColor,this.shapeList.push(new o(m)));S?d+=l+M:c-=l+M}}this._calculMarkMapXY(n,i,S?"y":"x")},_buildHorizontal:function(t,e,i,o){return this._buildNormal(t,e,i,o,"horizontal")},_buildVertical:function(t,e,i,o){return this._buildNormal(t,e,i,o,"vertical")},_buildOther:function(t,e,i,s){for(var n=this.series,r=0,a=i.length;a>r;r++)for(var h=0,l=i[r].length;l>h;h++){var d=i[r][h],c=n[d],p=c.xAxisIndex||0,u=this.component.xAxis.getAxis(p),g=u.getCoord(0),f=c.yAxisIndex||0,m=this.component.yAxis.getAxis(f),y=m.getCoord(0);s[d]=s[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 _=0,v=c.data.length;v>_;_++){var x=c.data[_],b=this.getDataFromOption(x,"-");if(b instanceof Array){var S,T,z=u.getCoord(b[0]),L=m.getCoord(b[1]),C=[x,c],w=this.deepQuery(C,"barWidth")||10,M=this.deepQuery(C,"barHeight");null!=M?(S="horizontal",b[0]>0?(w=z-g,z-=w):w=b[0]<0?g-z:0,T=this._getBarItem(d,_,b[0],z,L-M/2,w,M,S)):(S="vertical",b[1]>0?M=y-L:b[1]<0?(M=L-y,L-=M):M=0,T=this._getBarItem(d,_,b[0],z-w/2,L,w,M,S)),this.shapeList.push(new o(T)),z=u.getCoord(b[0]),L=m.getCoord(b[1]),s[
|
||
|
if("time"==d){p=c+u*this._zoom.end/100,c+=u*this._zoom.start/100;var g=a.getAutoFormatter(c,p).formatter;return{start:a.format(g,c),end:a.format(g,p)}}return{start:"",end:""}},__ondrift:function(t,e,i){this.zoomOption.zoomLock&&(t=this._fillerShae);var o="filler"==t._type?this._handleSize:0;if("horizontal"==this.zoomOption.orient?t.style.x+e-o<=this._location.x?t.style.x=this._location.x+o:t.style.x+e+t.style.width+o>=this._location.x+this._location.width?t.style.x=this._location.x+this._location.width-t.style.width-o:t.style.x+=e:t.style.y+i-o<=this._location.y?t.style.y=this._location.y+o:t.style.y+i+t.style.height+o>=this._location.y+this._location.height?t.style.y=this._location.y+this._location.height-t.style.height-o:t.style.y+=i,"filler"==t._type?this._syncHandleShape():this._syncFillerShape(),this.zoomOption.realtime&&this._syncData(),this.zoomOption.showDetail){var s=this._getDetail();this._startShape.style.text=this._startShape.highlightStyle.text=s.start,this._endShape.style.text=this._endShape.highlightStyle.text=s.end,this._startShape.style.textPosition=this._startShape.highlightStyle.textPosition,this._endShape.style.textPosition=this._endShape.highlightStyle.textPosition}return!0},__ondragend:function(){this.zoomOption.showDetail&&(this._startShape.style.text=this._endShape.style.text="=",this._startShape.style.textPosition=this._endShape.style.textPosition="inside",this.zr.modShape(this._startShape.id),this.zr.modShape(this._endShape.id),this.zr.refreshNextFrame()),this.isDragend=!0},ondragend:function(t,e){this.isDragend&&t.target&&(!this.zoomOption.realtime&&this._syncData(),e.dragOut=!0,e.dragIn=!0,this._isSilence||this.zoomOption.realtime||this.messageCenter.dispatch(r.EVENT.DATA_ZOOM,null,{zoom:this._zoom},this.myChart),e.needRefresh=!1,this.isDragend=!1)},ondataZoom:function(t,e){e.needRefresh=!0},absoluteZoom:function(t){this._zoom.start=t.start,this._zoom.end=t.end,this._zoom.start2=t.start2,this._zoom.end2=t.end2,this._syncShape(),this._syncData(!0)},rectZoom:function(t){if(!t)return this._zoom.start=this._zoom.start2=0,this._zoom.end=this._zoom.end2=100,this._syncShape(),this._syncData(!0),this._zoom;var e=this.component.grid.getArea(),i={x:t.x,y:t.y,width:t.width,height:t.height};if(i.width<0&&(i.x+=i.width,i.width=-i.width),i.height<0&&(i.y+=i.height,i.height=-i.height),i.x>e.x+e.width||i.y>e.y+e.height)return!1;i.x<e.x&&(i.x=e.x),i.x+i.width>e.x+e.width&&(i.width=e.x+e.width-i.x),i.y+i.height>e.y+e.height&&(i.height=e.y+e.height-i.y);var o,s=(i.x-e.x)/e.width,n=1-(i.x+i.width-e.x)/e.width,r=1-(i.y+i.height-e.y)/e.height,a=(i.y-e.y)/e.height;return"horizontal"==this.zoomOption.orient?(o=this._zoom.end-this._zoom.start,this._zoom.start+=o*s,this._zoom.end-=o*n,o=this._zoom.end2-this._zoom.start2,this._zoom.start2+=o*r,this._zoom.end2-=o*a):(o=this._zoom.end-this._zoom.start,this._zoom.start+=o*r,this._zoom.end-=o*a,o=this._zoom.end2-this._zoom.start2,this._zoom.start2+=o*s,this._zoom.end2-=o*n),this._syncShape(),this._syncData(!0),this._zoom},syncBackupData:function(t){for(var e,i,o=this._originalData.series,s=t.series,n=0,r=s.length;r>n;n++){i=s[n].data||s[n].eventList,e=o[n]?Math.floor(this._zoom.start/100*o[n].length):0;for(var a=0,h=i.length;h>a;a++)o[n]&&(o[n][a+e]=i[a])}},syncOption:function(t){this.silence(!0),this.option=t,this.option.dataZoom=this.reformOption(this.option.dataZoom),this.zoomOption=this.option.dataZoom,this.clear(),this._location=this._getLocation(),this._zoom=this._getZoom(),this._backupData(),this.option.dataZoom&&this.option.dataZoom.show&&this._buildShape(),this._syncData(),this.silence(!1)},silence:function(t){this._isSilence=t},getRealDataIndex:function(t,e){if(!this._originalData||0===this._zoom.start&&100==this._zoom.end)return e;var i=this._originalData.series;return i[t]?Math.floor(this._zoom.start/100*i[t].length)+e:-1},resize:function(){this.clear(),this._location=this._getLocation(),this._zoom=this._getZoom(),this.option.dataZoom.show&&this._buildShape()}},h.inherits(e,i),t("../component").define("dataZoom",e),e}),define("echarts/component/categoryAxis",["
|