basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 8.44 kB
JavaScript
import{as as t,b5 as e,_ as i,ax as a,P as n,f as o,e as s,u as r,j as l,aW as p,k as c,at as u,d,o as h,af as f,ag as y,aA as g,G as m,ah as v,ai as _,ae as S,t as b}from"./index.js";var L=t.prototype,I=e.prototype,M=function(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.percent=1};function x(t){return isNaN(+t.cpx1)||isNaN(+t.cpy1)}!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}i(e,t)}(M);var N=function(t){function e(e){var i=t.call(this,e)||this;return i.type="ec-line",i}return i(e,t),e.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},e.prototype.getDefaultShape=function(){return new M},e.prototype.buildPath=function(t,e){x(e)?L.buildPath.call(this,t,e):I.buildPath.call(this,t,e)},e.prototype.pointAt=function(t){return x(this.shape)?L.pointAt.call(this,t):I.pointAt.call(this,t)},e.prototype.tangentAt=function(t){var e=this.shape,i=x(e)?[e.x2-e.x1,e.y2-e.y1]:I.tangentAt.call(this,t);return a(i,i)},e}(n),A=["fromSymbol","toSymbol"];function k(t){return"_"+t+"Type"}function E(t,e,i){var a=e.getItemVisual(i,t);if(!a||"none"===a)return a;var n=e.getItemVisual(i,t+"Size"),o=e.getItemVisual(i,t+"Rotate"),s=e.getItemVisual(i,t+"Offset"),r=e.getItemVisual(i,t+"KeepAspect"),l=v(n);return a+l+_(s||0,l)+(o||"")+(r||"")}function D(t,e,i){var a=e.getItemVisual(i,t);if(a&&"none"!==a){var n=e.getItemVisual(i,t+"Size"),o=e.getItemVisual(i,t+"Rotate"),s=e.getItemVisual(i,t+"Offset"),r=e.getItemVisual(i,t+"KeepAspect"),l=v(n),p=_(s||0,l),c=S(a,-l[0]/2+p[0],-l[1]/2+p[1],l[0],l[1],null,r);return c.__specifiedRotation=null==o||isNaN(o)?void 0:+o*Math.PI/180||0,c.name=t,c}}function P(t,e){t.x1=e[0][0],t.y1=e[0][1],t.x2=e[1][0],t.y2=e[1][1],t.percent=1;var i=e[2];i?(t.cpx1=i[0],t.cpy1=i[1]):(t.cpx1=NaN,t.cpy1=NaN)}var w=function(t){function e(e,i,a){var n=t.call(this)||this;return n._createLine(e,i,a),n}return i(e,t),e.prototype._createLine=function(t,e,i){var a=t.hostModel,n=function(t){var e=new N({name:"line",subPixelOptimize:!0});return P(e.shape,t),e}(t.getItemLayout(e));n.shape.percent=0,o(n,{shape:{percent:1}},a,e),this.add(n),s(A,(function(i){var a=D(i,t,e);this.add(a),this[k(i)]=E(i,t,e)}),this),this._updateCommonStl(t,e,i)},e.prototype.updateData=function(t,e,i){var a=t.hostModel,n=this.childOfName("line"),o=t.getItemLayout(e),l={shape:{}};P(l.shape,o),r(n,l,a,e),s(A,(function(i){var a=E(i,t,e),n=k(i);if(this[n]!==a){this.remove(this.childOfName(i));var o=D(i,t,e);this.add(o)}this[n]=a}),this),this._updateCommonStl(t,e,i)},e.prototype.getLinePath=function(){return this.childAt(0)},e.prototype._updateCommonStl=function(t,e,i){var a=t.hostModel,n=this.childOfName("line"),o=i&&i.emphasisLineStyle,r=i&&i.blurLineStyle,f=i&&i.selectLineStyle,y=i&&i.labelStatesModels,g=i&&i.emphasisDisabled,m=i&&i.focus,v=i&&i.blurScope;if(!i||t.hasItemOption){var _=t.getItemModel(e),S=_.getModel("emphasis");o=S.getModel("lineStyle").getLineStyle(),r=_.getModel(["blur","lineStyle"]).getLineStyle(),f=_.getModel(["select","lineStyle"]).getLineStyle(),g=S.get("disabled"),m=S.get("focus"),v=S.get("blurScope"),y=l(_)}var b=t.getItemVisual(e,"style"),L=b.stroke;n.useStyle(b),n.style.fill=null,n.style.strokeNoScale=!0,n.ensureState("emphasis").style=o,n.ensureState("blur").style=r,n.ensureState("select").style=f,s(A,(function(t){var e=this.childOfName(t);if(e){e.setColor(L),e.style.opacity=b.opacity;for(var i=0;i<p.length;i++){var a=p[i],o=n.getState(a);if(o){var s=o.style||{},r=e.ensureState(a),l=r.style||(r.style={});null!=s.stroke&&(l[e.__isEmptyBrush?"stroke":"fill"]=s.stroke),null!=s.opacity&&(l.opacity=s.opacity)}}e.markRedraw()}}),this);var I=a.getRawValue(e);c(this,y,{labelDataIndex:e,labelFetcher:{getFormattedLabel:function(e,i){return a.getFormattedLabel(e,i,t.dataType)}},inheritColor:L||"#000",defaultOpacity:b.opacity,defaultText:(null==I?t.getName(e):isFinite(I)?u(I):I)+""});var M=this.getTextContent();if(M){var x=y.normal;M.__align=M.style.align,M.__verticalAlign=M.style.verticalAlign,M.__position=x.get("position")||"middle";var N=x.get("distance");d(N)||(N=[N,N]),M.__labelDistance=N}this.setTextConfig({position:null,local:!0,inside:!1}),h(this,m,v,g)},e.prototype.highlight=function(){f(this)},e.prototype.downplay=function(){y(this)},e.prototype.updateLayout=function(t,e){this.setLinePoints(t.getItemLayout(e))},e.prototype.setLinePoints=function(t){var e=this.childOfName("line");P(e.shape,t),e.dirty()},e.prototype.beforeUpdate=function(){var t=this,e=t.childOfName("fromSymbol"),i=t.childOfName("toSymbol"),n=t.getTextContent();if(e||i||n&&!n.ignore){for(var o=1,s=this.parent;s;)s.scaleX&&(o/=s.scaleX),s=s.parent;var r=t.childOfName("line");if(this.__dirty||r.__dirty){var l=r.shape.percent,p=r.pointAt(0),c=r.pointAt(l),u=g([],c,p);if(a(u,u),e&&(e.setPosition(p),x(e,0),e.scaleX=e.scaleY=o*l,e.markRedraw()),i&&(i.setPosition(c),x(i,1),i.scaleX=i.scaleY=o*l,i.markRedraw()),n&&!n.ignore){n.x=n.y=0,n.originX=n.originY=0;var d=void 0,h=void 0,f=n.__labelDistance,y=f[0]*o,m=f[1]*o,v=l/2,_=r.tangentAt(v),S=[_[1],-_[0]],b=r.pointAt(v);S[1]>0&&(S[0]=-S[0],S[1]=-S[1]);var L=_[0]<0?-1:1;if("start"!==n.__position&&"end"!==n.__position){var I=-Math.atan2(_[1],_[0]);c[0]<p[0]&&(I=Math.PI+I),n.rotation=I}var M=void 0;switch(n.__position){case"insideStartTop":case"insideMiddleTop":case"insideEndTop":case"middle":M=-m,h="bottom";break;case"insideStartBottom":case"insideMiddleBottom":case"insideEndBottom":M=m,h="top";break;default:M=0,h="middle"}switch(n.__position){case"end":n.x=u[0]*y+c[0],n.y=u[1]*m+c[1],d=u[0]>.8?"left":u[0]<-.8?"right":"center",h=u[1]>.8?"top":u[1]<-.8?"bottom":"middle";break;case"start":n.x=-u[0]*y+p[0],n.y=-u[1]*m+p[1],d=u[0]>.8?"right":u[0]<-.8?"left":"center",h=u[1]>.8?"bottom":u[1]<-.8?"top":"middle";break;case"insideStartTop":case"insideStart":case"insideStartBottom":n.x=y*L+p[0],n.y=p[1]+M,d=_[0]<0?"right":"left",n.originX=-y*L,n.originY=-M;break;case"insideMiddleTop":case"insideMiddle":case"insideMiddleBottom":case"middle":n.x=b[0],n.y=b[1]+M,d="center",n.originY=-M;break;case"insideEndTop":case"insideEnd":case"insideEndBottom":n.x=-y*L+c[0],n.y=c[1]+M,d=_[0]>=0?"right":"left",n.originX=y*L,n.originY=-M}n.scaleX=n.scaleY=o,n.setStyle({verticalAlign:n.__verticalAlign||h,align:n.__align||d})}}}function x(t,e){var i=t.__specifiedRotation;if(null==i){var a=r.tangentAt(e);t.attr("rotation",(1===e?-1:1)*Math.PI/2-Math.atan2(a[1],a[0]))}else t.attr("rotation",i)}},e}(m),O=function(){function t(t){this.group=new m,this._LineCtor=t||w}return t.prototype.updateData=function(t){var e=this;this._progressiveEls=null;var i=this,a=i.group,n=i._lineData;i._lineData=t,n||a.removeAll();var o=C(t);t.diff(n).add((function(i){e._doAdd(t,i,o)})).update((function(i,a){e._doUpdate(n,t,a,i,o)})).remove((function(t){a.remove(n.getItemGraphicEl(t))})).execute()},t.prototype.updateLayout=function(){var t=this._lineData;t&&t.eachItemGraphicEl((function(e,i){e.updateLayout(t,i)}),this)},t.prototype.incrementalPrepareUpdate=function(t){this._seriesScope=C(t),this._lineData=null,this.group.removeAll()},t.prototype.incrementalUpdate=function(t,e){function i(t){t.isGroup||function(t){return t.animators&&t.animators.length>0}(t)||(t.incremental=!0,t.ensureState("emphasis").hoverLayer=!0)}this._progressiveEls=[];for(var a=t.start;a<t.end;a++){if(V(e.getItemLayout(a))){var n=new this._LineCtor(e,a,this._seriesScope);n.traverse(i),this.group.add(n),e.setItemGraphicEl(a,n),this._progressiveEls.push(n)}}},t.prototype.remove=function(){this.group.removeAll()},t.prototype.eachRendered=function(t){b(this._progressiveEls||this.group,t)},t.prototype._doAdd=function(t,e,i){if(V(t.getItemLayout(e))){var a=new this._LineCtor(t,e,i);t.setItemGraphicEl(e,a),this.group.add(a)}},t.prototype._doUpdate=function(t,e,i,a,n){var o=t.getItemGraphicEl(i);V(e.getItemLayout(a))?(o?o.updateData(e,a,n):o=new this._LineCtor(e,a,n),e.setItemGraphicEl(a,o),this.group.add(o)):this.group.remove(o)},t}();function C(t){var e=t.hostModel,i=e.getModel("emphasis");return{lineStyle:e.getModel("lineStyle").getLineStyle(),emphasisLineStyle:i.getModel(["lineStyle"]).getLineStyle(),blurLineStyle:e.getModel(["blur","lineStyle"]).getLineStyle(),selectLineStyle:e.getModel(["select","lineStyle"]).getLineStyle(),emphasisDisabled:i.get("disabled"),blurScope:i.get("blurScope"),focus:i.get("focus"),labelStatesModels:l(e)}}function T(t){return isNaN(t[0])||isNaN(t[1])}function V(t){return t&&!T(t[0])&&!T(t[1])}export{O as L,w as a};