basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 10.6 kB
JavaScript
import{b8 as t,Z as e,D as n,_ as i,bQ as o,e as a,dh as r,bt as s,bV as u,bU as d,bh as p,aq as l,m as c,di as f,dj as h,dk as g,F as x}from"./index.js";import{s as m}from"./sliderMove.js";var v=["x","y","radius","angle","single"],y=["cartesian2d","polar","singleAxis"];function _(t){return e(t),t+"Axis"}function M(e,n){var i,o=t(),a=[],r=t();e.eachComponent({mainType:"dataZoom",query:n},(function(t){r.get(t.uid)||u(t)}));do{i=!1,e.eachComponent("dataZoom",s)}while(i);function s(t){!r.get(t.uid)&&function(t){var e=!1;return t.eachTargetAxis((function(t,n){var i=o.get(t);i&&i[n]&&(e=!0)})),e}(t)&&(u(t),i=!0)}function u(t){r.set(t.uid,!0),a.push(t),t.eachTargetAxis((function(t,e){(o.get(t)||o.set(t,[]))[e]=!0}))}return a}function A(e){var n=e.ecModel,i={infoList:[],infoMap:t()};return e.eachTargetAxis((function(t,e){var o=n.getComponent(_(t),e);if(o){var a=o.getCoordSysModel();if(a){var r=a.uid,s=i.infoMap.get(r);s||(s={model:a,axisModels:[]},i.infoList.push(s),i.infoMap.set(r,s)),s.axisModels.push(o)}}})),i}var T=function(){function t(){this.indexList=[],this.indexMap=[]}return t.prototype.add=function(t){this.indexMap[t]||(this.indexList.push(t),this.indexMap[t]=!0)},t}(),w=function(n){function u(){var t=null!==n&&n.apply(this,arguments)||this;return t.type=u.type,t._autoThrottle=!0,t._noTarget=!0,t._rangePropMode=["percent","percent"],t}return i(u,n),u.prototype.init=function(t,e,n){var i=P(t);this.settledOption=i,this.mergeDefaultAndTheme(t,n),this._doInit(i)},u.prototype.mergeOption=function(t){var e=P(t);o(this.option,t,!0),o(this.settledOption,e,!0),this._doInit(e)},u.prototype._doInit=function(t){var e=this.option;this._setDefaultThrottle(t),this._updateRangeUse(t);var n=this.settledOption;a([["start","startValue"],["end","endValue"]],(function(t,i){"value"===this._rangePropMode[i]&&(e[t[0]]=n[t[0]]=null)}),this),this._resetTarget()},u.prototype._resetTarget=function(){var e=this.get("orient",!0),n=this._targetAxisInfoMap=t();this._fillSpecifiedTargetAxis(n)?this._orient=e||this._makeAutoOrientByTargetAxis():(this._orient=e||"horizontal",this._fillAutoTargetAxisByOrient(n,this._orient)),this._noTarget=!0,n.each((function(t){t.indexList.length&&(this._noTarget=!1)}),this)},u.prototype._fillSpecifiedTargetAxis=function(t){var e=!1;return a(v,(function(n){var i=this.getReferringComponents(_(n),r);if(i.specified){e=!0;var o=new T;a(i.models,(function(t){o.add(t.componentIndex)})),t.set(n,o)}}),this),e},u.prototype._fillAutoTargetAxisByOrient=function(t,e){var n=this.ecModel,i=!0;if(i){var o="vertical"===e?"y":"x";r(n.findComponents({mainType:o+"Axis"}),o)}i&&r(n.findComponents({mainType:"singleAxis",filter:function(t){return t.get("orient",!0)===e}}),"single");function r(e,n){var o=e[0];if(o){var r=new T;if(r.add(o.componentIndex),t.set(n,r),i=!1,"x"===n||"y"===n){var u=o.getReferringComponents("grid",s).models[0];u&&a(e,(function(t){o.componentIndex!==t.componentIndex&&u===t.getReferringComponents("grid",s).models[0]&&r.add(t.componentIndex)}))}}}i&&a(v,(function(e){if(i){var o=n.findComponents({mainType:_(e),filter:function(t){return"category"===t.get("type",!0)}});if(o[0]){var a=new T;a.add(o[0].componentIndex),t.set(e,a),i=!1}}}),this)},u.prototype._makeAutoOrientByTargetAxis=function(){var t;return this.eachTargetAxis((function(e){!t&&(t=e)}),this),"y"===t?"vertical":"horizontal"},u.prototype._setDefaultThrottle=function(t){if(t.hasOwnProperty("throttle")&&(this._autoThrottle=!1),this._autoThrottle){var e=this.ecModel.option;this.option.throttle=e.animation&&e.animationDurationUpdate>0?100:20}},u.prototype._updateRangeUse=function(t){var e=this._rangePropMode,n=this.get("rangeMode");a([["start","startValue"],["end","endValue"]],(function(i,o){var a=null!=t[i[0]],r=null!=t[i[1]];a&&!r?e[o]="percent":!a&&r?e[o]="value":n?e[o]=n[o]:a&&(e[o]="percent")}))},u.prototype.noTarget=function(){return this._noTarget},u.prototype.getFirstTargetAxisModel=function(){var t;return this.eachTargetAxis((function(e,n){null==t&&(t=this.ecModel.getComponent(_(e),n))}),this),t},u.prototype.eachTargetAxis=function(t,e){this._targetAxisInfoMap.each((function(n,i){a(n.indexList,(function(n){t.call(e,i,n)}))}))},u.prototype.getAxisProxy=function(t,e){var n=this.getAxisModel(t,e);if(n)return n.__dzAxisProxy},u.prototype.getAxisModel=function(t,n){e(t&&null!=n);var i=this._targetAxisInfoMap.get(t);if(i&&i.indexMap[n])return this.ecModel.getComponent(_(t),n)},u.prototype.setRawRange=function(t){var e=this.option,n=this.settledOption;a([["start","startValue"],["end","endValue"]],(function(i){null==t[i[0]]&&null==t[i[1]]||(e[i[0]]=n[i[0]]=t[i[0]],e[i[1]]=n[i[1]]=t[i[1]])}),this),this._updateRangeUse(t)},u.prototype.setCalculatedRange=function(t){var e=this.option;a(["start","startValue","end","endValue"],(function(n){e[n]=t[n]}))},u.prototype.getPercentRange=function(){var t=this.findRepresentativeAxisProxy();if(t)return t.getDataPercentWindow()},u.prototype.getValueRange=function(t,e){if(null!=t||null!=e)return this.getAxisProxy(t,e).getDataValueWindow();var n=this.findRepresentativeAxisProxy();return n?n.getDataValueWindow():void 0},u.prototype.findRepresentativeAxisProxy=function(t){if(t)return t.__dzAxisProxy;for(var e,n=this._targetAxisInfoMap.keys(),i=0;i<n.length;i++)for(var o=n[i],a=this._targetAxisInfoMap.get(o),r=0;r<a.indexList.length;r++){var s=this.getAxisProxy(o,a.indexList[r]);if(s.hostedBy(this))return s;e||(e=s)}return e},u.prototype.getRangePropMode=function(){return this._rangePropMode.slice()},u.prototype.getOrient=function(){return e(this._orient),this._orient},u.type="dataZoom",u.dependencies=["xAxis","yAxis","radiusAxis","angleAxis","singleAxis","series","toolbox"],u.defaultOption={z:4,filterMode:"filter",start:0,end:100},u}(u);function P(t){var e={};return a(["start","end","startValue","endValue","throttle"],(function(n){t.hasOwnProperty(n)&&(e[n]=t[n])})),e}var R=function(t){function e(){var n=null!==t&&t.apply(this,arguments)||this;return n.type=e.type,n}return i(e,t),e.prototype.render=function(t,e,n,i){this.dataZoomModel=t,this.ecModel=e,this.api=n},e.type="dataZoom",e}(d),S=a,V=x,D=function(){function t(t,e,n,i){this._dimName=t,this._axisIndex=e,this.ecModel=i,this._dataZoomModel=n}return t.prototype.hostedBy=function(t){return this._dataZoomModel===t},t.prototype.getDataValueWindow=function(){return this._valueWindow.slice()},t.prototype.getDataPercentWindow=function(){return this._percentWindow.slice()},t.prototype.getTargetSeriesModels=function(){var t=[];return this.ecModel.eachSeries((function(e){if(function(t){var e=t.get("coordinateSystem");return n(y,e)>=0}(e)){var i=_(this._dimName),o=e.getReferringComponents(i,s).models[0];o&&this._axisIndex===o.componentIndex&&t.push(e)}}),this),t},t.prototype.getAxisModel=function(){return this.ecModel.getComponent(this._dimName+"Axis",this._axisIndex)},t.prototype.getMinMaxSpan=function(){return p(this._minMaxSpan)},t.prototype.calculateDataWindow=function(t){var e,n=this._dataExtent,i=this.getAxisModel().axis.scale,o=this._dataZoomModel.getRangePropMode(),a=[0,100],r=[],s=[];S(["start","end"],(function(u,d){var p=t[u],c=t[u+"Value"];"percent"===o[d]?(null==p&&(p=a[d]),c=i.parse(l(p,a,n))):(e=!0,c=null==c?n[d]:i.parse(c),p=l(c,n,a)),s[d]=null==c||isNaN(c)?n[d]:c,r[d]=null==p||isNaN(p)?a[d]:p})),V(s),V(r);var u=this._minMaxSpan;function d(t,e,n,o,a){var r=a?"Span":"ValueSpan";m(0,t,n,"all",u["min"+r],u["max"+r]);for(var s=0;s<2;s++)e[s]=l(t[s],n,o,!0),a&&(e[s]=i.parse(e[s]))}return e?d(s,r,n,a,!1):d(r,s,a,n,!0),{valueWindow:s,percentWindow:r}},t.prototype.reset=function(t){if(t===this._dataZoomModel){var e=this.getTargetSeriesModels();this._dataExtent=function(t,e,n){var i=[1/0,-1/0];S(n,(function(t){h(i,t.getData(),e)}));var o=t.getAxisModel(),a=g(o.axis.scale,o,i).calculate();return[a.min,a.max]}(this,this._dimName,e),this._updateMinMaxSpan();var n=this.calculateDataWindow(t.settledOption);this._valueWindow=n.valueWindow,this._percentWindow=n.percentWindow,this._setAxisModel()}},t.prototype.filterData=function(t,e){if(t===this._dataZoomModel){var n=this._dimName,i=this.getTargetSeriesModels(),o=t.get("filterMode"),a=this._valueWindow;"none"!==o&&S(i,(function(t){var e=t.getData(),i=e.mapDimensionsAll(n);if(i.length){if("weakFilter"===o){var r=e.getStore(),s=c(i,(function(t){return e.getDimensionIndex(t)}),e);e.filterSelf((function(t){for(var e,n,o,u=0;u<i.length;u++){var d=r.get(s[u],t),p=!isNaN(d),l=d<a[0],c=d>a[1];if(p&&!l&&!c)return!0;p&&(o=!0),l&&(e=!0),c&&(n=!0)}return o&&e&&n}))}else S(i,(function(n){if("empty"===o)t.setData(e=e.map(n,(function(t){return function(t){return t>=a[0]&&t<=a[1]}(t)?t:NaN})));else{var i={};i[n]=a,e.selectRange(i)}}));S(i,(function(t){e.setApproximateExtent(a,t)}))}}))}},t.prototype._updateMinMaxSpan=function(){var t=this._minMaxSpan={},e=this._dataZoomModel,n=this._dataExtent;S(["min","max"],(function(i){var o=e.get(i+"Span"),a=e.get(i+"ValueSpan");null!=a&&(a=this.getAxisModel().axis.scale.parse(a)),null!=a?o=l(n[0]+a,n,[0,100],!0):null!=o&&(a=l(o,[0,100],n,!0)-n[0]),t[i+"Span"]=o,t[i+"ValueSpan"]=a}),this)},t.prototype._setAxisModel=function(){var t=this.getAxisModel(),e=this._percentWindow,n=this._valueWindow;if(e){var i=f(n,[0,500]);i=Math.min(i,20);var o=t.axis.scale.rawExtentInfo;0!==e[0]&&o.setDeterminedMinMax("min",+n[0].toFixed(i)),100!==e[1]&&o.setDeterminedMinMax("max",+n[1].toFixed(i)),o.freeze()}},t}();var I={getTargetSeries:function(e){function n(t){e.eachComponent("dataZoom",(function(n){n.eachTargetAxis((function(i,o){var a=e.getComponent(_(i),o);t(i,o,a,n)}))}))}n((function(t,e,n,i){n.__dzAxisProxy=null}));var i=[];n((function(t,n,o,a){o.__dzAxisProxy||(o.__dzAxisProxy=new D(t,n,a,e),i.push(o.__dzAxisProxy))}));var o=t();return a(i,(function(t){a(t.getTargetSeriesModels(),(function(t){o.set(t.uid,t)}))})),o},overallReset:function(t,e){t.eachComponent("dataZoom",(function(t){t.eachTargetAxis((function(e,n){t.getAxisProxy(e,n).reset(t)})),t.eachTargetAxis((function(n,i){t.getAxisProxy(n,i).filterData(t,e)}))})),t.eachComponent("dataZoom",(function(t){var e=t.findRepresentativeAxisProxy();if(e){var n=e.getDataPercentWindow(),i=e.getDataValueWindow();t.setCalculatedRange({start:n[0],end:n[1],startValue:i[0],endValue:i[1]})}}))}};var C=!1;function W(t){C||(C=!0,t.registerProcessor(t.PRIORITY.PROCESSOR.FILTER,I),function(t){t.registerAction("dataZoom",(function(t,e){var n=M(e,t);a(n,(function(e){e.setRawRange({start:t.start,end:t.end,startValue:t.startValue,endValue:t.endValue})}))}))}(t),t.registerSubTypeDefaulter("dataZoom",(function(){return"slider"})))}export{w as D,R as a,A as c,_ as g,W as i};