basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 5.03 kB
JavaScript
import{_ as t,S as e,A as a,s as o,C as i,P as n,p as r,o as s,m as u,B as l,e as p,D as f,d as h,E as c,F as d,H as m,I as v,J as g,K as y,L as x,M as b}from"./index.js";import{W as M}from"./whiskerBoxCommon.js";import"./createSeriesDataSimply.js";var D=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=a.type,t.defaultValueDimensions=[{name:"min",defaultTooltip:!0},{name:"Q1",defaultTooltip:!0},{name:"median",defaultTooltip:!0},{name:"Q3",defaultTooltip:!0},{name:"max",defaultTooltip:!0}],t.visualDrawType="stroke",t}return t(a,e),a.type="series.boxplot",a.dependencies=["xAxis","yAxis","grid"],a.defaultOption={z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,layout:null,boxWidth:[7,50],itemStyle:{color:"#fff",borderWidth:1},emphasis:{scale:!0,itemStyle:{borderWidth:2,shadowBlur:5,shadowOffsetX:1,shadowOffsetY:1,shadowColor:"rgba(0,0,0,0.2)"}},animationDuration:800},a}(e);a(D,M,!0);var I=D,S=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=a.type,t}return t(a,e),a.prototype.render=function(t,e,a){var i=t.getData(),n=this.group,r=this._data;this._data||n.removeAll();var s="horizontal"===t.get("layout")?1:0;i.diff(r).add((function(t){if(i.hasValue(t)){var e=L(i.getItemLayout(t),i,t,s,!0);i.setItemGraphicEl(t,e),n.add(e)}})).update((function(t,e){var a=r.getItemGraphicEl(e);if(i.hasValue(t)){var u=i.getItemLayout(t);a?(o(a),N(u,a,i,t)):a=L(u,i,t,s),n.add(a),i.setItemGraphicEl(t,a)}else n.remove(a)})).remove((function(t){var e=r.getItemGraphicEl(t);e&&n.remove(e)})).execute(),this._data=i},a.prototype.remove=function(t){var e=this.group,a=this._data;this._data=null,a&&a.eachItemGraphicEl((function(t){t&&e.remove(t)}))},a.type="boxplot",a}(i),T=function(){},w=function(e){function a(t){var a=e.call(this,t)||this;return a.type="boxplotBoxPath",a}return t(a,e),a.prototype.getDefaultShape=function(){return new T},a.prototype.buildPath=function(t,e){var a=e.points,o=0;for(t.moveTo(a[o][0],a[o][1]),o++;o<4;o++)t.lineTo(a[o][0],a[o][1]);for(t.closePath();o<a.length;o++)t.moveTo(a[o][0],a[o][1]),o++,t.lineTo(a[o][0],a[o][1])},a}(n);function L(t,e,a,o,i){var n=t.ends,r=new w({shape:{points:i?B(n,o,t):n}});return N(t,r,e,a,i),r}function N(t,e,a,o,i){var n=a.hostModel;(0,l[i?"initProps":"updateProps"])(e,{shape:{points:t.ends}},n,o),e.useStyle(a.getItemVisual(o,"style")),e.style.strokeNoScale=!0,e.z2=100;var u=a.getItemModel(o),p=u.getModel("emphasis");r(e,u),s(e,p.get("focus"),p.get("blurScope"),p.get("disabled"))}function B(t,e,a){return u(t,(function(t){return(t=t.slice())[e]=a.initBaseline,t}))}var E=S,W=p;function P(t){var e=function(t){var e=[],a=[];return t.eachSeriesByType("boxplot",(function(t){var o=t.getBaseAxis(),i=f(a,o);i<0&&(i=a.length,a[i]=o,e[i]={axis:o,seriesModels:[]}),e[i].seriesModels.push(t)})),e}(t);W(e,(function(t){var e=t.seriesModels;e.length&&(!function(t){var e,a=t.axis,o=t.seriesModels,i=o.length,n=t.boxWidthList=[],r=t.boxOffsetList=[],s=[];if("category"===a.type)e=a.getBandWidth();else{var u=0;W(o,(function(t){u=Math.max(u,t.getData().count())}));var l=a.getExtent();e=Math.abs(l[1]-l[0])/u}W(o,(function(t){var a=t.get("boxWidth");h(a)||(a=[a,a]),s.push([c(a[0],e)||0,c(a[1],e)||0])}));var p=.8*e-2,f=p/i*.3,d=(p-f*(i-1))/i,m=d/2-p/2;W(o,(function(t,e){r.push(m),m+=f+d,n.push(Math.min(Math.max(d,s[e][0]),s[e][1]))}))}(t),W(e,(function(e,a){!function(t,e,a){var o=t.coordinateSystem,i=t.getData(),n=a/2,r="horizontal"===t.get("layout")?0:1,s=1-r,u=["x","y"],l=i.mapDimension(u[r]),p=i.mapDimensionsAll(u[s]);if(null==l||p.length<5)return;for(var f=0;f<i.count();f++){var h=i.get(l,f),c=x(h,p[2],f),d=x(h,p[0],f),m=x(h,p[1],f),v=x(h,p[3],f),g=x(h,p[4],f),y=[];b(y,m,!1),b(y,v,!0),y.push(d,m,g,v),M(y,d),M(y,g),M(y,c),i.setItemLayout(f,{initBaseline:c[s],ends:y})}function x(t,a,n){var u,l=i.get(a,n),p=[];return p[r]=t,p[s]=l,isNaN(t)||isNaN(l)?u=[NaN,NaN]:(u=o.dataToPoint(p))[r]+=e,u}function b(t,e,a){var o=e.slice(),i=e.slice();o[r]+=n,i[r]-=n,a?t.push(o,i):t.push(i,o)}function M(t,e){var a=e.slice(),o=e.slice();a[r]-=n,o[r]+=n,t.push(a,o)}}(e,t.boxOffsetList[a],t.boxWidthList[a])})))}))}var A={type:"echarts:boxplot",transform:function(t){var e=t.upstream;if(e.sourceFormat!==y){var a;a=x("source data is not applicable for this boxplot transform. Expect number[][]."),b(a)}var o=function(t,e){for(var a=[],o=[],i=(e=e||{}).boundIQR,n="none"===i||0===i,r=0;r<t.length;r++){var s=d(t[r].slice()),u=m(s,.25),l=m(s,.5),p=m(s,.75),f=s[0],h=s[s.length-1],c=(null==i?1.5:i)*(p-u),y=n?f:Math.max(f,u-c),x=n?h:Math.min(h,p+c),b=e.itemNameFormatter,M=v(b)?b({value:r}):g(b)?b.replace("{value}",r+""):r+"";a.push([M,y,u,l,p,x]);for(var D=0;D<s.length;D++){var I=s[D];if(I<y||I>x){var S=[M,I];o.push(S)}}}return{boxData:a,outliers:o}}(e.getRawData(),t.config);return[{dimensions:["ItemName","Low","Q1","Q2","Q3","High"],data:o.boxData},{data:o.outliers}]}};function Q(t){t.registerSeriesModel(I),t.registerChartView(E),t.registerLayout(P),t.registerTransform(A)}export{Q as install};