basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 8.04 kB
JavaScript
import{_ as e,t,f as r,u as o,s as i,C as n,P as a,p as s,m as l,S as u,A as p,d as c,e as d,N as g,O as h,h as m,Q as f,T as y,E as v,U as _}from"./index.js";import{c as S}from"./createClipPathFromCoordSys.js";import{W as b}from"./whiskerBoxCommon.js";import"./createSeriesDataSimply.js";var x=["color","borderColor"],C=function(n){function a(){var e=null!==n&&n.apply(this,arguments)||this;return e.type=a.type,e}return e(a,n),a.prototype.render=function(e,t,r){this.group.removeClipPath(),this._progressiveEls=null,this._updateDrawMode(e),this._isLargeDraw?this._renderLarge(e):this._renderNormal(e)},a.prototype.incrementalPrepareRender=function(e,t,r){this._clear(),this._updateDrawMode(e)},a.prototype.incrementalRender=function(e,t,r,o){this._progressiveEls=[],this._isLargeDraw?this._incrementalRenderLarge(e,t):this._incrementalRenderNormal(e,t)},a.prototype.eachRendered=function(e){t(this._progressiveEls||this.group,e)},a.prototype._updateDrawMode=function(e){var t=e.pipelineContext.large;null!=this._isLargeDraw&&t===this._isLargeDraw||(this._isLargeDraw=t,this._clear())},a.prototype._renderNormal=function(e){var t=e.getData(),n=this._data,a=this.group,s=t.getLayout("isSimpleBox"),l=e.get("clip",!0),u=e.coordinateSystem,p=u.getArea&&u.getArea();this._data||a.removeAll(),t.diff(n).add((function(o){if(t.hasValue(o)){var i=t.getItemLayout(o);if(l&&L(p,i))return;var n=T(i,o,!0);r(n,{shape:{points:i.ends}},e,o),w(n,t,o,s),a.add(n),t.setItemGraphicEl(o,n)}})).update((function(r,u){var c=n.getItemGraphicEl(u);if(t.hasValue(r)){var d=t.getItemLayout(r);l&&L(p,d)?a.remove(c):(c?(o(c,{shape:{points:d.ends}},e,r),i(c)):c=T(d),w(c,t,r,s),a.add(c),t.setItemGraphicEl(r,c))}else a.remove(c)})).remove((function(e){var t=n.getItemGraphicEl(e);t&&a.remove(t)})).execute(),this._data=t},a.prototype._renderLarge=function(e){this._clear(),k(e,this.group);var t=e.get("clip",!0)?S(e.coordinateSystem,!1,e):null;t?this.group.setClipPath(t):this.group.removeClipPath()},a.prototype._incrementalRenderNormal=function(e,t){for(var r,o=t.getData(),i=o.getLayout("isSimpleBox");null!=(r=e.next());){var n=T(o.getItemLayout(r));w(n,o,r,i),n.incremental=!0,this.group.add(n),this._progressiveEls.push(n)}},a.prototype._incrementalRenderLarge=function(e,t){k(t,this.group,this._progressiveEls,!0)},a.prototype.remove=function(e){this._clear()},a.prototype._clear=function(){this.group.removeAll(),this._data=null},a.type="candlestick",a}(n),N=function(){},D=function(t){function r(e){var r=t.call(this,e)||this;return r.type="normalCandlestickBox",r}return e(r,t),r.prototype.getDefaultShape=function(){return new N},r.prototype.buildPath=function(e,t){var r=t.points;this.__simpleBox?(e.moveTo(r[4][0],r[4][1]),e.lineTo(r[6][0],r[6][1])):(e.moveTo(r[0][0],r[0][1]),e.lineTo(r[1][0],r[1][1]),e.lineTo(r[2][0],r[2][1]),e.lineTo(r[3][0],r[3][1]),e.closePath(),e.moveTo(r[4][0],r[4][1]),e.lineTo(r[5][0],r[5][1]),e.moveTo(r[6][0],r[6][1]),e.lineTo(r[7][0],r[7][1]))},r}(a);function T(e,t,r){var o=e.ends;return new D({shape:{points:r?I(o,e):o},z2:100})}function L(e,t){for(var r=!0,o=0;o<t.ends.length;o++)if(e.contain(t.ends[o][0],t.ends[o][1])){r=!1;break}return r}function w(e,t,r,o){var i=t.getItemModel(r);e.useStyle(t.getItemVisual(r,"style")),e.style.strokeNoScale=!0,e.__simpleBox=o,s(e,i)}function I(e,t){return l(e,(function(e){return(e=e.slice())[1]=t.initBaseline,e}))}var M=function(){},P=function(t){function r(e){var r=t.call(this,e)||this;return r.type="largeCandlestickBox",r}return e(r,t),r.prototype.getDefaultShape=function(){return new M},r.prototype.buildPath=function(e,t){for(var r=t.points,o=0;o<r.length;)if(this.__sign===r[o++]){var i=r[o++];e.moveTo(i,r[o++]),e.lineTo(i,r[o++])}else o+=3},r}(a);function k(e,t,r,o){var i=e.getData().getLayout("largePoints"),n=new P({shape:{points:i},__sign:1,ignoreCoarsePointer:!0});t.add(n);var a=new P({shape:{points:i},__sign:-1,ignoreCoarsePointer:!0});t.add(a);var s=new P({shape:{points:i},__sign:0,ignoreCoarsePointer:!0});t.add(s),B(1,n,e),B(-1,a,e),B(0,s,e),o&&(n.incremental=!0,a.incremental=!0),r&&r.push(n,a)}function B(e,t,r,o){var i=r.get(["itemStyle",e>0?"borderColor":"borderColor0"])||r.get(["itemStyle",e>0?"color":"color0"]);0===e&&(i=r.get(["itemStyle","borderColorDoji"]));var n=r.getModel("itemStyle").getItemStyle(x);t.useStyle(n),t.style.fill=null,t.style.stroke=i}var E=C,W=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=r.type,e.defaultValueDimensions=[{name:"open",defaultTooltip:!0},{name:"close",defaultTooltip:!0},{name:"lowest",defaultTooltip:!0},{name:"highest",defaultTooltip:!0}],e}return e(r,t),r.prototype.getShadowDim=function(){return"open"},r.prototype.brushSelector=function(e,t,r){var o=t.getItemLayout(e);return o&&r.rect(o.brushRect)},r.type="series.candlestick",r.dependencies=["xAxis","yAxis","grid"],r.defaultOption={z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,layout:null,clip:!0,itemStyle:{color:"#eb5454",color0:"#47b262",borderColor:"#eb5454",borderColor0:"#47b262",borderColorDoji:null,borderWidth:1},emphasis:{scale:!0,itemStyle:{borderWidth:2}},barMaxWidth:null,barMinWidth:null,barWidth:null,large:!0,largeThreshold:600,progressive:3e3,progressiveThreshold:1e4,progressiveChunkMode:"mod",animationEasing:"linear",animationDuration:300},r}(u);p(W,b,!0);var R=W;function j(e){e&&c(e.series)&&d(e.series,(function(e){g(e)&&"k"===e.type&&(e.type="candlestick")}))}var A=["itemStyle","borderColor"],V=["itemStyle","borderColor0"],G=["itemStyle","borderColorDoji"],z=["itemStyle","color"],F=["itemStyle","color0"],O={seriesType:"candlestick",plan:h(),performRawSeries:!0,reset:function(e,t){function r(e,t){return t.get(e>0?z:F)}function o(e,t){return t.get(0===e?G:e>0?A:V)}if(!t.isSeriesFiltered(e))return!e.pipelineContext.large&&{progress:function(e,t){for(var i;null!=(i=e.next());){var n=t.getItemModel(i),a=t.getItemLayout(i).sign,s=n.getItemStyle();s.fill=r(a,n),s.stroke=o(a,n)||s.fill;var l=t.ensureUniqueItemVisual(i,"style");m(l,s)}}}}};function U(e,t,r,o,i,n){return r>o?-1:r<o?1:n?0:t>0?e.get(i,t-1)<=o?1:-1:1}var q={seriesType:"candlestick",plan:h(),reset:function(e){var t=e.coordinateSystem,r=e.getData(),o=function(e,t){var r,o=e.getBaseAxis(),i="category"===o.type?o.getBandWidth():(r=o.getExtent(),Math.abs(r[1]-r[0])/t.count()),n=v(_(e.get("barMaxWidth"),i),i),a=v(_(e.get("barMinWidth"),1),i),s=e.get("barWidth");return null!=s?v(s,i):Math.max(Math.min(i/2,n),a)}(e,r),i=["x","y"],n=r.getDimensionIndex(r.mapDimension(i[0])),a=l(r.mapDimensionsAll(i[1]),r.getDimensionIndex,r),s=a[0],u=a[1],p=a[2],c=a[3];if(r.setLayout({candleWidth:o,isSimpleBox:o<=1.3}),!(n<0||a.length<4))return{progress:e.pipelineContext.large?function(r,o){var i,a,l=y(4*r.count),d=0,g=[],h=[],m=o.getStore(),f=!!e.get(["itemStyle","borderColorDoji"]);for(;null!=(a=r.next());){var v=m.get(n,a),_=m.get(s,a),S=m.get(u,a),b=m.get(p,a),x=m.get(c,a);isNaN(v)||isNaN(b)||isNaN(x)?(l[d++]=NaN,d+=3):(l[d++]=U(m,a,_,S,u,f),g[0]=v,g[1]=b,i=t.dataToPoint(g,null,h),l[d++]=i?i[0]:NaN,l[d++]=i?i[1]:NaN,g[1]=x,i=t.dataToPoint(g,null,h),l[d++]=i?i[1]:NaN)}o.setLayout("largePoints",l)}:function(e,r){var i,a=r.getStore();for(;null!=(i=e.next());){var l=a.get(n,i),d=a.get(s,i),g=a.get(u,i),h=a.get(p,i),m=a.get(c,i),y=Math.min(d,g),v=Math.max(d,g),_=D(y,l),S=D(v,l),b=D(h,l),x=D(m,l),C=[];T(C,S,0),T(C,_,1),C.push(w(x),w(S),w(b),w(_));var N=!!r.getItemModel(i).get(["itemStyle","borderColorDoji"]);r.setItemLayout(i,{sign:U(a,i,d,g,u,N),initBaseline:d>g?S[1]:_[1],ends:C,brushRect:L(h,m,l)})}function D(e,r){var o=[];return o[0]=r,o[1]=e,isNaN(r)||isNaN(e)?[NaN,NaN]:t.dataToPoint(o)}function T(e,t,r){var i=t.slice(),n=t.slice();i[0]=f(i[0]+o/2,1,!1),n[0]=f(n[0]-o/2,1,!0),r?e.push(i,n):e.push(n,i)}function L(e,t,r){var i=D(e,r),n=D(t,r);return i[0]-=o/2,n[0]-=o/2,{x:i[0],y:i[1],width:o,height:n[1]-i[1]}}function w(e){return e[0]=f(e[0],1),e}}}}};function H(e){e.registerChartView(E),e.registerSeriesModel(R),e.registerPreprocessor(j),e.registerVisual(O),e.registerLayout(q)}export{H as install};