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

@antv/hierarchy

Package Overview
Dependencies
Maintainers
66
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.6.12 to 0.6.13

51

build/hierarchy.js

@@ -195,4 +195,39 @@ (function webpackUniversalModuleDefinition(root, factory) {

}
reassignXYIfRadial(root, options);
return root;
};
function reassignXYIfRadial(root, options) {
if (options.radial) {
var _ref = options.isHorizontal ? ["x", "y"] : ["y", "x"],
rScale = _ref[0],
radScale = _ref[1];
var min = {
x: Infinity,
y: Infinity
};
var max = {
x: -Infinity,
y: -Infinity
};
var count = 0;
root.DFTraverse(function (node) {
count++;
var x = node.x,
y = node.y;
min.x = Math.min(min.x, x);
min.y = Math.min(min.y, y);
max.x = Math.max(max.x, x);
max.y = Math.max(max.y, y);
});
var radDiff = max[radScale] - min[radScale];
if (radDiff === 0) return;
var avgRad = Math.PI * 2 / count;
root.DFTraverse(function (node) {
var rad = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;
var r = node[rScale] - root[rScale];
node.x = Math.cos(rad) * r;
node.y = Math.sin(rad) * r;
});
}
}

@@ -448,4 +483,4 @@ /***/ }),

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = __webpack_require__(1);

@@ -719,4 +754,4 @@ var nonLayeredTidyTree = __webpack_require__(7);

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = __webpack_require__(1);

@@ -863,4 +898,4 @@ var dendrogram = __webpack_require__(9);

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = __webpack_require__(1);

@@ -975,4 +1010,4 @@ var indentedTree = __webpack_require__(11);

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = __webpack_require__(1);

@@ -979,0 +1014,0 @@ var mindmap = __webpack_require__(13);

2

dist/hierarchy.min.js

@@ -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=5)}([function(t,e){t.exports={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}}},function(t,e,n){var r=n(3),i=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=r(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=i},function(t,e,n){var r=n(4),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 u=r(t,e),f=u.left,a=u.right;n(f,e),n(a,e),e.isHorizontal?f.right2left():f.bottom2top(),a.translate(f.x-a.x,f.y-a.y),t.x=f.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t}},function(t,e,n){function r(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof r)return t;n.data=t;var i=e.getHGap(t),o=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(i,o),n}var i=n(0),o={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},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.label||" ";return t.width||18*e.split("").length}};i.assign(r.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,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.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(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode(function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV})},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,e,n){void 0===e&&(e={});var c,h=new r(t,e=i.assign({},o,e)),u=[h];if(!n&&!t.collapsed)for(;c=u.shift();)if(!c.data.collapsed){var f=e.getChildren(c.data),a=f?f.length:0;if(c.children=new Array(a),f&&a)for(var s=0;s<a;s++){var l=new r(f[s],e);c.children[s]=l,u.push(l),l.parent=c,l.depth=c.depth+1}}return h}},function(t,e,n){var r=n(3);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"},u=0;u<o;u++){var f=t.children[u];"right"===h(f,u)?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(6),dendrogram:n(8),indented:n(10),mindmap:n(12)};t.exports=r},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(7),c=n(2),h=n(0),u=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return c(this.rootNode,this.options,o)},e}(i),f={};t.exports=function(t,e){return e=h.assign({},f,e),new u(t,e).execute()}},function(t,e){function n(t,e,n,r){void 0===r&&(r=[]);var 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,n){void 0===n&&(n=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,e){function h(t){if(0!==t.cs){h(t.c[0]);for(var e=s(f(t.c[0].el),0,null),n=1;n<t.cs;++n){h(t.c[n]);var r=f(t.c[n].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;){f(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 u=f(r),a=f(o);u<=a&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(i+=r.mod),u>=a&&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,n,e),e=s(r,n,e)}!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),u(t)}else u(t)}function u(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 f(t){return t.y+t.h}function a(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++)a(t.c[n],e)}function s(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}void 0===e&&(e={});var l=e.isHorizontal;c(t,l);var d=n.fromNode(t,l);return h(d),a(d,0),o(d,t,l),function(t,e){r(t,-i(t,e),e)}(t,l),t}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(9),c=n(2),h=n(0),u=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return this.rootNode.width=0,c(this.rootNode,this.options,o)},e}(i),f={};t.exports=function(t,e){return e=h.assign({},f,e),new u(t,e).execute()}},function(t,e,n){function r(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach(function(t,i){r(t,e.children[i],n)})}var i=n(0),o={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};t.exports=function(t,e){function n(t){if(!t)return null;t.width=0,t.depth&&t.depth>f&&(f=t.depth);var e=t.children,r=e.length,i=new function(t,e){void 0===t&&(t=0),void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}(t.height,[]);return e.forEach(function(t,e){var o=n(t);i.children.push(o),0===e&&(i.leftChild=o),e===r-1&&(i.rightChild=o)}),i.originNode=t,i.isLeaf=t.isLeaf(),i}function c(t){if(t.isLeaf||0===t.children.length)t.drawingDepth=f;else{var e=t.children.map(function(t){return c(t)}),n=Math.min.apply(null,e);t.drawingDepth=n-1}return t.drawingDepth}function h(t){t.x=t.drawingDepth*e.rankSep,t.isLeaf?(t.y=0,u&&(t.y=u.y+u.height+e.nodeSep,t.originNode.parent!==u.originNode.parent&&(t.y+=e.subTreeSep)),u=t):(t.children.forEach(function(t){h(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}void 0===e&&(e={}),e=i.assign({},o,e);var u,f=0,a=n(t);return c(a),h(a),r(a,t,e.isHorizontal),t}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(11),c=n(4),h=n(0),u=["LR","RL","H"],f=u[0],a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,h=void 0===i||i,a=t.direction,s=void 0===a?f:a,l=t.align;if(s&&-1===u.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===u[0])o(e,r,h,l);else if(s===u[1])o(e,r,h,l),e.right2left();else if(s===u[2]){var d=c(e,t),p=d.left,g=d.right;o(p,r,h,l),p.right2left(),o(g,r,h,l);var y=p.getBoundingBox();g.translate(y.width,0),e.x=g.x-e.width/2}return e},e}(i),s={};t.exports=function(t,e){return e=h.assign({},s,e),new a(t,e).execute()}},function(t,e,n){var r=n(0);t.exports=function(t,e,n,i){var o=null;t.eachNode(function(t){!function(t,e,n,i,o){var c="function"==typeof n?n(t):n*t.depth;if(!i)try{if(t.id===t.parent.children[0].id)return t.x+=c,void(t.y=e?e.y:0)}catch(t){}if(t.x+=c,e){if(t.y=e.y+r.getHeight(e,t,o),e.parent&&t.parent.id!==e.parent.id){var h=e.parent,u=h.y+r.getHeight(h,t,o);t.y=u>t.y?u:t.y}}else t.y=0}(t,o,e,n,i),o=t})}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(13),c=n(2),h=n(0),u=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return c(this.rootNode,this.options,o)},e}(i),f={};t.exports=function(t,e){return e=h.assign({},f,e),new u(t,e).execute()}},function(t,e,n){function r(t,e){var n=0;return t.children.length?t.children.forEach(function(t){n+=r(t,e)}):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function i(t){var e=t.children,n=e.length;if(n){e.forEach(function(t){i(t)});var r=e[0],o=e[n-1],c=o.y-r.y+o.height,h=0;if(e.forEach(function(t){h+=t.totalHeight}),c>t.height)t.y=r.y+c/2-t.height/2;else if(1!==e.length||t.height>h){var u=t.y+(t.height-c)/2-r.y;e.forEach(function(t){t.translate(0,u)})}else t.y=(r.y+r.height/2+o.y+o.height/2)/2-t.height/2}}var o=n(0),c={getSubTreeSep:function(){return 0}};t.exports=function(t,e){void 0===e&&(e={}),e=o.assign({},c,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,r(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}}}}),i(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=5)}([function(t,e){t.exports={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}}},function(t,e,n){var r=n(3),i=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=r(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=i},function(t,e,n){var r=n(4),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),u=a.left,f=a.right;n(u,e),n(f,e),e.isHorizontal?u.right2left():u.bottom2top(),f.translate(u.x-f.x,u.y-f.y),t.x=u.x,t.y=f.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},c={x:-1/0,y:-1/0},h=0;t.DFTraverse(function(t){h++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),c.x=Math.max(c.x,e),c.y=Math.max(c.y,n)});var a=c[i]-o[i];if(0===a)return;var u=2*Math.PI/h;t.DFTraverse(function(e){var n=(e[i]-o[i])/a*(2*Math.PI-u)+u,c=e[r]-t[r];e.x=Math.cos(n)*c,e.y=Math.sin(n)*c})}}(t,e),t}},function(t,e,n){function r(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof r)return t;n.data=t;var i=e.getHGap(t),o=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(i,o),n}var i=n(0),o={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},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.label||" ";return t.width||18*e.split("").length}};i.assign(r.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,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.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(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode(function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV})},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,e,n){void 0===e&&(e={});var c,h=new r(t,e=i.assign({},o,e)),a=[h];if(!n&&!t.collapsed)for(;c=a.shift();)if(!c.data.collapsed){var u=e.getChildren(c.data),f=u?u.length:0;if(c.children=new Array(f),u&&f)for(var s=0;s<f;s++){var l=new r(u[s],e);c.children[s]=l,a.push(l),l.parent=c,l.depth=c.depth+1}}return h}},function(t,e,n){var r=n(3);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 u=t.children[a];"right"===h(u,a)?i.children.push(u):n.children.push(u)}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(6),dendrogram:n(8),indented:n(10),mindmap:n(12)};t.exports=r},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(7),c=n(2),h=n(0),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return c(this.rootNode,this.options,o)},e}(i),u={};t.exports=function(t,e){return e=h.assign({},u,e),new a(t,e).execute()}},function(t,e){function n(t,e,n,r){void 0===r&&(r=[]);var 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,n){void 0===n&&(n=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,e){function h(t){if(0!==t.cs){h(t.c[0]);for(var e=s(u(t.c[0].el),0,null),n=1;n<t.cs;++n){h(t.c[n]);var r=u(t.c[n].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;){u(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 a=u(r),f=u(o);a<=f&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(i+=r.mod),a>=f&&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,n,e),e=s(r,n,e)}!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),a(t)}else a(t)}function a(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 u(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 s(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}void 0===e&&(e={});var l=e.isHorizontal;c(t,l);var d=n.fromNode(t,l);return h(d),f(d,0),o(d,t,l),function(t,e){r(t,-i(t,e),e)}(t,l),t}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(9),c=n(2),h=n(0),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return this.rootNode.width=0,c(this.rootNode,this.options,o)},e}(i),u={};t.exports=function(t,e){return e=h.assign({},u,e),new a(t,e).execute()}},function(t,e,n){function r(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach(function(t,i){r(t,e.children[i],n)})}var i=n(0),o={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};t.exports=function(t,e){function n(t){if(!t)return null;t.width=0,t.depth&&t.depth>u&&(u=t.depth);var e=t.children,r=e.length,i=new function(t,e){void 0===t&&(t=0),void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}(t.height,[]);return e.forEach(function(t,e){var o=n(t);i.children.push(o),0===e&&(i.leftChild=o),e===r-1&&(i.rightChild=o)}),i.originNode=t,i.isLeaf=t.isLeaf(),i}function c(t){if(t.isLeaf||0===t.children.length)t.drawingDepth=u;else{var e=t.children.map(function(t){return c(t)}),n=Math.min.apply(null,e);t.drawingDepth=n-1}return t.drawingDepth}function h(t){t.x=t.drawingDepth*e.rankSep,t.isLeaf?(t.y=0,a&&(t.y=a.y+a.height+e.nodeSep,t.originNode.parent!==a.originNode.parent&&(t.y+=e.subTreeSep)),a=t):(t.children.forEach(function(t){h(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}void 0===e&&(e={}),e=i.assign({},o,e);var a,u=0,f=n(t);return c(f),h(f),r(f,t,e.isHorizontal),t}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(11),c=n(4),h=n(0),a=["LR","RL","H"],u=a[0],f=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,h=void 0===i||i,f=t.direction,s=void 0===f?u:f,l=t.align;if(s&&-1===a.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===a[0])o(e,r,h,l);else if(s===a[1])o(e,r,h,l),e.right2left();else if(s===a[2]){var d=c(e,t),p=d.left,g=d.right;o(p,r,h,l),p.right2left(),o(g,r,h,l);var y=p.getBoundingBox();g.translate(y.width,0),e.x=g.x-e.width/2}return e},e}(i),s={};t.exports=function(t,e){return e=h.assign({},s,e),new f(t,e).execute()}},function(t,e,n){var r=n(0);t.exports=function(t,e,n,i){var o=null;t.eachNode(function(t){!function(t,e,n,i,o){var c="function"==typeof n?n(t):n*t.depth;if(!i)try{if(t.id===t.parent.children[0].id)return t.x+=c,void(t.y=e?e.y:0)}catch(t){}if(t.x+=c,e){if(t.y=e.y+r.getHeight(e,t,o),e.parent&&t.parent.id!==e.parent.id){var h=e.parent,a=h.y+r.getHeight(h,t,o);t.y=a>t.y?a:t.y}}else t.y=0}(t,o,e,n,i),o=t})}},function(t,e,n){function r(t,e){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var i=n(1),o=n(13),c=n(2),h=n(0),a=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}(e,t);return e.prototype.execute=function(){return c(this.rootNode,this.options,o)},e}(i),u={};t.exports=function(t,e){return e=h.assign({},u,e),new a(t,e).execute()}},function(t,e,n){function r(t,e){var n=0;return t.children.length?t.children.forEach(function(t){n+=r(t,e)}):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function i(t){var e=t.children,n=e.length;if(n){e.forEach(function(t){i(t)});var r=e[0],o=e[n-1],c=o.y-r.y+o.height,h=0;if(e.forEach(function(t){h+=t.totalHeight}),c>t.height)t.y=r.y+c/2-t.height/2;else if(1!==e.length||t.height>h){var a=t.y+(t.height-c)/2-r.y;e.forEach(function(t){t.translate(0,a)})}else t.y=(r.y+r.height/2+o.y+o.height/2)/2-t.height/2}}var o=n(0),c={getSubTreeSep:function(){return 0}};t.exports=function(t,e){void 0===e&&(e={}),e=o.assign({},c,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,r(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}}}}),i(t)}}])});

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

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = require('./layout/base');

@@ -4,0 +4,0 @@ var nonLayeredTidyTree = require('./layout/non-layered-tidy');

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

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = require('./layout/base');

@@ -4,0 +4,0 @@ var dendrogram = require('./layout/dendrogram');

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

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = require('./layout/base');

@@ -4,0 +4,0 @@ var indentedTree = require('./layout/indented');

@@ -71,3 +71,38 @@ var separateTree = require('./separate-root');

}
reassignXYIfRadial(root, options);
return root;
};
};
function reassignXYIfRadial(root, options) {
if (options.radial) {
var _ref = options.isHorizontal ? ["x", "y"] : ["y", "x"],
rScale = _ref[0],
radScale = _ref[1];
var min = {
x: Infinity,
y: Infinity
};
var max = {
x: -Infinity,
y: -Infinity
};
var count = 0;
root.DFTraverse(function (node) {
count++;
var x = node.x,
y = node.y;
min.x = Math.min(min.x, x);
min.y = Math.min(min.y, y);
max.x = Math.max(max.x, x);
max.y = Math.max(max.y, y);
});
var radDiff = max[radScale] - min[radScale];
if (radDiff === 0) return;
var avgRad = Math.PI * 2 / count;
root.DFTraverse(function (node) {
var rad = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;
var r = node[rScale] - root[rScale];
node.x = Math.cos(rad) * r;
node.y = Math.sin(rad) * r;
});
}
}

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

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var TreeLayout = require('./layout/base');

@@ -4,0 +4,0 @@ var mindmap = require('./layout/mindmap');

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

@@ -36,4 +36,3 @@ "main": "build/hierarchy.js",

},
"dependencies": {
},
"dependencies": {},
"devDependencies": {

@@ -76,3 +75,6 @@ "@babel/cli": "^7.0.0",

"author": "https://github.com/orgs/antvis/people",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"license": "MIT"
}

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

const separateTree = require('./separate-root');

@@ -70,3 +69,39 @@ const VALID_DIRECTIONS = [

}
reassignXYIfRadial(root, options);
return root;
};
function reassignXYIfRadial(root, options) {
if (options.radial) {
const [ rScale, radScale ] = options.isHorizontal ? [ "x", "y" ] : [ "y", "x" ];
const min = { x: Infinity, y: Infinity };
const max = { x: -Infinity, y: -Infinity };
let count = 0;
root.DFTraverse((node) => {
count++;
const { x, y } = node;
min.x = Math.min(min.x, x);
min.y = Math.min(min.y, y);
max.x = Math.max(max.x, x);
max.y = Math.max(max.y, y);
});
const radDiff = max[radScale] - min[radScale];
if (radDiff === 0) return;
const avgRad = (Math.PI * 2) / count;
root.DFTraverse((node) => {
const rad =
((node[radScale] - min[radScale]) / radDiff) * (Math.PI * 2 - avgRad) +
avgRad;
const r = node[rScale] - root[rScale];
node.x = Math.cos(rad) * r;
node.y = Math.sin(rad) * r;
});
}
}

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