basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 29.9 kB
JavaScript
import{bh as t,d as e,_ as i,Y as n,bA as o,e as a,J as r,I as s,bQ as l,bV as p,F as u,aq as h,i as c,da as d,R as v,bB as g,bU as f,ap as y,a9 as m,a0 as _,G as S,bs as M,ae as x,cb as b,bI as I,a8 as L,h as V,aV as w,ca as T,c8 as O,dL as R,ct as C,g as z,c9 as k,am as D,dM as H,N as P,m as E,dN as A,aY as B,cU as F,b9 as G}from"./index.js";import{V as N}from"./VisualMapping.js";import{r as W,c as K,i as U}from"./visualSolution.js";import{s as X}from"./sliderMove.js";var Y=function(i,n,o){var a=t((j[i]||{})[n]);return o&&e(a)?a[a.length-1]:a},j={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},Z=N.mapVisual,q=N.eachVisual,J=e,Q=a,$=u,tt=h,et=function(p){function u(){var t=null!==p&&p.apply(this,arguments)||this;return t.type=u.type,t.stateList=["inRange","outOfRange"],t.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],t.layoutMode={type:"box",ignoreSize:!0},t.dataBound=[-1/0,1/0],t.targetVisuals={},t.controllerVisuals={},t}return i(u,p),u.prototype.init=function(t,e,i){this.mergeDefaultAndTheme(t,i)},u.prototype.optionUpdated=function(t,e){var i=this.option;!e&&W(i,t,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},u.prototype.resetVisual=function(t){var e=this.stateList;t=n(t,this),this.controllerVisuals=K(this.option.controller,e,t),this.targetVisuals=K(this.option.target,e,t)},u.prototype.getItemSymbol=function(){return null},u.prototype.getTargetSeriesIndices=function(){var t=this.option.seriesIndex,e=[];return null==t||"all"===t?this.ecModel.eachSeries((function(t,i){e.push(i)})):e=o(t),e},u.prototype.eachTargetSeries=function(t,e){a(this.getTargetSeriesIndices(),(function(i){var n=this.ecModel.getSeriesByIndex(i);n&&t.call(e,n)}),this)},u.prototype.isTargetSeries=function(t){var e=!1;return this.eachTargetSeries((function(i){i===t&&(e=!0)})),e},u.prototype.formatValueText=function(t,i,n){var o,a=this.option,l=a.precision,p=this.dataBound,u=a.formatter;n=n||["<",">"],e(t)&&(t=t.slice(),o=!0);var h=i?t:o?[c(t[0]),c(t[1])]:c(t);return r(u)?u.replace("{value}",o?h[0]:h).replace("{value2}",o?h[1]:h):s(u)?o?u(t[0],t[1]):u(t):o?t[0]===p[0]?n[0]+" "+h[1]:t[1]===p[1]?n[1]+" "+h[0]:h[0]+" - "+h[1]:h;function c(t){return t===p[0]?"min":t===p[1]?"max":(+t).toFixed(Math.min(l,20))}},u.prototype.resetExtent=function(){var t=this.option,e=$([t.min,t.max]);this._dataExtent=e},u.prototype.getDataDimensionIndex=function(t){var e=this.option.dimension;if(null!=e)return t.getDimensionIndex(e);for(var i=t.dimensions,n=i.length-1;n>=0;n--){var o=i[n],a=t.getDimensionInfo(o);if(!a.isCalculationCoord)return a.storeDimIndex}},u.prototype.getExtent=function(){return this._dataExtent.slice()},u.prototype.completeVisualOption=function(){var e=this.ecModel,i=this.option,n={inRange:i.inRange,outOfRange:i.outOfRange},o=i.target||(i.target={}),a=i.controller||(i.controller={});l(o,n),l(a,n);var r=this.isCategory();function s(t){J(i.color)&&!t.inRange&&(t.inRange={color:i.color.slice().reverse()}),t.inRange=t.inRange||{color:e.get("gradientColor")}}s.call(this,o),s.call(this,a),function(t,e,i){var n=t[e],o=t[i];n&&!o&&(o=t[i]={},Q(n,(function(t,e){if(N.isValidType(e)){var i=Y(e,"inactive",r);null!=i&&(o[e]=i,"color"!==e||o.hasOwnProperty("opacity")||o.hasOwnProperty("colorAlpha")||(o.opacity=[0,0]))}})))}.call(this,o,"inRange","outOfRange"),function(e){var i=(e.inRange||{}).symbol||(e.outOfRange||{}).symbol,n=(e.inRange||{}).symbolSize||(e.outOfRange||{}).symbolSize,o=this.get("inactiveColor"),a=this.getItemSymbol()||"roundRect";Q(this.stateList,(function(s){var l=this.itemSize,p=e[s];p||(p=e[s]={color:r?o:[o]}),null==p.symbol&&(p.symbol=i&&t(i)||(r?a:[a])),null==p.symbolSize&&(p.symbolSize=n&&t(n)||(r?l[0]:[l[0],l[0]])),p.symbol=Z(p.symbol,(function(t){return"none"===t?a:t}));var u=p.symbolSize;if(null!=u){var h=-1/0;q(u,(function(t){t>h&&(h=t)})),p.symbolSize=Z(u,(function(t){return tt(t,[0,h],[0,l[0]],!0)}))}}),this)}.call(this,a)},u.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},u.prototype.isCategory=function(){return!!this.option.categories},u.prototype.setSelected=function(t){},u.prototype.getSelected=function(){return null},u.prototype.getValueState=function(t){return null},u.prototype.getVisualMeta=function(t){return null},u.type="visualMap",u.dependencies=["series"],u.defaultOption={show:!0,z:4,seriesIndex:"all",min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",contentColor:"#5793f3",inactiveColor:"#aaa",borderWidth:0,padding:5,textGap:10,precision:0,textStyle:{color:"#333"}},u}(p),it=[20,140],nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=n.type,e}return i(n,t),n.prototype.optionUpdated=function(e,i){t.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual((function(t){t.mappingMethod="linear",t.dataExtent=this.getExtent()})),this._resetRange()},n.prototype.resetItemSize=function(){t.prototype.resetItemSize.apply(this,arguments);var e=this.itemSize;(null==e[0]||isNaN(e[0]))&&(e[0]=it[0]),(null==e[1]||isNaN(e[1]))&&(e[1]=it[1])},n.prototype._resetRange=function(){var t=this.getExtent(),i=this.option.range;!i||i.auto?(t.auto=1,this.option.range=t):e(i)&&(i[0]>i[1]&&i.reverse(),i[0]=Math.max(i[0],t[0]),i[1]=Math.min(i[1],t[1]))},n.prototype.completeVisualOption=function(){t.prototype.completeVisualOption.apply(this,arguments),a(this.stateList,(function(t){var e=this.option.controller[t].symbolSize;e&&e[0]!==e[1]&&(e[0]=e[1]/3)}),this)},n.prototype.setSelected=function(t){this.option.range=t.slice(),this._resetRange()},n.prototype.getSelected=function(){var t=this.getExtent(),e=u((this.get("range")||[]).slice());return e[0]>t[1]&&(e[0]=t[1]),e[1]>t[1]&&(e[1]=t[1]),e[0]<t[0]&&(e[0]=t[0]),e[1]<t[0]&&(e[1]=t[0]),e},n.prototype.getValueState=function(t){var e=this.option.range,i=this.getExtent();return(e[0]<=i[0]||e[0]<=t)&&(e[1]>=i[1]||t<=e[1])?"inRange":"outOfRange"},n.prototype.findTargetDataIndices=function(t){var e=[];return this.eachTargetSeries((function(i){var n=[],o=i.getData();o.each(this.getDataDimensionIndex(o),(function(e,i){t[0]<=e&&e<=t[1]&&n.push(i)}),this),e.push({seriesId:i.id,dataIndex:n})}),this),e},n.prototype.getVisualMeta=function(t){var e=ot(this,"outOfRange",this.getExtent()),i=ot(this,"inRange",this.option.range.slice()),n=[];function o(e,i){n.push({value:e,color:t(e,i)})}for(var a=0,r=0,s=i.length,l=e.length;r<l&&(!i.length||e[r]<=i[0]);r++)e[r]<i[a]&&o(e[r],"outOfRange");for(var p=1;a<s;a++,p=0)p&&n.length&&o(i[a],"outOfRange"),o(i[a],"inRange");for(p=1;r<l;r++)(!i.length||i[i.length-1]<e[r])&&(p&&(n.length&&o(n[n.length-1].value,"outOfRange"),p=0),o(e[r],"outOfRange"));var u=n.length;return{stops:n,outerColors:[u?n[0].color:"transparent",u?n[u-1].color:"transparent"]}},n.type="visualMap.continuous",n.defaultOption=c(et.defaultOption,{align:"auto",calculable:!1,hoverLink:!0,realtime:!0,handleIcon:"path://M-11.39,9.77h0a3.5,3.5,0,0,1-3.5,3.5h-22a3.5,3.5,0,0,1-3.5-3.5h0a3.5,3.5,0,0,1,3.5-3.5h22A3.5,3.5,0,0,1-11.39,9.77Z",handleSize:"120%",handleStyle:{borderColor:"#fff",borderWidth:1},indicatorIcon:"circle",indicatorSize:"50%",indicatorStyle:{borderColor:"#fff",borderWidth:2,shadowBlur:2,shadowOffsetX:1,shadowOffsetY:1,shadowColor:"rgba(0,0,0,0.2)"}}),n}(et);function ot(t,e,i){if(i[0]===i[1])return i.slice();for(var n=(i[1]-i[0])/200,o=i[0],a=[],r=0;r<=200&&o<i[1];r++)a.push(o),o+=n;return a.push(i[1]),a}var at=nt,rt=function(t){function e(){var i=null!==t&&t.apply(this,arguments)||this;return i.type=e.type,i.autoPositionValues={left:1,right:1,top:1,bottom:1},i}return i(e,t),e.prototype.init=function(t,e){this.ecModel=t,this.api=e},e.prototype.render=function(t,e,i,n){this.visualMapModel=t,!1!==t.get("show")?this.doRender(t,e,i,n):this.group.removeAll()},e.prototype.renderBackground=function(t){var e=this.visualMapModel,i=d(e.get("padding")||0),n=t.getBoundingRect();t.add(new v({z2:-1,silent:!0,shape:{x:n.x-i[3],y:n.y-i[0],width:n.width+i[3]+i[1],height:n.height+i[0]+i[2]},style:{fill:e.get("backgroundColor"),stroke:e.get("borderColor"),lineWidth:e.get("borderWidth")}}))},e.prototype.getControllerVisual=function(t,e,i){var n=(i=i||{}).forceState,o=this.visualMapModel,r={};if("color"===e){var s=o.get("contentColor");r.color=s}function l(t){return r[t]}function p(t,e){r[t]=e}var u=o.controllerVisuals[n||o.getValueState(t)],h=N.prepareVisualTypes(u);return a(h,(function(n){var o=u[n];i.convertOpacityToAlpha&&"opacity"===n&&(n="colorAlpha",o=u.__alphaForOpacity),N.dependsOn(n,e)&&o&&o.applyVisual(t,l,p)})),r[e]},e.prototype.positionGroup=function(t){var e=this.visualMapModel,i=this.api;g(t,e.getBoxLayoutParams(),{width:i.getWidth(),height:i.getHeight()})},e.prototype.doRender=function(t,e,i,n){},e.type="visualMap",e}(f),st=[["left","right","width"],["top","bottom","height"]];function lt(t,e,i){var n=t.option,o=n.align;if(null!=o&&"auto"!==o)return o;for(var a={width:e.getWidth(),height:e.getHeight()},r="horizontal"===n.orient?1:0,s=st[r],l=[0,null,10],p={},u=0;u<3;u++)p[st[1-r][u]]=l[u],p[s[u]]=2===u?i[0]:n[s[u]];var h=[["x","width",3],["y","height",0]][r],c=y(p,a,n.padding);return s[(c.margin[h[2]]||0)+c[h[0]]+.5*c[h[1]]<.5*a[h[1]]?0:1]}function pt(t,e){return a(t||[],(function(t){null!=t.dataIndex&&(t.dataIndexInside=t.dataIndex,t.dataIndex=null),t.highlightKey="visualMap"+(e?e.componentIndex:"")})),t}var ut=h,ht=a,ct=Math.min,dt=Math.max;function vt(t,e,i,n){return new D({shape:{points:t},draggable:!!i,cursor:e,drift:i,onmousemove:function(t){b(t.event)},ondragend:n})}function gt(t){var e=t.get("hoverLinkOnHandle");return!!(null==e?t.get("realtime"):e)}function ft(t){return"vertical"===t?"ns-resize":"ew-resize"}var yt=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.type,e._shapes={},e._dataInterval=[],e._handleEnds=[],e._hoverLinkDataIndices=[],e}return i(o,t),o.prototype.init=function(e,i){t.prototype.init.call(this,e,i),this._hoverLinkFromSeriesMouseOver=n(this._hoverLinkFromSeriesMouseOver,this),this._hideIndicator=n(this._hideIndicator,this)},o.prototype.doRender=function(t,e,i,n){n&&"selectDataRange"===n.type&&n.from===this.uid||this._buildView()},o.prototype._buildView=function(){this.group.removeAll();var t=this.visualMapModel,e=this.group;this._orient=t.get("orient"),this._useHandle=t.get("calculable"),this._resetInterval(),this._renderBar(e);var i=t.get("text");this._renderEndsText(e,i,0),this._renderEndsText(e,i,1),this._updateView(!0),this.renderBackground(e),this._updateView(),this._enableHoverLinkToSeries(),this._enableHoverLinkFromSeries(),this.positionGroup(e)},o.prototype._renderEndsText=function(t,e,i){if(e){var n=e[1-i];n=null!=n?n+"":"";var o=this.visualMapModel,a=o.get("textGap"),r=o.itemSize,s=this._shapes.mainGroup,l=this._applyTransform([r[0]/2,0===i?-a:r[1]+a],s),p=this._applyTransform(0===i?"bottom":"top",s),u=this._orient,h=this.visualMapModel.textStyleModel;this.group.add(new m({style:_(h,{x:l[0],y:l[1],verticalAlign:"horizontal"===u?"middle":p,align:"horizontal"===u?p:"center",text:n})}))}},o.prototype._renderBar=function(t){var e=this.visualMapModel,i=this._shapes,o=e.itemSize,a=this._orient,r=this._useHandle,s=lt(e,this.api,o),l=i.mainGroup=this._createBarGroup(s),p=new S;l.add(p),p.add(i.outOfRange=vt()),p.add(i.inRange=vt(null,r?ft(this._orient):null,n(this._dragHandle,this,"all",!1),n(this._dragHandle,this,"all",!0))),p.setClipPath(new v({shape:{x:0,y:0,width:o[0],height:o[1],r:3}}));var u=e.textStyleModel.getTextRect("国"),h=dt(u.width,u.height);r&&(i.handleThumbs=[],i.handleLabels=[],i.handleLabelPoints=[],this._createHandle(e,l,0,o,h,a),this._createHandle(e,l,1,o,h,a)),this._createIndicator(e,l,o,h,a),t.add(l)},o.prototype._createHandle=function(t,e,i,o,a,r){var s=n(this._dragHandle,this,i,!1),l=n(this._dragHandle,this,i,!0),p=M(t.get("handleSize"),o[0]),u=x(t.get("handleIcon"),-p/2,-p/2,p,p,null,!0),h=ft(this._orient);u.attr({cursor:h,draggable:!0,drift:s,ondragend:l,onmousemove:function(t){b(t.event)}}),u.x=o[0]/2,u.useStyle(t.getModel("handleStyle").getItemStyle()),u.setStyle({strokeNoScale:!0,strokeFirst:!0}),u.style.lineWidth*=2,u.ensureState("emphasis").style=t.getModel(["emphasis","handleStyle"]).getItemStyle(),I(u,!0),e.add(u);var c=this.visualMapModel.textStyleModel,d=new m({cursor:h,draggable:!0,drift:s,onmousemove:function(t){b(t.event)},ondragend:l,style:_(c,{x:0,y:0,text:""})});d.ensureState("blur").style={opacity:.1},d.stateTransition={duration:200},this.group.add(d);var v=[p,0],g=this._shapes;g.handleThumbs[i]=u,g.handleLabelPoints[i]=v,g.handleLabels[i]=d},o.prototype._createIndicator=function(t,e,i,n,o){var a=M(t.get("indicatorSize"),i[0]),r=x(t.get("indicatorIcon"),-a/2,-a/2,a,a,null,!0);r.attr({cursor:"move",invisible:!0,silent:!0,x:i[0]/2});var s=t.getModel("indicatorStyle").getItemStyle();if(r instanceof L){var l=r.style;r.useStyle(V({image:l.image,x:l.x,y:l.y,width:l.width,height:l.height},s))}else r.useStyle(s);e.add(r);var p=this.visualMapModel.textStyleModel,u=new m({silent:!0,invisible:!0,style:_(p,{x:0,y:0,text:""})});this.group.add(u);var h=[("horizontal"===o?n/2:6)+i[0]/2,0],c=this._shapes;c.indicator=r,c.indicatorLabel=u,c.indicatorLabelPoint=h,this._firstShowIndicator=!0},o.prototype._dragHandle=function(t,e,i,n){if(this._useHandle){if(this._dragging=!e,!e){var o=this._applyTransform([i,n],this._shapes.mainGroup,!0);this._updateInterval(t,o[1]),this._hideIndicator(),this._updateView()}e===!this.visualMapModel.get("realtime")&&this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()}),e?!this._hovering&&this._clearHoverLinkToSeries():gt(this.visualMapModel)&&this._doHoverLinkToSeries(this._handleEnds[t],!1)}},o.prototype._resetInterval=function(){var t=this.visualMapModel,e=this._dataInterval=t.getSelected(),i=t.getExtent(),n=[0,t.itemSize[1]];this._handleEnds=[ut(e[0],i,n,!0),ut(e[1],i,n,!0)]},o.prototype._updateInterval=function(t,e){e=e||0;var i=this.visualMapModel,n=this._handleEnds,o=[0,i.itemSize[1]];X(e,n,o,t,0);var a=i.getExtent();this._dataInterval=[ut(n[0],o,a,!0),ut(n[1],o,a,!0)]},o.prototype._updateView=function(t){var e=this.visualMapModel,i=e.getExtent(),n=this._shapes,o=[0,e.itemSize[1]],a=t?o:this._handleEnds,r=this._createBarVisual(this._dataInterval,i,a,"inRange"),s=this._createBarVisual(i,i,o,"outOfRange");n.inRange.setStyle({fill:r.barColor}).setShape("points",r.barPoints),n.outOfRange.setStyle({fill:s.barColor}).setShape("points",s.barPoints),this._updateHandle(a,r)},o.prototype._createBarVisual=function(t,e,i,n){var o={forceState:n,convertOpacityToAlpha:!0},a=this._makeColorGradient(t,o),r=[this.getControllerVisual(t[0],"symbolSize",o),this.getControllerVisual(t[1],"symbolSize",o)],s=this._createBarPoints(i,r);return{barColor:new w(0,0,0,1,a),barPoints:s,handlesColor:[a[0].color,a[a.length-1].color]}},o.prototype._makeColorGradient=function(t,e){var i=[],n=(t[1]-t[0])/100;i.push({color:this.getControllerVisual(t[0],"color",e),offset:0});for(var o=1;o<100;o++){var a=t[0]+n*o;if(a>t[1])break;i.push({color:this.getControllerVisual(a,"color",e),offset:o/100})}return i.push({color:this.getControllerVisual(t[1],"color",e),offset:1}),i},o.prototype._createBarPoints=function(t,e){var i=this.visualMapModel.itemSize;return[[i[0]-e[0],t[0]],[i[0],t[0]],[i[0],t[1]],[i[0]-e[1],t[1]]]},o.prototype._createBarGroup=function(t){var e=this._orient,i=this.visualMapModel.get("inverse");return new S("horizontal"!==e||i?"horizontal"===e&&i?{scaleX:"bottom"===t?-1:1,rotation:-Math.PI/2}:"vertical"!==e||i?{scaleX:"left"===t?1:-1}:{scaleX:"left"===t?1:-1,scaleY:-1}:{scaleX:"bottom"===t?1:-1,rotation:Math.PI/2})},o.prototype._updateHandle=function(t,e){if(this._useHandle){var i=this._shapes,n=this.visualMapModel,o=i.handleThumbs,a=i.handleLabels,r=n.itemSize,s=n.getExtent();ht([0,1],(function(l){var p=o[l];p.setStyle("fill",e.handlesColor[l]),p.y=t[l];var u=ut(t[l],[0,r[1]],s,!0),h=this.getControllerVisual(u,"symbolSize");p.scaleX=p.scaleY=h/r[0],p.x=r[0]-h/2;var c=T(i.handleLabelPoints[l],O(p,this.group));a[l].setStyle({x:c[0],y:c[1],text:n.formatValueText(this._dataInterval[l]),verticalAlign:"middle",align:"vertical"===this._orient?this._applyTransform("left",i.mainGroup):"center"})}),this)}},o.prototype._showIndicator=function(t,e,i,n){var o=this.visualMapModel,a=o.getExtent(),r=o.itemSize,s=[0,r[1]],l=this._shapes,p=l.indicator;if(p){p.attr("invisible",!1);var u=this.getControllerVisual(t,"color",{convertOpacityToAlpha:!0}),h=this.getControllerVisual(t,"symbolSize"),c=ut(t,a,s,!0),d=r[0]-h/2,v={x:p.x,y:p.y};p.y=c,p.x=d;var g=T(l.indicatorLabelPoint,O(p,this.group)),f=l.indicatorLabel;f.attr("invisible",!1);var y=this._applyTransform("left",l.mainGroup),m="horizontal"===this._orient;f.setStyle({text:(i||"")+o.formatValueText(e),verticalAlign:m?y:"middle",align:m?"center":y});var _={x:d,y:c,style:{fill:u}},S={style:{x:g[0],y:g[1]}};if(o.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var M={duration:100,easing:"cubicInOut",additive:!0};p.x=v.x,p.y=v.y,p.animateTo(_,M),f.animateTo(S,M)}else p.attr(_),f.attr(S);this._firstShowIndicator=!1;var x=this._shapes.handleLabels;if(x)for(var b=0;b<x.length;b++)this.api.enterBlur(x[b])}},o.prototype._enableHoverLinkToSeries=function(){var t=this;this._shapes.mainGroup.on("mousemove",(function(e){if(t._hovering=!0,!t._dragging){var i=t.visualMapModel.itemSize,n=t._applyTransform([e.offsetX,e.offsetY],t._shapes.mainGroup,!0,!0);n[1]=ct(dt(0,n[1]),i[1]),t._doHoverLinkToSeries(n[1],0<=n[0]&&n[0]<=i[0])}})).on("mouseout",(function(){t._hovering=!1,!t._dragging&&t._clearHoverLinkToSeries()}))},o.prototype._enableHoverLinkFromSeries=function(){var t=this.api.getZr();this.visualMapModel.option.hoverLink?(t.on("mouseover",this._hoverLinkFromSeriesMouseOver,this),t.on("mouseout",this._hideIndicator,this)):this._clearHoverLinkFromSeries()},o.prototype._doHoverLinkToSeries=function(t,e){var i=this.visualMapModel,n=i.itemSize;if(i.option.hoverLink){var o=[0,n[1]],a=i.getExtent();t=ct(dt(o[0],t),o[1]);var r=function(t,e,i){var n=6,o=t.get("hoverLinkDataSize");o&&(n=ut(o,e,i,!0)/2);return n}(i,a,o),s=[t-r,t+r],l=ut(t,o,a,!0),p=[ut(s[0],o,a,!0),ut(s[1],o,a,!0)];s[0]<o[0]&&(p[0]=-1/0),s[1]>o[1]&&(p[1]=1/0),e&&(p[0]===-1/0?this._showIndicator(l,p[1],"< ",r):p[1]===1/0?this._showIndicator(l,p[0],"> ",r):this._showIndicator(l,l,"≈ ",r));var u=this._hoverLinkDataIndices,h=[];(e||gt(i))&&(h=this._hoverLinkDataIndices=i.findTargetDataIndices(p));var c=R(u,h);this._dispatchHighDown("downplay",pt(c[0],i)),this._dispatchHighDown("highlight",pt(c[1],i))}},o.prototype._hoverLinkFromSeriesMouseOver=function(t){var e;if(C(t.target,(function(t){var i=z(t);if(null!=i.dataIndex)return e=i,!0}),!0),e){var i=this.ecModel.getSeriesByIndex(e.seriesIndex),n=this.visualMapModel;if(n.isTargetSeries(i)){var o=i.getData(e.dataType),a=o.getStore().get(n.getDataDimensionIndex(o),e.dataIndex);isNaN(a)||this._showIndicator(a,a)}}},o.prototype._hideIndicator=function(){var t=this._shapes;t.indicator&&t.indicator.attr("invisible",!0),t.indicatorLabel&&t.indicatorLabel.attr("invisible",!0);var e=this._shapes.handleLabels;if(e)for(var i=0;i<e.length;i++)this.api.leaveBlur(e[i])},o.prototype._clearHoverLinkToSeries=function(){this._hideIndicator();var t=this._hoverLinkDataIndices;this._dispatchHighDown("downplay",pt(t,this.visualMapModel)),t.length=0},o.prototype._clearHoverLinkFromSeries=function(){this._hideIndicator();var t=this.api.getZr();t.off("mouseover",this._hoverLinkFromSeriesMouseOver),t.off("mouseout",this._hideIndicator)},o.prototype._applyTransform=function(t,i,n,o){var a=O(i,o?null:this.group);return e(t)?T(t,a,n):k(t,a,n)},o.prototype._dispatchHighDown=function(t,e){e&&e.length&&this.api.dispatchAction({type:t,batch:e})},o.prototype.dispose=function(){this._clearHoverLinkFromSeries(),this._clearHoverLinkToSeries()},o.type="visualMap.continuous",o}(rt),mt={type:"selectDataRange",event:"dataRangeSelected",update:"update"},_t=function(t,e){e.eachComponent({mainType:"visualMap",query:t},(function(e){e.setSelected(t.selected)}))},St=[{createOnAllSeries:!0,reset:function(t,e){var i=[];return e.eachComponent("visualMap",(function(e){var o=t.pipelineContext;!e.isTargetSeries(t)||o&&o.large||i.push(U(e.stateList,e.targetVisuals,n(e.getValueState,e),e.getDataDimensionIndex(t.getData())))})),i}},{createOnAllSeries:!0,reset:function(t,e){var i=t.getData(),o=[];e.eachComponent("visualMap",(function(e){if(e.isTargetSeries(t)){var a=e.getVisualMeta(n(Mt,null,t,e))||{stops:[],outerColors:[]},r=e.getDataDimensionIndex(i);r>=0&&(a.dimension=r,o.push(a))}})),t.getData().setVisual("visualMeta",o)}}];function Mt(t,e,i,n){for(var o=e.targetVisuals[n],a=N.prepareVisualTypes(o),r={color:H(t.getData(),"color")},s=0,l=a.length;s<l;s++){var p=a[s],u=o["opacity"===p?"__alphaForOpacity":p];u&&u.applyVisual(i,h,c)}return r.color;function h(t){return r[t]}function c(t,e){r[t]=e}}var xt=a;function bt(t){var i=t&&t.visualMap;e(i)||(i=i?[i]:[]),xt(i,(function(t){if(t){It(t,"splitList")&&!It(t,"pieces")&&(t.pieces=t.splitList,delete t.splitList);var i=t.pieces;i&&e(i)&&xt(i,(function(t){P(t)&&(It(t,"start")&&!It(t,"min")&&(t.min=t.start),It(t,"end")&&!It(t,"max")&&(t.max=t.end))}))}}))}function It(t,e){return t&&t.hasOwnProperty&&t.hasOwnProperty(e)}var Lt=!1;function Vt(t){Lt||(Lt=!0,t.registerSubTypeDefaulter("visualMap",(function(t){return t.categories||(t.pieces?t.pieces.length>0:t.splitNumber>0)&&!t.calculable?"piecewise":"continuous"})),t.registerAction(mt,_t),a(St,(function(e){t.registerVisual(t.PRIORITY.VISUAL.COMPONENT,e)})),t.registerPreprocessor(bt))}function wt(t){t.registerComponentModel(at),t.registerComponentView(yt),Vt(t)}var Tt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=n.type,t._pieceList=[],t}return i(n,e),n.prototype.optionUpdated=function(i,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var o=this._mode=this._determineMode();this._pieceList=[],Ot[this._mode].call(this,this._pieceList),this._resetSelected(i,n);var a=this.option.categories;this.resetVisual((function(e,i){"categories"===o?(e.mappingMethod="category",e.categories=t(a)):(e.dataExtent=this.getExtent(),e.mappingMethod="piecewise",e.pieceList=E(this._pieceList,(function(e){return e=t(e),"inRange"!==i&&(e.visual=null),e})))}))},n.prototype.completeVisualOption=function(){var t=this.option,i={},n=N.listVisualTypes(),o=this.isCategory();function r(t,e,i){return t&&t[e]&&t[e].hasOwnProperty(i)}a(t.pieces,(function(t){a(n,(function(e){t.hasOwnProperty(e)&&(i[e]=1)}))})),a(i,(function(e,i){var n=!1;a(this.stateList,(function(e){n=n||r(t,e,i)||r(t.target,e,i)}),this),!n&&a(this.stateList,(function(e){(t[e]||(t[e]={}))[i]=Y(i,"inRange"===e?"active":"inactive",o)}))}),this),e.prototype.completeVisualOption.apply(this,arguments)},n.prototype._resetSelected=function(t,e){var i=this.option,n=this._pieceList,o=(e?i:t).selected||{};if(i.selected=o,a(n,(function(t,e){var i=this.getSelectedMapKey(t);o.hasOwnProperty(i)||(o[i]=!0)}),this),"single"===i.selectedMode){var r=!1;a(n,(function(t,e){var i=this.getSelectedMapKey(t);o[i]&&(r?o[i]=!1:r=!0)}),this)}},n.prototype.getItemSymbol=function(){return this.get("itemSymbol")},n.prototype.getSelectedMapKey=function(t){return"categories"===this._mode?t.value+"":t.index+""},n.prototype.getPieceList=function(){return this._pieceList},n.prototype._determineMode=function(){var t=this.option;return t.pieces&&t.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},n.prototype.setSelected=function(e){this.option.selected=t(e)},n.prototype.getValueState=function(t){var e=N.findPieceIndex(t,this._pieceList);return null!=e&&this.option.selected[this.getSelectedMapKey(this._pieceList[e])]?"inRange":"outOfRange"},n.prototype.findTargetDataIndices=function(t){var e=[],i=this._pieceList;return this.eachTargetSeries((function(n){var o=[],a=n.getData();a.each(this.getDataDimensionIndex(a),(function(e,n){N.findPieceIndex(e,i)===t&&o.push(n)}),this),e.push({seriesId:n.id,dataIndex:o})}),this),e},n.prototype.getRepresentValue=function(t){var e;if(this.isCategory())e=t.value;else if(null!=t.value)e=t.value;else{var i=t.interval||[];e=i[0]===-1/0&&i[1]===1/0?0:(i[0]+i[1])/2}return e},n.prototype.getVisualMeta=function(t){if(!this.isCategory()){var e=[],i=["",""],n=this,o=this._pieceList.slice();if(o.length){var r=o[0].interval[0];r!==-1/0&&o.unshift({interval:[-1/0,r]}),(r=o[o.length-1].interval[1])!==1/0&&o.push({interval:[r,1/0]})}else o.push({interval:[-1/0,1/0]});var s=-1/0;return a(o,(function(t){var e=t.interval;e&&(e[0]>s&&l([s,e[0]],"outOfRange"),l(e.slice()),s=e[1])}),this),{stops:e,outerColors:i}}function l(o,a){var r=n.getRepresentValue({interval:o});a||(a=n.getValueState(r));var s=t(r,a);o[0]===-1/0?i[0]=s:o[1]===1/0?i[1]=s:e.push({value:o[0],color:s},{value:o[1],color:s})}},n.type="visualMap.piecewise",n.defaultOption=c(et.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),n}(et),Ot={splitNumber:function(t){var e=this.option,i=Math.min(e.precision,20),n=this.getExtent(),o=e.splitNumber;o=Math.max(parseInt(o,10),1),e.splitNumber=o;for(var r=(n[1]-n[0])/o;+r.toFixed(i)!==r&&i<5;)i++;e.precision=i,r=+r.toFixed(i),e.minOpen&&t.push({interval:[-1/0,n[0]],close:[0,0]});for(var s=0,l=n[0];s<o;l+=r,s++){var p=s===o-1?n[1]:l+r;t.push({interval:[l,p],close:[1,1]})}e.maxOpen&&t.push({interval:[n[1],1/0],close:[0,0]}),A(t),a(t,(function(t,e){t.index=e,t.text=this.formatValueText(t.interval)}),this)},categories:function(t){var e=this.option;a(e.categories,(function(e){t.push({text:this.formatValueText(e,!0),value:e})}),this),Rt(e,t)},pieces:function(t){var e=this.option;a(e.pieces,(function(e,i){P(e)||(e={value:e});var n={text:"",index:i};if(null!=e.label&&(n.text=e.label),e.hasOwnProperty("value")){var o=n.value=e.value;n.interval=[o,o],n.close=[1,1]}else{for(var a=n.interval=[],r=n.close=[0,0],s=[1,0,1],l=[-1/0,1/0],p=[],u=0;u<2;u++){for(var h=[["gte","gt","min"],["lte","lt","max"]][u],c=0;c<3&&null==a[u];c++)a[u]=e[h[c]],r[u]=s[c],p[u]=2===c;null==a[u]&&(a[u]=l[u])}p[0]&&a[1]===1/0&&(r[0]=0),p[1]&&a[0]===-1/0&&(r[1]=0),a[0]>a[1]&&console.warn("Piece "+i+"is illegal: "+a+" lower bound should not greater then uppper bound."),a[0]===a[1]&&r[0]&&r[1]&&(n.value=a[0])}n.visual=N.retrieveVisuals(e),t.push(n)}),this),Rt(e,t),A(t),a(t,(function(t){var e=t.close,i=[["<","≤"][e[1]],[">","≥"][e[0]]];t.text=t.text||this.formatValueText(null!=t.value?t.value:t.interval,!1,i)}),this)}};function Rt(t,e){var i=t.inverse;("vertical"===t.orient?!i:i)&&e.reverse()}var Ct=Tt,zt=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=o.type,t}return i(o,e),o.prototype.doRender=function(){var t=this.group;t.removeAll();var e=this.visualMapModel,i=e.get("textGap"),o=e.textStyleModel,r=o.getFont(),s=o.getTextColor(),l=this._getItemAlign(),p=e.itemSize,u=this._getViewData(),h=u.endsText,c=B(e.get("showLabel",!0),!h);h&&this._renderEndsText(t,h[0],p,c,l),a(u.viewPieceList,(function(o){var a=o.piece,u=new S;u.onclick=n(this._onItemClick,this,a),this._enableHoverLink(u,o.indexInModelPieceList);var h=e.getRepresentValue(a);if(this._createItemSymbol(u,h,[0,0,p[0],p[1]]),c){var d=this.visualMapModel.getValueState(h);u.add(new m({style:{x:"right"===l?-i:p[0]+i,y:p[1]/2,text:a.text,verticalAlign:"middle",align:l,font:r,fill:s,opacity:"outOfRange"===d?.5:1}}))}t.add(u)}),this),h&&this._renderEndsText(t,h[1],p,c,l),F(e.get("orient"),t,e.get("itemGap")),this.renderBackground(t),this.positionGroup(t)},o.prototype._enableHoverLink=function(t,e){var i=this;t.on("mouseover",(function(){return n("highlight")})).on("mouseout",(function(){return n("downplay")}));var n=function(t){var n=i.visualMapModel;n.option.hoverLink&&i.api.dispatchAction({type:t,batch:pt(n.findTargetDataIndices(e),n)})}},o.prototype._getItemAlign=function(){var t=this.visualMapModel,e=t.option;if("vertical"===e.orient)return lt(t,this.api,t.itemSize);var i=e.align;return i&&"auto"!==i||(i="left"),i},o.prototype._renderEndsText=function(t,e,i,n,o){if(e){var a=new S,r=this.visualMapModel.textStyleModel;a.add(new m({style:_(r,{x:n?"right"===o?i[0]:0:i[0]/2,y:i[1]/2,verticalAlign:"middle",align:n?o:"center",text:e})})),t.add(a)}},o.prototype._getViewData=function(){var t=this.visualMapModel,e=E(t.getPieceList(),(function(t,e){return{piece:t,indexInModelPieceList:e}})),i=t.get("text"),n=t.get("orient"),o=t.get("inverse");return("horizontal"===n?o:!o)?e.reverse():i&&(i=i.slice().reverse()),{viewPieceList:e,endsText:i}},o.prototype._createItemSymbol=function(t,e,i){t.add(x(this.getControllerVisual(e,"symbol"),i[0],i[1],i[2],i[3],this.getControllerVisual(e,"color")))},o.prototype._onItemClick=function(e){var i=this.visualMapModel,n=i.option,o=n.selectedMode;if(o){var r=t(n.selected),s=i.getSelectedMapKey(e);"single"===o||!0===o?(r[s]=!0,a(r,(function(t,e){r[e]=e===s}))):r[s]=!r[s],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:r})}},o.type="visualMap.piecewise",o}(rt);function kt(t){t.registerComponentModel(Ct),t.registerComponentView(zt),Vt(t)}function Dt(t){G(wt),G(kt)}export{Dt as install};