@antv/hierarchy
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -175,7 +175,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
me.depth = 0; | ||
if (!isolated && !data.isCollapsed) { | ||
if (!isolated && !data.collapsed) { | ||
var nodes = [me]; | ||
var node = nodes.pop(); | ||
while (node) { | ||
if (!node.data.isCollapsed) { | ||
if (!node.data.collapsed) { | ||
var children = (options.getChildren || DEFAULT_OPTIONS.getChildren)(node.data); | ||
@@ -182,0 +182,0 @@ var length = children ? children.length : 0; |
@@ -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.Herarchy=e():t.Herarchy=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.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(1),o=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=new r(e,n)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=o},function(t,e){var n={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}},r=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=this;if(i.vgap=i.hgap=0,e instanceof t)return e;i.data=e;var c=(r.getHGap||n.getHGap)(e),a=(r.getVGap||n.getVGap)(e);if(i.width=(r.getWidth||n.getWidth)(e),i.height=(r.getHeight||n.getHeight)(e),i.id=(r.getId||n.getId)(e),i.x=i.y=0,i.depth=0,!o&&!e.isCollapsed)for(var h=[i],f=h.pop();f;){if(!f.data.isCollapsed){var u=(r.getChildren||n.getChildren)(f.data),l=u?u.length:0;if(f.children=[],u&&l)for(var s=0;s<l;s++){var p=new t(u[s],r);f.children.push(p),h.push(p),p.parent=f,p.depth=f.depth+1}}f=h.pop()}i.children||(i.children=[]),i.addGap(c,a)}return t.prototype.isRoot=function(){return 0===this.depth},t.prototype.isLeaf=function(){return 0===this.children.length},t.prototype.addGap=function(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e},t.prototype.eachNode=function(t){for(var e=[this],n=e.pop();n;)t(n),n=(e=e.concat(n.children)).pop()},t.prototype.DFTraverse=function(t){this.eachNode(t)},t.prototype.BFTraverse=function(t){for(var e=[this],n=e.shift();n;)t(n),n=(e=e.concat(n.children)).shift()},t.prototype.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},t.prototype.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})},t.prototype.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)},t.prototype.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.prototype.getCenterX=function(){return this.x+this.width/2},t.prototype.getCenterY=function(){return this.y+this.height/2},t.prototype.getActualWidth=function(){return this.width-2*this.hgap},t.prototype.getActualHeight=function(){return this.height-2*this.vgap},t}();r.prototype.each=r.prototype.eachNode,t.exports=r},function(t,e,n){var r=n(3),o=["LR","RL","TB","BT","H","V"],i=["LR","RL","H"],c=o[0];t.exports=function(t,e,n){var a=e.direction||c;if(e.isHorizontal=function(t){return i.indexOf(t)>-1}(a),a&&-1===o.indexOf(a))throw new TypeError("Invalid direction: "+a);if(a===o[0])n(t,e);else if(a===o[1])n(t,e),t.right2left();else if(a===o[2])n(t,e);else if(a===o[3])n(t,e),t.bottom2top();else if(a===o[4]||a===o[5]){var h=r(t,e),f=h.left,u=h.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,n){var r=n(1);t.exports=function(t,e){for(var n=new r(t.data,e,!0),o=new r(t.data,e,!0),i=t.children.length,c=Math.round(i/2),a=e.getSide||function(t,e){return e<c?"right":"left"},h=0;h<i;h++){var f=t.children[h];"right"===a(f,h)?o.children.push(f):n.children.push(f)}return n.eachNode(function(t){t.isRoot()||(t.side="left")}),o.eachNode(function(t){t.isRoot()||(t.side="right")}),{left:n,right:o}}},function(t,e,n){var r={compactBox:n(5),dendrogram:n(7),indented:n(9)};t.exports=r},function(t,e,n){var r=n(0),o=n(6),i=n(2),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(){var t=i(this.rootNode,this.options,o);return t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t},e}(r),a={};t.exports=function(t,e){return e=Object.assign({},a,e),new c(t,e).execute()}},function(t,e){function n(t,e,r){r?t.y+=e:t.x+=e,t.children.forEach(function(t){n(t,e,r)})}function r(t,e){var n=e?t.y:t.x;return t.children.forEach(function(t){n=Math.min(r(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 i(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){i(t,e,n)})}var c=function t(e,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=this;i.w=e||0,i.h=n||0,i.y=r||0,i.x=0,i.c=o||[],i.cs=o.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};c.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach(function(t){n.push(c.fromNode(t,e))}),e?new c(t.height,t.width,t.x,n):new c(t.width,t.height,t.y,n)},t.exports=function(t){function e(t){if(0!==t.cs){e(t.c[0]);for(var n=u(h(t.c[0].el),0,null),r=1;r<t.cs;++r){e(t.c[r]);var o=h(t.c[r].er);!function(t,e,n){var r=t.c[e-1],o=r.mod,i=t.c[e],c=i.mod;for(;null!==r&&null!==i;){h(r)>n.low&&(n=n.nxt);var a=o+r.prelim+r.w-(c+i.prelim);a>0&&(c+=a,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 o=e-n;t.c[n+1].shift+=r/o,t.c[e].shift-=r/o,t.c[e].change-=r-r/o}}(t,e,n,r)}(t,e,n.index,a));var f=h(r),u=h(i);f<=u&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(o+=r.mod),f>=u&&null!==(i=function(t){return 0===t.cs?t.tl:t.c[0]}(i))&&(c+=i.mod)}!r&&i?function(t,e,n,r){var o=t.c[0].el;o.tl=n;var i=r-n.mod-t.c[0].msel;o.mod+=i,o.prelim-=i,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,i,c):r&&!i&&function(t,e,n,r){var o=t.c[e].er;o.tr=n;var i=r-n.mod-t.c[e].mser;o.mod+=i,o.prelim-=i,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,o)}(t,r,n),n=u(o,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),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 h(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;i(t,l);var s=c.fromNode(t,l);return e(s),f(s,0),o(s,t,l),function(t,e){n(t,-r(t,e),e)}(t,l),t}},function(t,e,n){var r=n(0),o=n(8),i=n(2),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,i(this.rootNode,this.options,o)},e}(r),a={};t.exports=function(t,e){return e=Object.assign({},a,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,o){n(t,e.children[o],r)})}var r=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);var r=this;r.x=r.y=0,r.leftChild=r.rightChild=null,r.height=e||0,r.children=n},o={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,o=n.length,i=new r(t.height,[]);return n.forEach(function(t,n){var r=e(t);i.children.push(r),0===n&&(i.leftChild=r),n===o-1&&(i.rightChild=r)}),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 c(t){t.x=t.drawingDepth*a.rankSep,t.isLeaf?(t.y=0,f&&(t.y=f.y+f.height+a.nodeSep,t.originNode.parent!==f.originNode.parent&&(t.y+=a.subTreeSep)),f=t):(t.children.forEach(function(t){c(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=Object.assign({},o,a);var h=0,f=void 0,u=e(t);return i(u),c(u),n(u,t,a.isHorizontal),t}},function(t,e,n){var r=n(0),o=n(10),i=n(3),c=["LR","RL","H"],a=c[0],h=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||a;if(r&&-1===c.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===c[0])o(e,n);else if(r===c[1])o(e,n),e.right2left();else if(r===c[2]){var h=i(e,t),f=h.left,u=h.right;o(f,n),f.right2left(),o(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 h(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){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Herarchy=e():t.Herarchy=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.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(1),o=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=new r(e,n)}return t.prototype.execute=function(){throw new Error("please override this method")},t}();t.exports=o},function(t,e){var n={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}},r=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=this;if(i.vgap=i.hgap=0,e instanceof t)return e;i.data=e;var c=(r.getHGap||n.getHGap)(e),a=(r.getVGap||n.getVGap)(e);if(i.width=(r.getWidth||n.getWidth)(e),i.height=(r.getHeight||n.getHeight)(e),i.id=(r.getId||n.getId)(e),i.x=i.y=0,i.depth=0,!o&&!e.collapsed)for(var h=[i],f=h.pop();f;){if(!f.data.collapsed){var u=(r.getChildren||n.getChildren)(f.data),l=u?u.length:0;if(f.children=[],u&&l)for(var s=0;s<l;s++){var p=new t(u[s],r);f.children.push(p),h.push(p),p.parent=f,p.depth=f.depth+1}}f=h.pop()}i.children||(i.children=[]),i.addGap(c,a)}return t.prototype.isRoot=function(){return 0===this.depth},t.prototype.isLeaf=function(){return 0===this.children.length},t.prototype.addGap=function(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e},t.prototype.eachNode=function(t){for(var e=[this],n=e.pop();n;)t(n),n=(e=e.concat(n.children)).pop()},t.prototype.DFTraverse=function(t){this.eachNode(t)},t.prototype.BFTraverse=function(t){for(var e=[this],n=e.shift();n;)t(n),n=(e=e.concat(n.children)).shift()},t.prototype.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},t.prototype.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})},t.prototype.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)},t.prototype.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.prototype.getCenterX=function(){return this.x+this.width/2},t.prototype.getCenterY=function(){return this.y+this.height/2},t.prototype.getActualWidth=function(){return this.width-2*this.hgap},t.prototype.getActualHeight=function(){return this.height-2*this.vgap},t}();r.prototype.each=r.prototype.eachNode,t.exports=r},function(t,e,n){var r=n(3),o=["LR","RL","TB","BT","H","V"],i=["LR","RL","H"],c=o[0];t.exports=function(t,e,n){var a=e.direction||c;if(e.isHorizontal=function(t){return i.indexOf(t)>-1}(a),a&&-1===o.indexOf(a))throw new TypeError("Invalid direction: "+a);if(a===o[0])n(t,e);else if(a===o[1])n(t,e),t.right2left();else if(a===o[2])n(t,e);else if(a===o[3])n(t,e),t.bottom2top();else if(a===o[4]||a===o[5]){var h=r(t,e),f=h.left,u=h.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,n){var r=n(1);t.exports=function(t,e){for(var n=new r(t.data,e,!0),o=new r(t.data,e,!0),i=t.children.length,c=Math.round(i/2),a=e.getSide||function(t,e){return e<c?"right":"left"},h=0;h<i;h++){var f=t.children[h];"right"===a(f,h)?o.children.push(f):n.children.push(f)}return n.eachNode(function(t){t.isRoot()||(t.side="left")}),o.eachNode(function(t){t.isRoot()||(t.side="right")}),{left:n,right:o}}},function(t,e,n){var r={compactBox:n(5),dendrogram:n(7),indented:n(9)};t.exports=r},function(t,e,n){var r=n(0),o=n(6),i=n(2),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(){var t=i(this.rootNode,this.options,o);return t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t},e}(r),a={};t.exports=function(t,e){return e=Object.assign({},a,e),new c(t,e).execute()}},function(t,e){function n(t,e,r){r?t.y+=e:t.x+=e,t.children.forEach(function(t){n(t,e,r)})}function r(t,e){var n=e?t.y:t.x;return t.children.forEach(function(t){n=Math.min(r(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 i(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){i(t,e,n)})}var c=function t(e,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=this;i.w=e||0,i.h=n||0,i.y=r||0,i.x=0,i.c=o||[],i.cs=o.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};c.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach(function(t){n.push(c.fromNode(t,e))}),e?new c(t.height,t.width,t.x,n):new c(t.width,t.height,t.y,n)},t.exports=function(t){function e(t){if(0!==t.cs){e(t.c[0]);for(var n=u(h(t.c[0].el),0,null),r=1;r<t.cs;++r){e(t.c[r]);var o=h(t.c[r].er);!function(t,e,n){var r=t.c[e-1],o=r.mod,i=t.c[e],c=i.mod;for(;null!==r&&null!==i;){h(r)>n.low&&(n=n.nxt);var a=o+r.prelim+r.w-(c+i.prelim);a>0&&(c+=a,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 o=e-n;t.c[n+1].shift+=r/o,t.c[e].shift-=r/o,t.c[e].change-=r-r/o}}(t,e,n,r)}(t,e,n.index,a));var f=h(r),u=h(i);f<=u&&null!==(r=function(t){return 0===t.cs?t.tr:t.c[t.cs-1]}(r))&&(o+=r.mod),f>=u&&null!==(i=function(t){return 0===t.cs?t.tl:t.c[0]}(i))&&(c+=i.mod)}!r&&i?function(t,e,n,r){var o=t.c[0].el;o.tl=n;var i=r-n.mod-t.c[0].msel;o.mod+=i,o.prelim-=i,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,i,c):r&&!i&&function(t,e,n,r){var o=t.c[e].er;o.tr=n;var i=r-n.mod-t.c[e].mser;o.mod+=i,o.prelim-=i,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,o)}(t,r,n),n=u(o,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),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 h(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;i(t,l);var s=c.fromNode(t,l);return e(s),f(s,0),o(s,t,l),function(t,e){n(t,-r(t,e),e)}(t,l),t}},function(t,e,n){var r=n(0),o=n(8),i=n(2),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,i(this.rootNode,this.options,o)},e}(r),a={};t.exports=function(t,e){return e=Object.assign({},a,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,o){n(t,e.children[o],r)})}var r=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);var r=this;r.x=r.y=0,r.leftChild=r.rightChild=null,r.height=e||0,r.children=n},o={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,o=n.length,i=new r(t.height,[]);return n.forEach(function(t,n){var r=e(t);i.children.push(r),0===n&&(i.leftChild=r),n===o-1&&(i.rightChild=r)}),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 c(t){t.x=t.drawingDepth*a.rankSep,t.isLeaf?(t.y=0,f&&(t.y=f.y+f.height+a.nodeSep,t.originNode.parent!==f.originNode.parent&&(t.y+=a.subTreeSep)),f=t):(t.children.forEach(function(t){c(t)}),t.y=(t.leftChild.y+t.rightChild.y)/2)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=Object.assign({},o,a);var h=0,f=void 0,u=e(t);return i(u),c(u),n(u,t,a.isHorizontal),t}},function(t,e,n){var r=n(0),o=n(10),i=n(3),c=["LR","RL","H"],a=c[0],h=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||a;if(r&&-1===c.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===c[0])o(e,n);else if(r===c[1])o(e,n),e.right2left();else if(r===c[2]){var h=i(e,t),f=h.left,u=h.right;o(f,n),f.right2left(),o(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 h(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})}}])}); |
@@ -68,7 +68,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
me.depth = 0; | ||
if (!isolated && !data.isCollapsed) { | ||
if (!isolated && !data.collapsed) { | ||
var nodes = [me]; | ||
var node = nodes.pop(); | ||
while (node) { | ||
if (!node.data.isCollapsed) { | ||
if (!node.data.collapsed) { | ||
var children = (options.getChildren || DEFAULT_OPTIONS.getChildren)(node.data); | ||
@@ -75,0 +75,0 @@ var length = children ? children.length : 0; |
{ | ||
"name": "@antv/hierarchy", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "layout algorithms for visualizing hierarchical data", | ||
@@ -5,0 +5,0 @@ "main": "build/hierarchy.js", |
@@ -62,7 +62,7 @@ | ||
me.depth = 0; | ||
if (!isolated && !data.isCollapsed) { | ||
if (!isolated && !data.collapsed) { | ||
const nodes = [ me ]; | ||
let node = nodes.pop(); | ||
while (node) { | ||
if (!node.data.isCollapsed) { | ||
if (!node.data.collapsed) { | ||
const children = (options.getChildren || DEFAULT_OPTIONS.getChildren)(node.data); | ||
@@ -69,0 +69,0 @@ const length = children ? children.length : 0; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178363