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

3 lines
64 KiB
JavaScript
Raw Normal View History

2024-03-18 10:04:33 +08:00
define("echarts/chart/line",["require","./base","zrender/shape/Polyline","../util/shape/Icon","../util/shape/HalfSmoothPolygon","../component/axis","../component/grid","../component/dataZoom","../config","../util/ecData","zrender/tool/util","zrender/tool/color","../chart"],function(t){function e(t,e,i,s,n){o.call(this,t,e,i,s,n),this.refresh(s)}function i(t,e,i){var o=e.x,s=e.y,r=e.width,a=e.height,h=a/2;e.symbol.match("empty")&&(t.fillStyle="#fff"),e.brushType="both";var l=e.symbol.replace("empty","").toLowerCase();l.match("star")?(h=l.replace("star","")-0||5,s-=1,l="star"):("rectangle"===l||"arrow"===l)&&(o+=(r-a)/2,r=a);var d="";if(l.match("image")&&(d=l.replace(new RegExp("^image:\\/\\/"),""),l="image",o+=Math.round((r-a)/2)-1,r=a+=2),l=n.prototype.iconLibrary[l]){var c=e.x,p=e.y;t.moveTo(c,p+h),t.lineTo(c+5,p+h),t.moveTo(c+e.width-5,p+h),t.lineTo(c+e.width,p+h);var u=this;l(t,{x:o+4,y:s+4,width:r-8,height:a-8,n:h,image:d},function(){u.modSelf(),i()})}else t.moveTo(o,s+h),t.lineTo(o+r,s+h)}var o=t("./base"),s=t("zrender/shape/Polyline"),n=t("../util/shape/Icon"),r=t("../util/shape/HalfSmoothPolygon");t("../component/axis"),t("../component/grid"),t("../component/dataZoom");var a=t("../config");a.line={zlevel:0,z:2,clickable:!0,legendHoverLink:!0,xAxisIndex:0,yAxisIndex:0,itemStyle:{normal:{label:{show:!1},lineStyle:{width:1.5,type:"solid",shadowColor:"rgba(0,0,0,0)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0}},emphasis:{label:{show:!1}}},symbolSize:2,showAllSymbol:!1};var h=t("../util/ecData"),l=t("zrender/tool/util"),d=t("zrender/tool/color");return e.prototype={type:a.CHART_TYPE_LINE,_buildShape:function(){this.finalPLMap={},this._buildPosition()},_buildHorizontal:function(t,e,i,o){for(var s,n,r,a,h,l,d,c,p,u=this.series,g=i[0][0],f=u[g],m=this.component.xAxis.getAxis(f.xAxisIndex||0),y={},_=0,v=e;v>_&&null!=m.getNameByIndex(_);_++){n=m.getCoordByIndex(_);for(var x=0,b=i.length;b>x;x++){s=this.component.yAxis.getAxis(u[i[x][0]].yAxisIndex||0),h=a=d=l=s.getCoord(0);for(var S=0,T=i[x].length;T>S;S++)g=i[x][S],f=u[g],c=f.data[_],p=this.getDataFromOption(c,"-"),y[g]=y[g]||[],o[g]=o[g]||{min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY,sum:0,counter:0,average:0},"-"!==p?(p>=0?(a-=S>0?s.getCoordSize(p):h-s.getCoord(p),r=a):0>p&&(l+=S>0?s.getCoordSize(p):s.getCoord(p)-d,r=l),y[g].push([n,r,_,m.getNameByIndex(_),n,h]),o[g].min>p&&(o[g].min=p,o[g].minY=r,o[g].minX=n),o[g].max<p&&(o[g].max=p,o[g].maxY=r,o[g].maxX=n),o[g].sum+=p,o[g].counter++):y[g].length>0&&(this.finalPLMap[g]=this.finalPLMap[g]||[],this.finalPLMap[g].push(y[g]),y[g]=[])}a=this.component.grid.getY();for(var z,x=0,b=i.length;b>x;x++)for(var S=0,T=i[x].length;T>S;S++)g=i[x][S],f=u[g],c=f.data[_],p=this.getDataFromOption(c,"-"),"-"==p&&this.deepQuery([c,f,this.option],"calculable")&&(z=this.deepQuery([c,f],"symbolSize"),a+=2*z+5,r=a,this.shapeList.push(this._getCalculableItem(g,_,m.getNameByIndex(_),n,r,"horizontal")))}for(var L in y)y[L].length>0&&(this.finalPLMap[L]=this.finalPLMap[L]||[],this.finalPLMap[L].push(y[L]),y[L]=[]);this._calculMarkMapXY(o,i,"y"),this._buildBorkenLine(t,this.finalPLMap,m,"horizontal")},_buildVertical:function(t,e,i,o){for(var s,n,r,a,h,l,d,c,p,u=this.series,g=i[0][0],f=u[g],m=this.component.yAxis.getAxis(f.yAxisIndex||0),y={},_=0,v=e;v>_&&null!=m.getNameByIndex(_);_++){r=m.getCoordByIndex(_);for(var x=0,b=i.length;b>x;x++){s=this.component.xAxis.getAxis(u[i[x][0]].xAxisIndex||0),h=a=d=l=s.getCoord(0);for(var S=0,T=i[x].length;T>S;S++)g=i[x][S],f=u[g],c=f.data[_],p=this.getDataFromOption(c,"-"),y[g]=y[g]||[],o[g]=o[g]||{min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY,sum:0,counter:0,average:0},"-"!==p?(p>=0?(a+=S>0?s.getCoordSize(p):s.getCoord(p)-h,n=a):0>p&&(l-=S>0?s.getCoordSize(p):d-s.getCoord(p),n=l),y[g].push([n,r,_,m.getNameByIndex(_),h,r]),o[g].min>p&&(o[g].min=p,o[g].minX=n,o[g].minY=r),o[g].max<p&&(o[g].max=p,o[g].maxX=n,o[g].maxY=r),o[g].sum+=p,o[g].counter++):y[g].length>0&&(this.finalPLMap[g]=this.finalPLMap[g]||[],this.finalPLMap[g].push(y[g]),y[g]=[])}a=this.component.grid.getXend();for(var z,x=0,
},_syncData:function(t){var e,i,o,s,n;for(var a in this._originalData){e=this._originalData[a];for(var h in e)n=e[h],null!=n&&(s=n.length,i=Math.floor(this._zoom.start/100*s),o=Math.ceil(this._zoom.end/100*s),this.getDataFromOption(n[0])instanceof Array&&this.option[a][h].type!=r.CHART_TYPE_K?(this._setScale(),this.option[a][h].data=this._synScatterData(h,n)):this.option[a][h].data=n.slice(i,o))}this._isSilence||!this.zoomOption.realtime&&!t||this.messageCenter.dispatch(r.EVENT.DATA_ZOOM,null,{zoom:this._zoom},this.myChart)},_synScatterData:function(t,e){if(0===this._zoom.start&&100==this._zoom.end&&0===this._zoom.start2&&100==this._zoom.end2)return e;var i,o,s,n,r,a=[],h=this._zoom.scatterMap[t];"horizontal"==this.zoomOption.orient?(i=h.x.max-h.x.min,o=this._zoom.start/100*i+h.x.min,s=this._zoom.end/100*i+h.x.min,i=h.y.max-h.y.min,n=this._zoom.start2/100*i+h.y.min,r=this._zoom.end2/100*i+h.y.min):(i=h.x.max-h.x.min,o=this._zoom.start2/100*i+h.x.min,s=this._zoom.end2/100*i+h.x.min,i=h.y.max-h.y.min,n=this._zoom.start/100*i+h.y.min,r=this._zoom.end/100*i+h.y.min);for(var l,d=0,c=e.length;c>d;d++)l=e[d].value||e[d],l[0]>=o&&l[0]<=s&&l[1]>=n&&l[1]<=r&&a.push(e[d]);return a},_setScale:function(){var t=0!==this._zoom.start||100!==this._zoom.end||0!==this._zoom.start2||100!==this._zoom.end2,e={xAxis:this.option.xAxis,yAxis:this.option.yAxis};for(var i in e)for(var o=0,s=e[i].length;s>o;o++)e[i][o].scale=t||e[i][o]._scale},_backupScale:function(){var t={xAxis:this.option.xAxis,yAxis:this.option.yAxis};for(var e in t)for(var i=0,o=t[e].length;o>i;i++)t[e][i]._scale=t[e][i].scale},_getDetail:function(){var t="horizontal"==this.zoomOption.orient?"xAxis":"yAxis",e=this._originalData[t];for(var i in e){var o=e[i];if(null!=o){var s=o.length,n=Math.floor(this._zoom.start/100*s),r=Math.ceil(this._zoom.end/100*s);return r-=r>0?1:0,{start:this.getDataFromOption(o[n]),end:this.getDataFromOption(o[r])}}}var h=this._zoom.seriesIndex[0],l=this.option.series[h][t+"Index"]||0,d=this.option[t][l].type,c=this._zoom.scatterMap[h][t.charAt(0)].min,p=this._zoom.scatterMap[h][t.charAt(0)].max,u=p-c;if("value"==d)return{start:c+u*this._zoom.start/100,end:c+u*this._zoom.end/100};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._z
i.e-s.e>6&&(s={c:0,e:i.e}),a(i,s),a(o,s),o.c+=s.c-i.c,i.c=s.c}else if(T){var r=n(e,4);o.e-r.e>6&&(r={c:0,e:o.e}),a(i,r),a(o,r),i.c+=r.c-o.c,o.c=r.c}}function _(t,e,i){var o=i?[i]:b,a=e-t;if(0===a)return e=n(e,3),i=o[0],e.c=w(e.c+i/2),s(e.c-i,e.c,i,e.e);E(e/a)<1e-6&&(e=0),E(t/a)<1e-6&&(t=0);var h,l,d,c=[[5,10],[10,2],[50,10],[100,2]],p=[],u=[],g=n(e-t,3),f=n(t,-1,1),m=n(e,-1);r(f,g,1),r(m,g),a=m.c-f.c,g.c=a;for(var y=o.length;y--;){i=o[y],h=A(a/i),l=h*i-a,d=3*(l+3),d+=2*(i-o[0]+2),i%5===0&&(d-=10);for(var _=c.length;_--;)h%c[_][0]===0&&(d/=c[_][1]);u[y]=[i,h,l,d].join(),p[y]={secs:i,step:h,delta:l,score:d}}return p.sort(function(t,e){return t.score-e.score}),p=p[0],f.c=w(f.c-p.delta/2),m.c=w(m.c+p.delta/2),s(f.c,m.c,p.secs,g.e)}var v,x,b,S,T,z=[10,20,25,50],L=[4,5,6],C=Math,w=C.round,M=C.floor,A=C.ceil,E=C.abs;return o});