Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/hierarchy

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/hierarchy - npm Package Compare versions

Comparing version 0.3.12 to 0.3.13

2

build/hierarchy.js

@@ -1042,3 +1042,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

// 多于一个子节点或者父节点大于所有子节点的总高度
var offset = (node.height - childrenHeight) / 2;
var offset = node.y + (node.height - childrenHeight) / 2 - first.y;
children.forEach(function (c) {

@@ -1045,0 +1045,0 @@ c.translate(0, offset);

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Hierarchy=e():t.Hierarchy=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){var r=n(2),i=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.options=n,this.rootNode=r(e,n)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=i},function(t,e,n){var r=n(3),i=["LR","RL","TB","BT","H","V"],o=["LR","RL","H"],c=i[0];t.exports=function(t,e,n){var h=e.direction||c;if(e.isHorizontal=function(t){return o.indexOf(t)>-1}(h),h&&-1===i.indexOf(h))throw new TypeError("Invalid direction: "+h);if(h===i[0])n(t,e);else if(h===i[1])n(t,e),t.right2left();else if(h===i[2])n(t,e);else if(h===i[3])n(t,e),t.bottom2top();else if(h===i[4]||h===i[5]){var a=r(t,e),f=a.left,u=a.right;n(f,e),n(u,e),e.isHorizontal?f.right2left():f.bottom2top(),u.translate(f.x-u.x,f.y-u.y),t.x=f.x,t.y=u.y;var l=t.getBoundingBox();e.isHorizontal?l.top<0&&t.translate(0,-l.top):l.left<0&&t.translate(-l.left,0)}return t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t}},function(t,e){function n(t,e){var r=this;if(r.vgap=r.hgap=0,t instanceof n)return t;r.data=t;var i=e.getHGap(t),o=e.getVGap(t);return r.width=e.getWidth(t),r.height=e.getHeight(t),r.id=e.getId(t),r.x=r.y=0,r.depth=0,r.children||(r.children=[]),r.addGap(i,o),r}var r={getId:function(t){return t.id||t.name},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.name||" ";return t.width||18*e.split("").length}};Object.assign(n.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e},eachNode:function(t){for(var e=[this],n=void 0;n=e.pop();)t(n),e=e.concat(n.children)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e=[this],n=void 0;n=e.shift();)t(n),e=e.concat(n.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)}),t},translate:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.eachNode(function(n){n.x+=t,n.y+=e})},right2left:function(){var t=this.getBoundingBox();this.eachNode(function(e){e.x=e.x-2*(e.x-t.left)-e.width}),this.translate(t.width,0)},bottom2top:function(){var t=this.getBoundingBox();this.eachNode(function(e){e.y=e.y-2*(e.y-t.top)-e.height}),this.translate(0,t.height)}}),t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments[2],o=new n(t,e=Object.assign({},r,e)),c=[o],h=void 0;if(!i&&!t.collapsed)for(;h=c.pop();)if(!h.data.collapsed){var a=e.getChildren(h.data),f=a?a.length:0;if(h.children=new Array(f),a&&f)for(var u=0;u<f;u++){var l=new n(a[u],e);h.children[u]=l,c.push(l),l.parent=h,l.depth=h.depth+1}}return o}},function(t,e,n){var r=n(2);t.exports=function(t,e){for(var n=r(t.data,e,!0),i=r(t.data,e,!0),o=t.children.length,c=Math.round(o/2),h=e.getSide||function(t,e){return e<c?"right":"left"},a=0;a<o;a++){var f=t.children[a];"right"===h(f,a)?i.children.push(f):n.children.push(f)}return n.eachNode(function(t){t.isRoot()||(t.side="left")}),i.eachNode(function(t){t.isRoot()||(t.side="right")}),{left:n,right:i}}},function(t,e,n){var r={compactBox:n(5),dendrogram:n(7),indented:n(9),mindmap:n(11)};t.exports=r},function(t,e,n){var r=n(0),i=n(6),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function r(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach(function(t){r(t,e,n)})}function i(t,e){var n=e?t.y:t.x;return t.children.forEach(function(t){n=Math.min(i(t,e),n)}),n}function o(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach(function(t,r){o(t,e.children[r],n)})}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach(function(t){c(t,e,n)})}n.fromNode=function(t,e){if(!t)return null;var r=[];return t.children.forEach(function(t){r.push(n.fromNode(t,e))}),e?new n(t.height,t.width,t.x,r):new n(t.width,t.height,t.y,r)},t.exports=function(t){function e(t){if(0!==t.cs){e(t.c[0]);for(var n=u(a(t.c[0].el),0,null),r=1;r<t.cs;++r){e(t.c[r]);var i=a(t.c[r].er);!function(t,e,n){var r=t.c[e-1],i=r.mod,o=t.c[e],c=o.mod;for(;null!==r&&null!==o;){a(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+o.prelim);h>0&&(c+=h,function(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}(t,e,n.index,h));var f=a(r),u=a(o);f<=u&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(i+=r.mod),f>=u&&null!==(o=function(t){return 0===t.cs?t.tl:t.c[0]}(o))&&(c+=o.mod)}!r&&o?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,o,c):r&&!o&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}(t,r,n),n=u(i,r,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(t),h(t)}else h(t)}function h(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function a(t){return t.y+t.h}function f(t,e){e+=t.mod,t.x=t.prelim+e,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)e+=t.c[r].shift,n+=e+t.c[r].change,t.c[r].mod+=n}(t);for(var n=0;n<t.cs;n++)f(t.c[n],e)}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}var l=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isHorizontal;c(t,l);var s=n.fromNode(t,l);return e(s),f(s,0),o(s,t,l),function(t,e){r(t,-i(t,e),e)}(t,l),t}},function(t,e,n){var r=n(0),i=n(8),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return this.rootNode.width=0,o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e,r){r?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach(function(t,i){n(t,e.children[i],r)})}var r={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};t.exports=function(t){function e(t){if(!t)return null;t.width=0,t.depth&&t.depth>h&&(h=t.depth);var n=t.children,r=n.length,i=new function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],e=this;e.x=e.y=0,e.leftChild=e.rightChild=null,e.height=0,e.children=t}(t.height,[]);return n.forEach(function(t,n){var o=e(t);i.children.push(o),0===n&&(i.leftChild=o),n===r-1&&(i.rightChild=o)}),i.originNode=t,i.isLeaf=t.isLeaf(),i}function i(t){if(t.isLeaf||0===t.children.length)t.drawingDepth=h;else{var e=t.children.map(function(t){return i(t)}),n=Math.min.apply(null,e);t.drawingDepth=n-1}return t.drawingDepth}function o(t){t.x=t.drawingDepth*c.rankSep,t.isLeaf?(t.y=0,a&&(t.y=a.y+a.height+c.nodeSep,t.originNode.parent!==a.originNode.parent&&(t.y+=c.subTreeSep)),a=t):(t.children.forEach(function(t){o(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c=Object.assign({},r,c);var h=0,a=void 0,f=e(t);return i(f),o(f),n(f,t,c.isHorizontal),t}},function(t,e,n){var r=n(0),i=n(10),o=n(3),c=["LR","RL","H"],h=c[0],a=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=t.direction||h;if(r&&-1===c.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===c[0])i(e,n);else if(r===c[1])i(e,n),e.right2left();else if(r===c[2]){var a=o(e,t),f=a.left,u=a.right;i(f,n),f.right2left(),i(u,n);var l=f.getBoundingBox();u.translate(l.width,0),e.x=u.x-e.width/2}return e},e}(r),f={};t.exports=function(t,e){return e=Object.assign({},f,e),new a(t,e).execute()}},function(t,e){t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,n=null;t.eachNode(function(t){!function(t,e,n){t.x+=n*t.depth,t.y=e?e.y+e.height:0}(t,n,e),n=t})}},function(t,e,n){var r=n(0),i=n(12),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e){var r=0;return t.children.length?t.children.forEach(function(t){r+=n(t,e)}):r=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,r)+2*t._subTreeSep,t.totalHeight}function r(t){var e=t.children,n=e.length;if(n){e.forEach(function(t){r(t)});var i=e[0],o=e[n-1],c=o.y-i.y+o.height,h=0;if(e.forEach(function(t){h+=t.totalHeight}),c>t.height)t.y=i.y+c/2-t.height/2;else if(1!==e.length||t.height>h){var a=(t.height-c)/2;e.forEach(function(t){t.translate(0,a)})}else t.y=(i.y+i.height/2+o.y+o.height/2)/2-t.height/2}}var i={getSubTreeSep:function(){return 0}};t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=Object.assign({},i,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse(function(t){t.x=t.parent.x+t.parent.width}),t.parent=null,n(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode(function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}}),r(t)}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Hierarchy=e():t.Hierarchy=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){var r=n(2),i=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.options=n,this.rootNode=r(e,n)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=i},function(t,e,n){var r=n(3),i=["LR","RL","TB","BT","H","V"],o=["LR","RL","H"],c=i[0];t.exports=function(t,e,n){var h=e.direction||c;if(e.isHorizontal=function(t){return o.indexOf(t)>-1}(h),h&&-1===i.indexOf(h))throw new TypeError("Invalid direction: "+h);if(h===i[0])n(t,e);else if(h===i[1])n(t,e),t.right2left();else if(h===i[2])n(t,e);else if(h===i[3])n(t,e),t.bottom2top();else if(h===i[4]||h===i[5]){var a=r(t,e),f=a.left,u=a.right;n(f,e),n(u,e),e.isHorizontal?f.right2left():f.bottom2top(),u.translate(f.x-u.x,f.y-u.y),t.x=f.x,t.y=u.y;var l=t.getBoundingBox();e.isHorizontal?l.top<0&&t.translate(0,-l.top):l.left<0&&t.translate(-l.left,0)}return t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t}},function(t,e){function n(t,e){var r=this;if(r.vgap=r.hgap=0,t instanceof n)return t;r.data=t;var i=e.getHGap(t),o=e.getVGap(t);return r.width=e.getWidth(t),r.height=e.getHeight(t),r.id=e.getId(t),r.x=r.y=0,r.depth=0,r.children||(r.children=[]),r.addGap(i,o),r}var r={getId:function(t){return t.id||t.name},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.name||" ";return t.width||18*e.split("").length}};Object.assign(n.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e},eachNode:function(t){for(var e=[this],n=void 0;n=e.pop();)t(n),e=e.concat(n.children)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e=[this],n=void 0;n=e.shift();)t(n),e=e.concat(n.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)}),t},translate:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.eachNode(function(n){n.x+=t,n.y+=e})},right2left:function(){var t=this.getBoundingBox();this.eachNode(function(e){e.x=e.x-2*(e.x-t.left)-e.width}),this.translate(t.width,0)},bottom2top:function(){var t=this.getBoundingBox();this.eachNode(function(e){e.y=e.y-2*(e.y-t.top)-e.height}),this.translate(0,t.height)}}),t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments[2],o=new n(t,e=Object.assign({},r,e)),c=[o],h=void 0;if(!i&&!t.collapsed)for(;h=c.pop();)if(!h.data.collapsed){var a=e.getChildren(h.data),f=a?a.length:0;if(h.children=new Array(f),a&&f)for(var u=0;u<f;u++){var l=new n(a[u],e);h.children[u]=l,c.push(l),l.parent=h,l.depth=h.depth+1}}return o}},function(t,e,n){var r=n(2);t.exports=function(t,e){for(var n=r(t.data,e,!0),i=r(t.data,e,!0),o=t.children.length,c=Math.round(o/2),h=e.getSide||function(t,e){return e<c?"right":"left"},a=0;a<o;a++){var f=t.children[a];"right"===h(f,a)?i.children.push(f):n.children.push(f)}return n.eachNode(function(t){t.isRoot()||(t.side="left")}),i.eachNode(function(t){t.isRoot()||(t.side="right")}),{left:n,right:i}}},function(t,e,n){var r={compactBox:n(5),dendrogram:n(7),indented:n(9),mindmap:n(11)};t.exports=r},function(t,e,n){var r=n(0),i=n(6),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function r(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach(function(t){r(t,e,n)})}function i(t,e){var n=e?t.y:t.x;return t.children.forEach(function(t){n=Math.min(i(t,e),n)}),n}function o(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach(function(t,r){o(t,e.children[r],n)})}function c(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach(function(t){c(t,e,n)})}n.fromNode=function(t,e){if(!t)return null;var r=[];return t.children.forEach(function(t){r.push(n.fromNode(t,e))}),e?new n(t.height,t.width,t.x,r):new n(t.width,t.height,t.y,r)},t.exports=function(t){function e(t){if(0!==t.cs){e(t.c[0]);for(var n=u(a(t.c[0].el),0,null),r=1;r<t.cs;++r){e(t.c[r]);var i=a(t.c[r].er);!function(t,e,n){var r=t.c[e-1],i=r.mod,o=t.c[e],c=o.mod;for(;null!==r&&null!==o;){a(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+o.prelim);h>0&&(c+=h,function(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}(t,e,n.index,h));var f=a(r),u=a(o);f<=u&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(i+=r.mod),f>=u&&null!==(o=function(t){return 0===t.cs?t.tl:t.c[0]}(o))&&(c+=o.mod)}!r&&o?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,o,c):r&&!o&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}(t,r,n),n=u(i,r,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(t),h(t)}else h(t)}function h(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function a(t){return t.y+t.h}function f(t,e){e+=t.mod,t.x=t.prelim+e,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)e+=t.c[r].shift,n+=e+t.c[r].change,t.c[r].mod+=n}(t);for(var n=0;n<t.cs;n++)f(t.c[n],e)}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}var l=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isHorizontal;c(t,l);var s=n.fromNode(t,l);return e(s),f(s,0),o(s,t,l),function(t,e){r(t,-i(t,e),e)}(t,l),t}},function(t,e,n){var r=n(0),i=n(8),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return this.rootNode.width=0,o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e,r){r?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach(function(t,i){n(t,e.children[i],r)})}var r={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};t.exports=function(t){function e(t){if(!t)return null;t.width=0,t.depth&&t.depth>h&&(h=t.depth);var n=t.children,r=n.length,i=new function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],e=this;e.x=e.y=0,e.leftChild=e.rightChild=null,e.height=0,e.children=t}(t.height,[]);return n.forEach(function(t,n){var o=e(t);i.children.push(o),0===n&&(i.leftChild=o),n===r-1&&(i.rightChild=o)}),i.originNode=t,i.isLeaf=t.isLeaf(),i}function i(t){if(t.isLeaf||0===t.children.length)t.drawingDepth=h;else{var e=t.children.map(function(t){return i(t)}),n=Math.min.apply(null,e);t.drawingDepth=n-1}return t.drawingDepth}function o(t){t.x=t.drawingDepth*c.rankSep,t.isLeaf?(t.y=0,a&&(t.y=a.y+a.height+c.nodeSep,t.originNode.parent!==a.originNode.parent&&(t.y+=c.subTreeSep)),a=t):(t.children.forEach(function(t){o(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c=Object.assign({},r,c);var h=0,a=void 0,f=e(t);return i(f),o(f),n(f,t,c.isHorizontal),t}},function(t,e,n){var r=n(0),i=n(10),o=n(3),c=["LR","RL","H"],h=c[0],a=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=t.direction||h;if(r&&-1===c.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===c[0])i(e,n);else if(r===c[1])i(e,n),e.right2left();else if(r===c[2]){var a=o(e,t),f=a.left,u=a.right;i(f,n),f.right2left(),i(u,n);var l=f.getBoundingBox();u.translate(l.width,0),e.x=u.x-e.width/2}return e},e}(r),f={};t.exports=function(t,e){return e=Object.assign({},f,e),new a(t,e).execute()}},function(t,e){t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,n=null;t.eachNode(function(t){!function(t,e,n){t.x+=n*t.depth,t.y=e?e.y+e.height:0}(t,n,e),n=t})}},function(t,e,n){var r=n(0),i=n(12),o=n(1),c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.execute=function(){return o(this.rootNode,this.options,i)},e}(r),h={};t.exports=function(t,e){return e=Object.assign({},h,e),new c(t,e).execute()}},function(t,e){function n(t,e){var r=0;return t.children.length?t.children.forEach(function(t){r+=n(t,e)}):r=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,r)+2*t._subTreeSep,t.totalHeight}function r(t){var e=t.children,n=e.length;if(n){e.forEach(function(t){r(t)});var i=e[0],o=e[n-1],c=o.y-i.y+o.height,h=0;if(e.forEach(function(t){h+=t.totalHeight}),c>t.height)t.y=i.y+c/2-t.height/2;else if(1!==e.length||t.height>h){var a=t.y+(t.height-c)/2-i.y;e.forEach(function(t){t.translate(0,a)})}else t.y=(i.y+i.height/2+o.y+o.height/2)/2-t.height/2}}var i={getSubTreeSep:function(){return 0}};t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=Object.assign({},i,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse(function(t){t.x=t.parent.x+t.parent.width}),t.parent=null,n(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode(function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}}),r(t)}}])});

@@ -35,3 +35,3 @@

// 多于一个子节点或者父节点大于所有子节点的总高度
var offset = (node.height - childrenHeight) / 2;
var offset = node.y + (node.height - childrenHeight) / 2 - first.y;
children.forEach(function (c) {

@@ -38,0 +38,0 @@ c.translate(0, offset);

{
"name": "@antv/hierarchy",
"version": "0.3.12",
"version": "0.3.13",
"description": "layout algorithms for visualizing hierarchical data",

@@ -5,0 +5,0 @@ "main": "build/hierarchy.js",

@@ -35,3 +35,3 @@

// 多于一个子节点或者父节点大于所有子节点的总高度
const offset = (node.height - childrenHeight) / 2;
const offset = node.y + (node.height - childrenHeight) / 2 - first.y;
children.forEach(c => {

@@ -38,0 +38,0 @@ c.translate(0, offset);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc