UNPKG

basb-cli

Version:
2 lines (1 loc) 23.2 kB
import{r as e,a as t,T as o,w as a,g as r}from"./Tree.js";import{aN as i,_ as n,aJ as s,m as l,aK as d,h as u,b8 as h,S as p,e as g,d as c,bA as f,G as v,bB as y,bm as m,bC as x,am as w,$ as b,a9 as I,a0 as M,b7 as _,x as T,o as S,g as R,bD as C,X as L,D as V,a6 as N,Y as D,b1 as A,bE as k,bF as W,bq as E,C as G,I as H,bG as z,bH as B,bI as q,bJ as Z,ac as F,k as X,j as Y,bK as j,ad as P,R as O,bL as U,bM as J,ap as K,E as $,aY as Q,bk as ee,bN as te}from"./index.js";import{e as oe}from"./enableAriaDecalForTree.js";import{R as ae}from"./RoamController.js";import{V as re}from"./VisualMapping.js";import"./linkSeriesData.js";import"./interactionMutex.js";var ie=["treemapZoomToNode","treemapRender","treemapMove"];function ne(e){var t=0;g(e.children,(function(e){ne(e);var o=e.value;c(o)&&(o=o[0]),t+=o}));var o=e.value;c(o)&&(o=o[0]),(null==o||isNaN(o))&&(o=t),o<0&&(o=0),c(e.value)?e.value[0]=o:e.value=o}var se=function(e){function t(){var o=null!==e&&e.apply(this,arguments)||this;return o.type=t.type,o.preventUsingHoverLayer=!0,o}return n(t,e),t.prototype.getInitialData=function(e,t){var a={name:e.name,children:e.data};ne(a);var r=e.levels||[],i=this.designatedVisualItemStyle={},n=new s({itemStyle:i},this,t);r=e.levels=function(e,t){var o,a,r=f(t.get("color")),i=f(t.get(["aria","decal","decals"]));if(!r)return;e=e||[],g(e,(function(e){var t=new s(e),r=t.get("color"),i=t.get("decal");(t.get(["itemStyle","color"])||r&&"none"!==r)&&(o=!0),(t.get(["itemStyle","decal"])||i&&"none"!==i)&&(a=!0)}));var n=e[0]||(e[0]={});o||(n.color=r.slice());!a&&i&&(n.decal=i.slice());return e}(r,t);var d=l(r||[],(function(e){return new s(e,n,t)}),this),u=o.createTree(a,this,(function(e){e.wrapMethod("getItemModel",(function(e,t){var o=u.getNodeByDataIndex(t),a=o?d[o.depth]:null;return e.parentModel=a||n,e}))}));return u.data},t.prototype.optionUpdated=function(){this.resetViewRoot()},t.prototype.formatTooltip=function(e,t,o){var a=this.getData(),r=this.getRawValue(e),i=a.getName(e);return d("nameValue",{name:i,value:r})},t.prototype.getDataParams=function(t){var o=e.prototype.getDataParams.apply(this,arguments),r=this.getData().tree.getNodeByDataIndex(t);return o.treeAncestors=a(r,this),o.treePathInfo=o.treeAncestors,o},t.prototype.setLayoutInfo=function(e){this.layoutInfo=this.layoutInfo||{},u(this.layoutInfo,e)},t.prototype.mapIdToIndex=function(e){var t=this._idIndexMap;t||(t=this._idIndexMap=h(),this._idIndexMapCount=0);var o=t.get(e);return null==o&&t.set(e,o=this._idIndexMapCount++),o},t.prototype.getViewRoot=function(){return this._viewRoot},t.prototype.resetViewRoot=function(e){e?this._viewRoot=e:e=this._viewRoot;var t=this.getRawData().tree.root;e&&(e===t||t.contains(e))||(this._viewRoot=t)},t.prototype.enableAriaDecal=function(){oe(this)},t.type="series.treemap",t.layoutMode="box",t.defaultOption={progressive:0,left:"center",top:"middle",width:"80%",height:"80%",sort:!0,clipWindow:"origin",squareRatio:.5*(1+Math.sqrt(5)),leafDepth:null,drillDownIcon:"▶",zoomToNodeRatio:.1024,roam:!0,nodeClick:"zoomToNode",animation:!0,animationDurationUpdate:900,animationEasing:"quinticInOut",breadcrumb:{show:!0,height:22,left:"center",top:"bottom",emptyItemWidth:25,itemStyle:{color:"rgba(0,0,0,0.7)",textStyle:{color:"#fff"}},emphasis:{itemStyle:{color:"rgba(0,0,0,0.9)"}}},label:{show:!0,distance:0,padding:5,position:"inside",color:"#fff",overflow:"truncate"},upperLabel:{show:!1,position:[0,"50%"],height:20,overflow:"truncate",verticalAlign:"middle"},itemStyle:{color:null,colorAlpha:null,colorSaturation:null,borderWidth:0,gapWidth:0,borderColor:"#fff",borderColorSaturation:null},emphasis:{upperLabel:{show:!0,position:[0,"50%"],overflow:"truncate",verticalAlign:"middle"}},visualDimension:0,visualMin:null,visualMax:null,color:[],colorAlpha:null,colorSaturation:null,colorMappingBy:"index",visibleMin:10,childrenVisibleMin:null,levels:[]},t}(p);function le(e,t,o,a,r,i){var n=[[r?e:e-5,t],[e+o,t],[e+o,t+a],[r?e:e-5,t+a]];return!i&&n.splice(2,0,[e+o+5,t+a/2]),!r&&n.push([e,t+a/2]),n}function de(e,t,o){R(e).eventData={componentType:"series",componentSubType:"treemap",componentIndex:t.componentIndex,seriesIndex:t.seriesIndex,seriesName:t.name,seriesType:"treemap",selfType:"breadcrumb",nodeData:{dataIndex:o&&o.dataIndex,name:o&&o.name},treePathInfo:o&&a(o,t)}}var ue=function(){function e(e){this.group=new v,e.add(this.group)}return e.prototype.render=function(e,t,o,a){var r=e.getModel("breadcrumb"),i=this.group;if(i.removeAll(),r.get("show")&&o){var n=r.getModel("itemStyle"),s=r.getModel("emphasis"),l=n.getModel("textStyle"),d=s.getModel(["itemStyle","textStyle"]),u={pos:{left:r.get("left"),right:r.get("right"),top:r.get("top"),bottom:r.get("bottom")},box:{width:t.getWidth(),height:t.getHeight()},emptyItemWidth:r.get("emptyItemWidth"),totalWidth:0,renderList:[]};this._prepare(o,u,l),this._renderContent(e,u,n,s,l,d,a),y(i,u.pos,u.box)}},e.prototype._prepare=function(e,t,o){for(var a=e;a;a=a.parentNode){var r=m(a.getModel().get("name"),""),i=o.getTextRect(r),n=Math.max(i.width+16,t.emptyItemWidth);t.totalWidth+=n+8,t.renderList.push({node:a,text:r,width:n})}},e.prototype._renderContent=function(e,t,o,a,r,i,n){for(var s=0,l=t.emptyItemWidth,d=e.get(["breadcrumb","height"]),u=x(t.pos,t.box),h=t.totalWidth,p=t.renderList,g=a.getModel("itemStyle").getItemStyle(),c=p.length-1;c>=0;c--){var f=p[c],v=f.node,y=f.width,m=f.text;h>u.width&&(h-=y-l,y=l,m=null);var R=new w({shape:{points:le(s,0,y,d,c===p.length-1,0===c)},style:b(o.getItemStyle(),{lineJoin:"bevel"}),textContent:new I({style:M(r,{text:m})}),textConfig:{position:"inside"},z2:1e4*_,onclick:T(n,v)});R.disableLabelAnimation=!0,R.getTextContent().ensureState("emphasis").style=M(i,{text:m}),R.ensureState("emphasis").style=g,S(R,a.get("focus"),a.get("blurScope"),a.get("disabled")),this.group.add(R),de(R,e,v),s+=y+8}},e.prototype.remove=function(){this.group.removeAll()},e}(),he=function(){function e(){this._storage=[],this._elExistsMap={}}return e.prototype.add=function(e,t,o,a,r){return!this._elExistsMap[e.id]&&(this._elExistsMap[e.id]=!0,this._storage.push({el:e,target:t,duration:o,delay:a,easing:r}),!0)},e.prototype.finished=function(e){return this._finishedCallback=e,this},e.prototype.start=function(){for(var e=this,t=this._storage.length,o=function(){--t<=0&&(e._storage.length=0,e._elExistsMap={},e._finishedCallback&&e._finishedCallback())},a=0,r=this._storage.length;a<r;a++){var i=this._storage[a];i.el.animateTo(i.target,{duration:i.duration,delay:i.delay,easing:i.easing,setToFinal:!0,done:o,aborted:o})}return this},e}();var pe=v,ge=O,ce="label",fe="upperLabel",ve=10*_,ye=2*_,me=3*_,xe=C([["fill","color"],["stroke","strokeColor"],["lineWidth","strokeWidth"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"]]),we=function(e){var t=xe(e);return t.stroke=t.fill=t.lineWidth=null,t},be=L();var Ie=function(o){function a(){var e=null!==o&&o.apply(this,arguments)||this;return e.type=a.type,e._state="ready",e._storage={nodeGroup:[],background:[],content:[]},e}return n(a,o),a.prototype.render=function(t,o,a,r){var i=o.findComponents({mainType:"series",subType:"treemap",query:r});if(!(V(i,t)<0)){this.seriesModel=t,this.api=a,this.ecModel=o;var n=e(r,["treemapZoomToNode","treemapRootToNode"],t),s=r&&r.type,l=t.layoutInfo,d=!this._oldTree,u=this._storage,h="treemapRootToNode"===s&&n&&u?{rootNodeGroup:u.nodeGroup[n.node.getRawIndex()],direction:r.direction}:null,p=this._giveContainerGroup(l),g=t.get("animation"),c=this._doRender(p,t,h);!g||d||s&&"treemapZoomToNode"!==s&&"treemapRootToNode"!==s?c.renderFinally():this._doAnimation(p,c,t,h),this._resetController(a),this._renderBreadcrumb(t,a,n)}},a.prototype._giveContainerGroup=function(e){var t=this._containerGroup;return t||(t=this._containerGroup=new pe,this._initEvents(t),this.group.add(t)),t.x=e.x,t.y=e.y,t},a.prototype._doRender=function(e,t,o){var a=t.getData().tree,r=this._oldTree,i={nodeGroup:[],background:[],content:[]},n={nodeGroup:[],background:[],content:[]},s=this._storage,l=[];function d(e,a,r,d){return function(e,t,o,a,r,i,n,s,l,d){if(!n)return;var h=n.getLayout(),p=e.getData(),g=n.getModel();if(p.setItemGraphicEl(n.dataIndex,null),!h||!h.isInView)return;var c=h.width,f=h.height,y=h.borderWidth,x=h.invisible,w=n.getRawIndex(),b=s&&s.getRawIndex(),I=n.viewChildren,M=h.upperHeight,_=I&&I.length,T=g.getModel("itemStyle"),S=g.getModel(["emphasis","itemStyle"]),C=g.getModel(["blur","itemStyle"]),L=g.getModel(["select","itemStyle"]),V=T.get("borderRadius")||0,N=$("nodeGroup",pe);if(!N)return;if(l.add(N),N.x=h.x||0,N.y=h.y||0,N.markRedraw(),be(N).nodeWidth=c,be(N).nodeHeight=f,h.isAboveViewRoot)return N;var D=$("background",ge,d,ye);D&&z(N,D,_&&h.upperLabelHeight);var A=g.getModel("emphasis"),k=A.get("focus"),W=A.get("blurScope"),E=A.get("disabled"),G="ancestor"===k?n.getAncestorsIndices():"descendant"===k?n.getDescendantIndices():k;if(_)B(N)&&q(N,!1),D&&(q(D,!E),p.setItemGraphicEl(n.dataIndex,D),Z(D,G,W));else{var H=$("content",ge,d,me);H&&O(N,H),D.disableMorphing=!0,D&&B(D)&&q(D,!1),q(N,!E),p.setItemGraphicEl(n.dataIndex,N),Z(N,G,W)}return N;function z(t,o,a){var r=R(o);if(r.dataIndex=n.dataIndex,r.seriesIndex=e.seriesIndex,o.setShape({x:0,y:0,width:c,height:f,r:V}),x)U(o);else{o.invisible=!1;var i=n.getVisual("style"),s=i.stroke,l=we(T);l.fill=s;var d=xe(S);d.fill=S.get("borderColor");var u=xe(C);u.fill=C.get("borderColor");var h=xe(L);if(h.fill=L.get("borderColor"),a){var p=c-2*y;J(o,s,i.opacity,{x:y,y:0,width:p,height:M})}else o.removeTextContent();o.setStyle(l),o.ensureState("emphasis").style=d,o.ensureState("blur").style=u,o.ensureState("select").style=h,F(o)}t.add(o)}function O(t,o){var a=R(o);a.dataIndex=n.dataIndex,a.seriesIndex=e.seriesIndex;var r=Math.max(c-2*y,0),i=Math.max(f-2*y,0);if(o.culling=!0,o.setShape({x:y,y:y,width:r,height:i,r:V}),x)U(o);else{o.invisible=!1;var s=n.getVisual("style"),l=s.fill,d=we(T);d.fill=l,d.decal=s.decal;var u=xe(S),h=xe(C),p=xe(L);J(o,l,s.opacity,null),o.setStyle(d),o.ensureState("emphasis").style=u,o.ensureState("blur").style=h,o.ensureState("select").style=p,F(o)}t.add(o)}function U(e){!e.invisible&&i.push(e)}function J(t,o,a,r){var i=g.getModel(r?fe:ce),s=m(g.get("name"),null),l=i.getShallow("show");X(t,Y(g,r?fe:ce),{defaultText:l?s:null,inheritColor:o,defaultOpacity:a,labelFetcher:e,labelDataIndex:n.dataIndex});var d=t.getTextContent();if(d){var u=d.style,p=j(u.padding||0);r&&(t.setTextConfig({layoutRect:r}),d.disableLabelLayout=!0),d.beforeUpdate=function(){var e=Math.max((r?r.width:t.shape.width)-p[1]-p[3],0),o=Math.max((r?r.height:t.shape.height)-p[0]-p[2],0);u.width===e&&u.height===o||d.setStyle({width:e,height:o})},u.truncateMinChar=2,u.lineOverflow="truncate",K(u,r,h);var c=d.getState("emphasis");K(c?c.style:null,r,h)}}function K(t,o,a){var r=t?t.text:null;if(!o&&a.isLeafRoot&&null!=r){var i=e.get("drillDownIcon",!0);t.text=i?i+" "+r:r}}function $(e,a,i,n){var s=null!=b&&o[e][b],l=r[e];return s?(o[e][b]=null,Q(l,s)):x||((s=new a)instanceof P&&(s.z2=function(e,t){return e*ve+t}(i,n)),ee(l,s)),t[e][w]=s}function Q(e,t){var o=e[w]={};t instanceof pe?(o.oldX=t.x,o.oldY=t.y):o.oldShape=u({},t.shape)}function ee(e,t){var o=e[w]={},i=n.parentNode,s=t instanceof v;if(i&&(!a||"drillDown"===a.direction)){var l=0,d=0,u=r.background[i.getRawIndex()];!a&&u&&u.oldShape&&(l=u.oldShape.width,d=u.oldShape.height),s?(o.oldX=0,o.oldY=d):o.oldShape={x:l,y:d,width:0,height:0}}o.fadein=!s}}(t,n,s,o,i,l,e,a,r,d)}!function e(t,o,a,r,i){r?(o=t,g(t,(function(e,t){!e.isRemoved()&&s(t,t)}))):new N(o,t,n,n).add(s).update(s).remove(T(s,null)).execute();function n(e){return e.getId()}function s(n,s){var l=null!=n?t[n]:null,u=null!=s?o[s]:null,h=d(l,u,a,i);h&&e(l&&l.viewChildren||[],u&&u.viewChildren||[],h,r,i+1)}}(a.root?[a.root]:[],r&&r.root?[r.root]:[],e,a===r||!r,0);var h=function(e){var t={nodeGroup:[],background:[],content:[]};return e&&g(e,(function(e,o){var a=t[o];g(e,(function(e){e&&(a.push(e),be(e).willDelete=!0)}))})),t}(s);return this._oldTree=a,this._storage=n,{lastsForAnimation:i,willDeleteEls:h,renderFinally:function(){g(h,(function(e){g(e,(function(e){e.parent&&e.parent.remove(e)}))})),g(l,(function(e){e.invisible=!0,e.dirty()}))}}},a.prototype._doAnimation=function(e,t,o,a){var r=o.get("animationDurationUpdate"),i=o.get("animationEasing"),n=(H(r)?0:r)||0,s=(H(i)?null:i)||"cubicOut",l=new he;g(t.willDeleteEls,(function(e,t){g(e,(function(e,o){if(!e.invisible){var r,i=e.parent,d=be(i);if(a&&"drillDown"===a.direction)r=i===a.rootNodeGroup?{shape:{x:0,y:0,width:d.nodeWidth,height:d.nodeHeight},style:{opacity:0}}:{style:{opacity:0}};else{var u=0,h=0;d.willDelete||(u=d.nodeWidth/2,h=d.nodeHeight/2),r="nodeGroup"===t?{x:u,y:h,style:{opacity:0}}:{shape:{x:u,y:h,width:0,height:0},style:{opacity:0}}}r&&l.add(e,r,n,0,s)}}))})),g(this._storage,(function(e,o){g(e,(function(e,a){var r=t.lastsForAnimation[o][a],i={};r&&(e instanceof v?null!=r.oldX&&(i.x=e.x,i.y=e.y,e.x=r.oldX,e.y=r.oldY):(r.oldShape&&(i.shape=u({},e.shape),e.setShape(r.oldShape)),r.fadein?(e.setStyle("opacity",0),i.style={opacity:1}):1!==e.style.opacity&&(i.style={opacity:1})),l.add(e,i,n,0,s))}))}),this),this._state="animating",l.finished(D((function(){this._state="ready",t.renderFinally()}),this)).start()},a.prototype._resetController=function(e){var t=this._controller;t||((t=this._controller=new ae(e.getZr())).enable(this.seriesModel.get("roam")),t.on("pan",D(this._onPan,this)),t.on("zoom",D(this._onZoom,this)));var o=new A(0,0,e.getWidth(),e.getHeight());t.setPointerChecker((function(e,t,a){return o.contain(t,a)}))},a.prototype._clearController=function(){var e=this._controller;e&&(e.dispose(),e=null)},a.prototype._onPan=function(e){if("animating"!==this._state&&(Math.abs(e.dx)>3||Math.abs(e.dy)>3)){var t=this.seriesModel.getData().tree.root;if(!t)return;var o=t.getLayout();if(!o)return;this.api.dispatchAction({type:"treemapMove",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:o.x+e.dx,y:o.y+e.dy,width:o.width,height:o.height}})}},a.prototype._onZoom=function(e){var t=e.originX,o=e.originY;if("animating"!==this._state){var a=this.seriesModel.getData().tree.root;if(!a)return;var r=a.getLayout();if(!r)return;var i=new A(r.x,r.y,r.width,r.height),n=this.seriesModel.layoutInfo;t-=n.x,o-=n.y;var s=z();k(s,s,[-t,-o]),W(s,s,[e.scale,e.scale]),k(s,s,[t,o]),i.applyTransform(s),this.api.dispatchAction({type:"treemapRender",from:this.uid,seriesId:this.seriesModel.id,rootRect:{x:i.x,y:i.y,width:i.width,height:i.height}})}},a.prototype._initEvents=function(e){var t=this;e.on("click",(function(e){if("ready"===t._state){var o=t.seriesModel.get("nodeClick",!0);if(o){var a=t.findTarget(e.offsetX,e.offsetY);if(a){var r=a.node;if(r.getLayout().isLeafRoot)t._rootToNode(a);else if("zoomToNode"===o)t._zoomToNode(a);else if("link"===o){var i=r.hostTree.data.getItemModel(r.dataIndex),n=i.get("link",!0),s=i.get("target",!0)||"blank";n&&E(n,s)}}}}}),this)},a.prototype._renderBreadcrumb=function(e,o,a){var r=this;a||(a=null!=e.get("leafDepth",!0)?{node:e.getViewRoot()}:this.findTarget(o.getWidth()/2,o.getHeight()/2))||(a={node:e.getData().tree.root}),(this._breadcrumb||(this._breadcrumb=new ue(this.group))).render(e,o,a.node,(function(o){"animating"!==r._state&&(t(e.getViewRoot(),o)?r._rootToNode({node:o}):r._zoomToNode({node:o}))}))},a.prototype.remove=function(){this._clearController(),this._containerGroup&&this._containerGroup.removeAll(),this._storage={nodeGroup:[],background:[],content:[]},this._state="ready",this._breadcrumb&&this._breadcrumb.remove()},a.prototype.dispose=function(){this._clearController()},a.prototype._zoomToNode=function(e){this.api.dispatchAction({type:"treemapZoomToNode",from:this.uid,seriesId:this.seriesModel.id,targetNode:e.node})},a.prototype._rootToNode=function(e){this.api.dispatchAction({type:"treemapRootToNode",from:this.uid,seriesId:this.seriesModel.id,targetNode:e.node})},a.prototype.findTarget=function(e,t){var o;return this.seriesModel.getViewRoot().eachNode({attr:"viewChildren",order:"preorder"},(function(a){var r=this._storage.background[a.getRawIndex()];if(r){var i=r.transformCoordToLocal(e,t),n=r.shape;if(!(n.x<=i[0]&&i[0]<=n.x+n.width&&n.y<=i[1]&&i[1]<=n.y+n.height))return!1;o={node:a,offsetX:i[0],offsetY:i[1]}}}),this),o},a.type="treemap",a}(G),Me=L(),_e={seriesType:"treemap",reset:function(e){var t=e.getData().tree.root;t.isRemoved()||Te(t,{},e.getViewRoot().getAncestors(),e)}};function Te(e,t,o,a){var r=e.getModel(),i=e.getLayout(),n=e.hostTree.data;if(i&&!i.invisible&&i.isInView){var s,l=r.getModel("itemStyle"),d=function(e,t,o){var a=u({},t),r=o.designatedVisualItemStyle;return g(["color","colorAlpha","colorSaturation"],(function(o){r[o]=t[o];var i=e.get(o);r[o]=null,null!=i&&(a[o]=i)})),a}(l,t,a),h=n.ensureUniqueItemVisual(e.dataIndex,"style"),p=l.get("borderColor"),c=l.get("borderColorSaturation");null!=c&&(p=function(e,t){return null!=t?U(t,null,null,e):null}(c,s=Se(d))),h.stroke=p;var f=e.viewChildren;if(f&&f.length){var v=function(e,t,o,a,r,i){if(!i||!i.length)return;var n=Ce(t,"color")||null!=r.color&&"none"!==r.color&&(Ce(t,"colorAlpha")||Ce(t,"colorSaturation"));if(!n)return;var s=t.get("visualMin"),l=t.get("visualMax"),d=o.dataExtent.slice();null!=s&&s<d[0]&&(d[0]=s),null!=l&&l>d[1]&&(d[1]=l);var u=t.get("colorMappingBy"),h={type:n.name,dataExtent:d,visual:n.range};"color"!==h.type||"index"!==u&&"id"!==u?h.mappingMethod="linear":(h.mappingMethod="category",h.loop=!0);var p=new re(h);return Me(p).drColorMappingBy=u,p}(0,r,i,0,d,f);g(f,(function(e,t){if(e.depth>=o.length||e===o[e.depth]){var i=function(e,t,o,a,r,i){var n=u({},t);if(r){var s=r.type,l="color"===s&&Me(r).drColorMappingBy,d="index"===l?a:"id"===l?i.mapIdToIndex(o.getId()):o.getValue(e.get("visualDimension"));n[s]=r.mapValueToVisual(d)}return n}(r,d,e,t,v,a);Te(e,i,o,a)}}))}else s=Se(d),h.fill=s}}function Se(e){var t=Re(e,"color");if(t){var o=Re(e,"colorAlpha"),a=Re(e,"colorSaturation");return a&&(t=U(t,null,null,a)),o&&(t=J(t,o)),t}}function Re(e,t){var o=e[t];if(null!=o&&"none"!==o)return o}function Ce(e,t){var o=e.get(t);return c(o)&&o.length?{name:t,range:o}:null}var Le=Math.max,Ve=Math.min,Ne=Q,De=g,Ae=["itemStyle","borderWidth"],ke=["itemStyle","gapWidth"],We=["upperLabel","show"],Ee=["upperLabel","height"],Ge={seriesType:"treemap",reset:function(t,o,a,i){var n=a.getWidth(),s=a.getHeight(),l=t.option,d=K(t.getBoxLayoutParams(),{width:a.getWidth(),height:a.getHeight()}),h=l.size||[],p=$(Ne(d.width,h[0]),n),g=$(Ne(d.height,h[1]),s),c=i&&i.type,f=e(i,["treemapZoomToNode","treemapRootToNode"],t),v="treemapRender"===c||"treemapMove"===c?i.rootRect:null,y=t.getViewRoot(),m=r(y);if("treemapMove"!==c){var x="treemapZoomToNode"===c?function(e,t,o,a,r){var i,n=(t||{}).node,s=[a,r];if(!n||n===o)return s;var l=a*r,d=l*e.option.zoomToNodeRatio;for(;i=n.parentNode;){for(var u=0,h=i.children,p=0,g=h.length;p<g;p++)u+=h[p].getValue();var c=n.getValue();if(0===c)return s;d*=u/c;var f=i.getModel(),v=f.get(Ae);(d+=4*v*v+(3*v+Math.max(v,Ze(f)))*Math.pow(d,.5))>te&&(d=te),n=i}d<l&&(d=l);var y=Math.pow(d/l,.5);return[a*y,r*y]}(t,f,y,p,g):v?[v.width,v.height]:[p,g],w=l.sort;w&&"asc"!==w&&"desc"!==w&&(w="desc");var b={squareRatio:l.squareRatio,sort:w,leafDepth:l.leafDepth};y.hostTree.clearLayouts();var I={x:0,y:0,width:x[0],height:x[1],area:x[0]*x[1]};y.setLayout(I),He(y,b,!1,0),I=y.getLayout(),De(m,(function(e,t){var o=(m[t+1]||y).getValue();e.setLayout(u({dataExtent:[o,o],borderWidth:0,upperHeight:0},I))}))}var M=t.getData().tree.root;M.setLayout(function(e,t,o){if(t)return{x:t.x,y:t.y};var a={x:0,y:0};if(!o)return a;var r=o.node,i=r.getLayout();if(!i)return a;var n=[i.width/2,i.height/2],s=r;for(;s;){var l=s.getLayout();n[0]+=l.x,n[1]+=l.y,s=s.parentNode}return{x:e.width/2-n[0],y:e.height/2-n[1]}}(d,v,f),!0),t.setLayoutInfo(d),qe(M,new A(-d.x,-d.y,n,s),m,y,0)}};function He(e,t,o,a){var r,i;if(!e.isRemoved()){var n=e.getLayout();r=n.width,i=n.height;var s=e.getModel(),l=s.get(Ae),d=s.get(ke)/2,u=Ze(s),h=Math.max(l,u),p=l-d,g=h-d;e.setLayout({borderWidth:l,upperHeight:h,upperLabelHeight:u},!0);var c=(r=Le(r-2*p,0))*(i=Le(i-p-g,0)),f=function(e,t,o,a,r,i){var n=e.children||[],s=a.sort;"asc"!==s&&"desc"!==s&&(s=null);var l=null!=a.leafDepth&&a.leafDepth<=i;if(r&&!l)return e.viewChildren=[];n=ee(n,(function(e){return!e.isRemoved()})),function(e,t){t&&e.sort((function(e,o){var a="asc"===t?e.getValue()-o.getValue():o.getValue()-e.getValue();return 0===a?"asc"===t?e.dataIndex-o.dataIndex:o.dataIndex-e.dataIndex:a}))}(n,s);var d=function(e,t,o){for(var a=0,r=0,i=t.length;r<i;r++)a+=t[r].getValue();var n,s=e.get("visualDimension");t&&t.length?"value"===s&&o?(n=[t[t.length-1].getValue(),t[0].getValue()],"asc"===o&&n.reverse()):(n=[1/0,-1/0],De(t,(function(e){var t=e.getValue(s);t<n[0]&&(n[0]=t),t>n[1]&&(n[1]=t)}))):n=[NaN,NaN];return{sum:a,dataExtent:n}}(t,n,s);if(0===d.sum)return e.viewChildren=[];if(d.sum=function(e,t,o,a,r){if(!a)return o;for(var i=e.get("visibleMin"),n=r.length,s=n,l=n-1;l>=0;l--){var d=r["asc"===a?n-l-1:l].getValue();d/o*t<i&&(s=l,o-=d)}return"asc"===a?r.splice(0,n-s):r.splice(s,n-s),o}(t,o,d.sum,s,n),0===d.sum)return e.viewChildren=[];for(var u=0,h=n.length;u<h;u++){var p=n[u].getValue()/d.sum*o;n[u].setLayout({area:p})}l&&(n.length&&e.setLayout({isLeafRoot:!0},!0),n.length=0);return e.viewChildren=n,e.setLayout({dataExtent:d.dataExtent},!0),n}(e,s,c,t,o,a);if(f.length){var v={x:p,y:g,width:r,height:i},y=Ve(r,i),m=1/0,x=[];x.area=0;for(var w=0,b=f.length;w<b;){var I=f[w];x.push(I),x.area+=I.getLayout().area;var M=ze(x,y,t.squareRatio);M<=m?(w++,m=M):(x.area-=x.pop().getLayout().area,Be(x,y,v,d,!1),y=Ve(v.width,v.height),x.length=x.area=0,m=1/0)}if(x.length&&Be(x,y,v,d,!0),!o){var _=s.get("childrenVisibleMin");null!=_&&c<_&&(o=!0)}for(w=0,b=f.length;w<b;w++)He(f[w],t,o,a+1)}}}function ze(e,t,o){for(var a=0,r=1/0,i=0,n=void 0,s=e.length;i<s;i++)(n=e[i].getLayout().area)&&(n<r&&(r=n),n>a&&(a=n));var l=e.area*e.area,d=t*t*o;return l?Le(d*a/l,l/(d*r)):1/0}function Be(e,t,o,a,r){var i=t===o.width?0:1,n=1-i,s=["x","y"],l=["width","height"],d=o[s[i]],u=t?e.area/t:0;(r||u>o[l[n]])&&(u=o[l[n]]);for(var h=0,p=e.length;h<p;h++){var g=e[h],c={},f=u?g.getLayout().area/u:0,v=c[l[n]]=Le(u-2*a,0),y=o[s[i]]+o[l[i]]-d,m=h===p-1||y<f?y:f,x=c[l[i]]=Le(m-2*a,0);c[s[n]]=o[s[n]]+Ve(a,v/2),c[s[i]]=d+Ve(a,x/2),d+=m,g.setLayout(c,!0)}o[s[n]]+=u,o[l[n]]-=u}function qe(e,t,o,a,r){var i=e.getLayout(),n=o[r],s=n&&n===e;if(!(n&&!s||r===o.length&&e!==a)){e.setLayout({isInView:!0,invisible:!s&&!t.intersect(i),isAboveViewRoot:s},!0);var l=new A(t.x-i.x,t.y-i.y,t.width,t.height);De(e.viewChildren||[],(function(e){qe(e,l,o,a,r+1)}))}}function Ze(e){return e.get(We)?e.get(Ee):0}function Fe(o){o.registerSeriesModel(se),o.registerChartView(Ie),o.registerVisual(_e),o.registerLayout(Ge),function(o){for(var a=0;a<ie.length;a++)o.registerAction({type:ie[a],update:"updateView"},i);o.registerAction({type:"treemapRootToNode",update:"updateView"},(function(o,a){a.eachComponent({mainType:"series",subType:"treemap",query:o},(function(a,r){var i=e(o,["treemapZoomToNode","treemapRootToNode"],a);if(i){var n=a.getViewRoot();n&&(o.direction=t(n,i.node)?"rollUp":"drillDown"),a.resetViewRoot(i.node)}}))}))}(o)}export{Fe as install};