UNPKG

basb-cli

Version:
2 lines (1 loc) 6.54 kB
import{_ as t,c as e,S as r,b1 as o,P as i,G as s,ae as n,g as a,C as p,b9 as l}from"./index.js";import{S as h}from"./SymbolDraw.js";import{p as u}from"./points.js";import{i as d}from"./installSimple.js";import"./Symbol.js";import"./labelHelper.js";import"./axisModelCreator.js";import"./axisDefault.js";import"./AxisView.js";import"./axisAlignTicks.js";import"./AxisBuilder.js";import"./labelLayoutHelper.js";import"./axisSplitHelper.js";var c=function(r){function o(){var t=null!==r&&r.apply(this,arguments)||this;return t.type=o.type,t.hasSymbolVisual=!0,t}return t(o,r),o.prototype.getInitialData=function(t,r){return e(null,this,{useEncodeDefaulter:!0})},o.prototype.getProgressive=function(){var t=this.option.progressive;return null==t?this.option.large?5e3:this.get("progressive"):t},o.prototype.getProgressiveThreshold=function(){var t=this.option.progressiveThreshold;return null==t?this.option.large?1e4:this.get("progressiveThreshold"):t},o.prototype.brushSelector=function(t,e,r){return r.point(e.getItemLayout(t))},o.prototype.getZLevelKey=function(){return this.getData().count()>this.getProgressiveThreshold()?this.id:""},o.type="series.scatter",o.dependencies=["grid","polar","geo","singleAxis","calendar"],o.defaultOption={coordinateSystem:"cartesian2d",z:2,legendHoverLink:!0,symbolSize:10,large:!1,largeThreshold:2e3,itemStyle:{opacity:.8},emphasis:{scale:!0},clip:!0,select:{itemStyle:{borderColor:"#212121"}},universalTransition:{divideShape:"clone"}},o}(r),f=function(){},y=function(e){function r(t){var r=e.call(this,t)||this;return r._off=0,r.hoverDataIdx=-1,r}return t(r,e),r.prototype.getDefaultShape=function(){return new f},r.prototype.reset=function(){this.notClear=!1,this._off=0},r.prototype.buildPath=function(t,e){var r,o=e.points,i=e.size,s=this.symbolProxy,n=s.shape,a=t.getContext?t.getContext():t,p=a&&i[0]<4,l=this.softClipShape;if(p)this._ctx=a;else{for(this._ctx=null,r=this._off;r<o.length;){var h=o[r++],u=o[r++];isNaN(h)||isNaN(u)||(l&&!l.contain(h,u)||(n.x=h-i[0]/2,n.y=u-i[1]/2,n.width=i[0],n.height=i[1],s.buildPath(t,n,!0)))}this.incremental&&(this._off=r,this.notClear=!0)}},r.prototype.afterBrush=function(){var t,e=this.shape,r=e.points,o=e.size,i=this._ctx,s=this.softClipShape;if(i){for(t=this._off;t<r.length;){var n=r[t++],a=r[t++];isNaN(n)||isNaN(a)||(s&&!s.contain(n,a)||i.fillRect(n-o[0]/2,a-o[1]/2,o[0],o[1]))}this.incremental&&(this._off=t,this.notClear=!0)}},r.prototype.findDataIndex=function(t,e){for(var r=this.shape,o=r.points,i=r.size,s=Math.max(i[0],4),n=Math.max(i[1],4),a=o.length/2-1;a>=0;a--){var p=2*a,l=o[p]-s/2,h=o[p+1]-n/2;if(t>=l&&e>=h&&t<=l+s&&e<=h+n)return a}return-1},r.prototype.contain=function(t,e){var r=this.transformCoordToLocal(t,e),o=this.getBoundingRect();return t=r[0],e=r[1],o.contain(t,e)?(this.hoverDataIdx=this.findDataIndex(t,e))>=0:(this.hoverDataIdx=-1,!1)},r.prototype.getBoundingRect=function(){var t=this._rect;if(!t){for(var e=this.shape,r=e.points,i=e.size,s=i[0],n=i[1],a=1/0,p=1/0,l=-1/0,h=-1/0,u=0;u<r.length;){var d=r[u++],c=r[u++];a=Math.min(d,a),l=Math.max(d,l),p=Math.min(c,p),h=Math.max(c,h)}t=this._rect=new o(a-s/2,p-n/2,l-a+s,h-p+n)}return t},r}(i),m=function(){function t(){this.group=new s}return t.prototype.updateData=function(t,e){this._clear();var r=this._create();r.setShape({points:t.getLayout("points")}),this._setCommon(r,t,e)},t.prototype.updateLayout=function(t){var e=t.getLayout("points");this.group.eachChild((function(t){if(null!=t.startIndex){var r=2*(t.endIndex-t.startIndex),o=4*t.startIndex*2;e=new Float32Array(e.buffer,o,r)}t.setShape("points",e),t.reset()}))},t.prototype.incrementalPrepareUpdate=function(t){this._clear()},t.prototype.incrementalUpdate=function(t,e,r){var o=this._newAdded[0],i=e.getLayout("points"),s=o&&o.shape.points;if(s&&s.length<2e4){var n=s.length,a=new Float32Array(n+i.length);a.set(s),a.set(i,n),o.endIndex=t.end,o.setShape({points:a})}else{this._newAdded=[];var p=this._create();p.startIndex=t.start,p.endIndex=t.end,p.incremental=!0,p.setShape({points:i}),this._setCommon(p,e,r)}},t.prototype.eachRendered=function(t){this._newAdded[0]&&t(this._newAdded[0])},t.prototype._create=function(){var t=new y({cursor:"default"});return t.ignoreCoarsePointer=!0,this.group.add(t),this._newAdded.push(t),t},t.prototype._setCommon=function(t,e,r){var o=e.hostModel;r=r||{};var i=e.getVisual("symbolSize");t.setShape("size",i instanceof Array?i:[i,i]),t.softClipShape=r.clipShape||null,t.symbolProxy=n(e.getVisual("symbol"),0,0,0,0),t.setColor=t.symbolProxy.setColor;var s=t.shape.size[0]<4;t.useStyle(o.getModel("itemStyle").getItemStyle(s?["color","shadowBlur","shadowColor"]:["color"]));var p=e.getVisual("style"),l=p&&p.fill;l&&t.setColor(l);var h=a(t);h.seriesIndex=o.seriesIndex,t.on("mousemove",(function(e){h.dataIndex=null;var r=t.hoverDataIdx;r>=0&&(h.dataIndex=r+(t.startIndex||0))}))},t.prototype.remove=function(){this._clear()},t.prototype._clear=function(){this._newAdded=[],this.group.removeAll()},t}(),g=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=r.type,t}return t(r,e),r.prototype.render=function(t,e,r){var o=t.getData();this._updateSymbolDraw(o,t).updateData(o,{clipShape:this._getClipShape(t)}),this._finished=!0},r.prototype.incrementalPrepareRender=function(t,e,r){var o=t.getData();this._updateSymbolDraw(o,t).incrementalPrepareUpdate(o),this._finished=!1},r.prototype.incrementalRender=function(t,e,r){this._symbolDraw.incrementalUpdate(t,e.getData(),{clipShape:this._getClipShape(e)}),this._finished=t.end===e.getData().count()},r.prototype.updateTransform=function(t,e,r){var o=t.getData();if(this.group.dirty(),!this._finished||o.count()>1e4)return{update:!0};var i=u("").reset(t,e,r);i.progress&&i.progress({start:0,end:o.count(),count:o.count()},o),this._symbolDraw.updateLayout(o)},r.prototype.eachRendered=function(t){this._symbolDraw&&this._symbolDraw.eachRendered(t)},r.prototype._getClipShape=function(t){if(t.get("clip",!0)){var e=t.coordinateSystem;return e&&e.getArea&&e.getArea(.1)}},r.prototype._updateSymbolDraw=function(t,e){var r=this._symbolDraw,o=e.pipelineContext.large;return r&&o===this._isLargeDraw||(r&&r.remove(),r=this._symbolDraw=o?new m:new h,this._isLargeDraw=o,this.group.removeAll()),this.group.add(r.group),r},r.prototype.remove=function(t,e){this._symbolDraw&&this._symbolDraw.remove(!0),this._symbolDraw=null},r.prototype.dispose=function(){},r.type="scatter",r}(p);function v(t){l(d),t.registerSeriesModel(c),t.registerChartView(g),t.registerLayout(u("scatter"))}export{v as install};