basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 9.09 kB
JavaScript
import{_ as e,P as t,ar as i,e as r,E as a,as as n,at as o,a9 as l,a0 as s,f as g,aq as d,au as h,u as c,a8 as p,h as u,p as f,o as y,ae as m,G as v,n as w,av as x,C as M,J as S,I as A,v as I,b,S as C}from"./index.js";import{S as _}from"./sausage.js";import{c as k}from"./createSeriesDataSimply.js";var P=function(){this.angle=0,this.width=10,this.r=10,this.x=0,this.y=0},E=function(t){function i(e){var i=t.call(this,e)||this;return i.type="pointer",i}return e(i,t),i.prototype.getDefaultShape=function(){return new P},i.prototype.buildPath=function(e,t){var i=Math.cos,r=Math.sin,a=t.r,n=t.width,o=t.angle,l=t.x-i(o)*n*(n>=a/3?1:2),s=t.y-r(o)*n*(n>=a/3?1:2);o=t.angle-Math.PI/2,e.moveTo(l,s),e.lineTo(t.x+i(o)*n,t.y+r(o)*n),e.lineTo(t.x+i(t.angle)*a,t.y+r(t.angle)*a),e.lineTo(t.x-i(o)*n,t.y-r(o)*n),e.lineTo(l,s)},i}(t);function L(e,t){var i=null==e?"":e+"";return t&&(S(t)?i=t.replace("{value}",i):A(t)&&(i=t(e))),i}var N=function(t){function M(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=M.type,e}return e(M,t),M.prototype.render=function(e,t,i){this.group.removeAll();var r=e.get(["axisLine","lineStyle","color"]),n=function(e,t){var i=e.get("center"),r=t.getWidth(),n=t.getHeight(),o=Math.min(r,n);return{cx:a(i[0],t.getWidth()),cy:a(i[1],t.getHeight()),r:a(e.get("radius"),o/2)}}(e,i);this._renderMain(e,t,i,r,n),this._data=e.getData()},M.prototype.dispose=function(){},M.prototype._renderMain=function(e,t,a,n,o){var l=this.group,s=e.get("clockwise"),g=-e.get("startAngle")/180*Math.PI,d=-e.get("endAngle")/180*Math.PI,h=e.getModel("axisLine"),c=h.get("roundCap")?_:I,p=h.get("show"),u=h.getModel("lineStyle"),f=u.get("width"),y=[g,d];i(y,!s);for(var m=(d=y[1])-(g=y[0]),v=g,w=[],x=0;p&&x<n.length;x++){var M=new c({shape:{startAngle:v,endAngle:d=g+m*Math.min(Math.max(n[x][0],0),1),cx:o.cx,cy:o.cy,clockwise:s,r0:o.r-f,r:o.r},silent:!0});M.setStyle({fill:n[x][1]}),M.setStyle(u.getLineStyle(["color","width"])),w.push(M),v=d}w.reverse(),r(w,(function(e){return l.add(e)}));var S=function(e){if(e<=0)return n[0][1];var t;for(t=0;t<n.length;t++)if(n[t][0]>=e&&(0===t?0:n[t-1][0])<e)return n[t][1];return n[t-1][1]};this._renderTicks(e,t,a,S,o,g,d,s,f),this._renderTitleAndDetail(e,t,a,S,o),this._renderAnchor(e,o),this._renderPointer(e,t,a,S,o,g,d,s,f)},M.prototype._renderTicks=function(e,t,i,r,g,d,h,c,p){for(var u,f,y=this.group,m=g.cx,v=g.cy,w=g.r,x=+e.get("min"),M=+e.get("max"),S=e.getModel("splitLine"),A=e.getModel("axisTick"),I=e.getModel("axisLabel"),C=e.get("splitNumber"),_=A.get("splitNumber"),k=a(S.get("length"),w),P=a(A.get("length"),w),E=d,N=(h-d)/C,T=N/_,z=S.getModel("lineStyle").getLineStyle(),D=A.getModel("lineStyle").getLineStyle(),G=S.get("distance"),V=0;V<=C;V++){if(u=Math.cos(E),f=Math.sin(E),S.get("show")){var W=new n({shape:{x1:u*(w-(H=G?G+p:p))+m,y1:f*(w-H)+v,x2:u*(w-k-H)+m,y2:f*(w-k-H)+v},style:z,silent:!0});"auto"===z.stroke&&W.setStyle({stroke:r(V/C)}),y.add(W)}if(I.get("show")){var H=I.get("distance")+G,j=L(o(V/C*(M-x)+x),I.get("formatter")),B=r(V/C),F=u*(w-k-H)+m,q=f*(w-k-H)+v,J=I.get("rotate"),O=0;"radial"===J?(O=-E+2*Math.PI)>Math.PI/2&&(O+=Math.PI):"tangential"===J?O=-E-Math.PI/2:b(J)&&(O=J*Math.PI/180),0===O?y.add(new l({style:s(I,{text:j,x:F,y:q,verticalAlign:f<-.8?"top":f>.8?"bottom":"middle",align:u<-.4?"left":u>.4?"right":"center"},{inheritColor:B}),silent:!0})):y.add(new l({style:s(I,{text:j,x:F,y:q,verticalAlign:"middle",align:"center"},{inheritColor:B}),silent:!0,originX:F,originY:q,rotation:O}))}if(A.get("show")&&V!==C){H=(H=A.get("distance"))?H+p:p;for(var X=0;X<=_;X++){u=Math.cos(E),f=Math.sin(E);var Y=new n({shape:{x1:u*(w-H)+m,y1:f*(w-H)+v,x2:u*(w-P-H)+m,y2:f*(w-P-H)+v},silent:!0,style:D});"auto"===D.stroke&&Y.setStyle({stroke:r((V+X/_)/C)}),y.add(Y),E+=T}E-=T}else E+=N}},M.prototype._renderPointer=function(e,t,i,r,n,o,l,s,v){var w=this.group,x=this._data,M=this._progressEls,S=[],A=e.get(["pointer","show"]),b=e.getModel("progress"),C=b.get("show"),k=e.getData(),P=k.mapDimension("value"),L=+e.get("min"),N=+e.get("max"),T=[L,N],z=[o,l];function D(t,i){var r,o=k.getItemModel(t).getModel("pointer"),l=a(o.get("width"),n.r),s=a(o.get("length"),n.r),g=e.get(["pointer","icon"]),d=o.get("offsetCenter"),h=a(d[0],n.r),c=a(d[1],n.r),p=o.get("keepAspect");return(r=g?m(g,h-l/2,c-s,l,s,null,p):new E({shape:{angle:-Math.PI/2,width:l,r:s,x:h,y:c}})).rotation=-(i+Math.PI/2),r.x=n.cx,r.y=n.cy,r}function G(e,t){var i=b.get("roundCap")?_:I,r=b.get("overlap"),a=r?b.get("width"):v/k.count(),l=r?n.r-a:n.r-(e+1)*a,g=r?n.r:n.r-e*a,d=new i({shape:{startAngle:o,endAngle:t,cx:n.cx,cy:n.cy,clockwise:s,r0:l,r:g}});return r&&(d.z2=N-k.get(P,e)%N),d}(C||A)&&(k.diff(x).add((function(t){var i=k.get(P,t);if(A){var r=D(t,o);g(r,{rotation:-((isNaN(+i)?z[0]:d(i,T,z,!0))+Math.PI/2)},e),w.add(r),k.setItemGraphicEl(t,r)}if(C){var a=G(t,o),n=b.get("clip");g(a,{shape:{endAngle:d(i,T,z,n)}},e),w.add(a),h(e.seriesIndex,k.dataType,t,a),S[t]=a}})).update((function(t,i){var r=k.get(P,t);if(A){var a=x.getItemGraphicEl(i),n=a?a.rotation:o,l=D(t,n);l.rotation=n,c(l,{rotation:-((isNaN(+r)?z[0]:d(r,T,z,!0))+Math.PI/2)},e),w.add(l),k.setItemGraphicEl(t,l)}if(C){var s=M[i],g=G(t,s?s.shape.endAngle:o),p=b.get("clip");c(g,{shape:{endAngle:d(r,T,z,p)}},e),w.add(g),h(e.seriesIndex,k.dataType,t,g),S[t]=g}})).execute(),k.each((function(e){var t=k.getItemModel(e),i=t.getModel("emphasis"),a=i.get("focus"),n=i.get("blurScope"),o=i.get("disabled");if(A){var l=k.getItemGraphicEl(e),s=k.getItemVisual(e,"style"),g=s.fill;if(l instanceof p){var h=l.style;l.useStyle(u({image:h.image,x:h.x,y:h.y,width:h.width,height:h.height},s))}else l.useStyle(s),"pointer"!==l.type&&l.setColor(g);l.setStyle(t.getModel(["pointer","itemStyle"]).getItemStyle()),"auto"===l.style.fill&&l.setStyle("fill",r(d(k.get(P,e),T,[0,1],!0))),l.z2EmphasisLift=0,f(l,t),y(l,a,n,o)}if(C){var c=S[e];c.useStyle(k.getItemVisual(e,"style")),c.setStyle(t.getModel(["progress","itemStyle"]).getItemStyle()),c.z2EmphasisLift=0,f(c,t),y(c,a,n,o)}})),this._progressEls=S)},M.prototype._renderAnchor=function(e,t){var i=e.getModel("anchor");if(i.get("show")){var r=i.get("size"),n=i.get("icon"),o=i.get("offsetCenter"),l=i.get("keepAspect"),s=m(n,t.cx-r/2+a(o[0],t.r),t.cy-r/2+a(o[1],t.r),r,r,null,l);s.z2=i.get("showAbove")?1:0,s.setStyle(i.getModel("itemStyle").getItemStyle()),this.group.add(s)}},M.prototype._renderTitleAndDetail=function(e,t,i,r,n){var o=this,g=e.getData(),h=g.mapDimension("value"),c=+e.get("min"),p=+e.get("max"),u=new v,f=[],y=[],m=e.isAnimationEnabled(),M=e.get(["pointer","showAbove"]);g.diff(this._data).add((function(e){f[e]=new l({silent:!0}),y[e]=new l({silent:!0})})).update((function(e,t){f[e]=o._titleEls[t],y[e]=o._detailEls[t]})).execute(),g.each((function(t){var i=g.getItemModel(t),o=g.get(h,t),l=new v,S=r(d(o,[c,p],[0,1],!0)),A=i.getModel("title");if(A.get("show")){var I=A.get("offsetCenter"),b=n.cx+a(I[0],n.r),C=n.cy+a(I[1],n.r);(D=f[t]).attr({z2:M?0:2,style:s(A,{x:b,y:C,text:g.getName(t),align:"center",verticalAlign:"middle"},{inheritColor:S})}),l.add(D)}var _=i.getModel("detail");if(_.get("show")){var k=_.get("offsetCenter"),P=n.cx+a(k[0],n.r),E=n.cy+a(k[1],n.r),N=a(_.get("width"),n.r),T=a(_.get("height"),n.r),z=e.get(["progress","show"])?g.getItemVisual(t,"style").fill:S,D=y[t],G=_.get("formatter");D.attr({z2:M?0:2,style:s(_,{x:P,y:E,text:L(o,G),width:isNaN(N)?null:N,height:isNaN(T)?null:T,align:"center",verticalAlign:"middle"},{inheritColor:z})}),w(D,{normal:_},o,(function(e){return L(e,G)})),m&&x(D,t,g,e,{getFormattedLabel:function(e,t,i,r,a,n){return L(n?n.interpolatedValue:o,G)}}),l.add(D)}u.add(l)})),this.group.add(u),this._titleEls=f,this._detailEls=y},M.type="gauge",M}(M),T=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=i.type,e.visualStyleAccessPath="itemStyle",e}return e(i,t),i.prototype.getInitialData=function(e,t){return k(this,["value"])},i.type="series.gauge",i.defaultOption={z:2,colorBy:"data",center:["50%","50%"],legendHoverLink:!0,radius:"75%",startAngle:225,endAngle:-45,clockwise:!0,min:0,max:100,splitNumber:10,axisLine:{show:!0,roundCap:!1,lineStyle:{color:[[1,"#E6EBF8"]],width:10}},progress:{show:!1,overlap:!0,width:10,roundCap:!1,clip:!0},splitLine:{show:!0,length:10,distance:10,lineStyle:{color:"#63677A",width:3,type:"solid"}},axisTick:{show:!0,splitNumber:5,length:6,distance:10,lineStyle:{color:"#63677A",width:1,type:"solid"}},axisLabel:{show:!0,distance:15,color:"#464646",fontSize:12,rotate:0},pointer:{icon:null,offsetCenter:[0,0],show:!0,showAbove:!0,length:"60%",width:6,keepAspect:!1},anchor:{show:!1,showAbove:!1,size:6,icon:"circle",offsetCenter:[0,0],keepAspect:!1,itemStyle:{color:"#fff",borderWidth:0,borderColor:"#5470c6"}},title:{show:!0,offsetCenter:[0,"20%"],color:"#464646",fontSize:16,valueAnimation:!1},detail:{show:!0,backgroundColor:"rgba(0,0,0,0)",borderWidth:0,borderColor:"#ccc",width:100,height:null,padding:[5,10],offsetCenter:[0,"40%"],color:"#464646",fontSize:30,fontWeight:"bold",lineHeight:30,valueAnimation:!1}},i}(C);function z(e){e.registerChartView(N),e.registerSeriesModel(T)}export{z as install};