@antv/hierarchy 0.6.13 → 0.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/hierarchy.js
CHANGED
|
@@ -965,7 +965,7 @@ module.exports = indentedLayout;
|
|
|
965
965
|
var util = __webpack_require__(0);
|
|
966
966
|
function positionNode(node, previousNode, indent, dropCap, align) {
|
|
967
967
|
// caculate the node's horizontal offset DX, dx's type might be number or function
|
|
968
|
-
var displacementX = typeof indent === "function" ? indent(node) : indent * node.depth;
|
|
968
|
+
var displacementX = (typeof indent === "function" ? indent(node) : indent) * node.depth;
|
|
969
969
|
if (!dropCap) {
|
|
970
970
|
try {
|
|
971
971
|
if (node.id === node.parent.children[0].id) {
|
package/build/hierarchy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchy.js","sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8e530ea718b7866c10c8","webpack:///./src/util.js","webpack:///./src/layout/base.js","webpack:///./src/layout/do-layout.js","webpack:///./src/layout/hierarchy.js","webpack:///./src/layout/separate-root.js","webpack:///./src/index.js","webpack:///./src/compact-box.js","webpack:///./src/layout/non-layered-tidy.js","webpack:///./src/dendrogram.js","webpack:///./src/layout/dendrogram.js","webpack:///./src/indented.js","webpack:///./src/layout/indented.js","webpack:///./src/mindmap.js","webpack:///./src/layout/mindmap.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Hierarchy\"] = factory();\n\telse\n\t\troot[\"Hierarchy\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 8e530ea718b7866c10c8","/**\n * Get average height or height for node's position calculation, according to align.\n * @param {*} preNode previous node\n * @param {*} node current node, whose position is going to be calculated\n * @param {'center' | undefined} align 'center' means nodes align at the center, other value means align at the left-top\n * @param {string} heightField field name for height value on preNode and node\n * @return {number} the height for calculation\n */\nfunction getHeight(preNode, node, align, heightField) {\n if (heightField === void 0) {\n heightField = 'height';\n }\n return align === 'center' ? (preNode[heightField] + node[heightField]) / 2 : preNode.height;\n}\nmodule.exports = {\n assign: Object.assign,\n getHeight: getHeight\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/util.js\n// module id = 0\n// module chunks = 0","var hierarchy = require('./hierarchy');\nvar Layout = /*#__PURE__*/function () {\n function Layout(root, options) {\n if (options === void 0) {\n options = {};\n }\n var me = this;\n me.options = options;\n me.rootNode = hierarchy(root, options);\n }\n var _proto = Layout.prototype;\n _proto.execute = function execute() {\n throw new Error('please override this method');\n };\n return Layout;\n}();\nmodule.exports = Layout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/base.js\n// module id = 1\n// module chunks = 0","var separateTree = require('./separate-root');\nvar VALID_DIRECTIONS = ['LR',\n// left to right\n'RL',\n// right to left\n'TB',\n// top to bottom\n'BT',\n// bottom to top\n'H',\n// horizontal\n'V' // vertical\n];\nvar HORIZONTAL_DIRECTIONS = ['LR', 'RL', 'H'];\nvar isHorizontal = function isHorizontal(direction) {\n return HORIZONTAL_DIRECTIONS.indexOf(direction) > -1;\n};\nvar DEFAULT_DIRECTION = VALID_DIRECTIONS[0];\nmodule.exports = function (root, options, layoutAlgrithm) {\n var direction = options.direction || DEFAULT_DIRECTION;\n options.isHorizontal = isHorizontal(direction);\n if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {\n throw new TypeError(\"Invalid direction: \" + direction);\n }\n if (direction === VALID_DIRECTIONS[0]) {\n // LR\n layoutAlgrithm(root, options);\n } else if (direction === VALID_DIRECTIONS[1]) {\n // RL\n layoutAlgrithm(root, options);\n root.right2left();\n } else if (direction === VALID_DIRECTIONS[2]) {\n // TB\n layoutAlgrithm(root, options);\n } else if (direction === VALID_DIRECTIONS[3]) {\n // BT\n layoutAlgrithm(root, options);\n root.bottom2top();\n } else if (direction === VALID_DIRECTIONS[4] || direction === VALID_DIRECTIONS[5]) {\n // H or V\n // separate into left and right trees\n var _separateTree = separateTree(root, options),\n left = _separateTree.left,\n right = _separateTree.right;\n // do layout for left and right trees\n layoutAlgrithm(left, options);\n layoutAlgrithm(right, options);\n options.isHorizontal ? left.right2left() : left.bottom2top();\n // combine left and right trees\n right.translate(left.x - right.x, left.y - right.y);\n // translate root\n root.x = left.x;\n root.y = right.y;\n var bb = root.getBoundingBox();\n if (options.isHorizontal) {\n if (bb.top < 0) {\n root.translate(0, -bb.top);\n }\n } else {\n if (bb.left < 0) {\n root.translate(-bb.left, 0);\n }\n }\n }\n // fixed root position, default value is true\n var fixedRoot = options.fixedRoot;\n if (fixedRoot === undefined) fixedRoot = true;\n if (fixedRoot) {\n root.translate(-(root.x + root.width / 2 + root.hgap), -(root.y + root.height / 2 + root.vgap));\n }\n reassignXYIfRadial(root, options);\n return root;\n};\nfunction reassignXYIfRadial(root, options) {\n if (options.radial) {\n var _ref = options.isHorizontal ? [\"x\", \"y\"] : [\"y\", \"x\"],\n rScale = _ref[0],\n radScale = _ref[1];\n var min = {\n x: Infinity,\n y: Infinity\n };\n var max = {\n x: -Infinity,\n y: -Infinity\n };\n var count = 0;\n root.DFTraverse(function (node) {\n count++;\n var x = node.x,\n y = node.y;\n min.x = Math.min(min.x, x);\n min.y = Math.min(min.y, y);\n max.x = Math.max(max.x, x);\n max.y = Math.max(max.y, y);\n });\n var radDiff = max[radScale] - min[radScale];\n if (radDiff === 0) return;\n var avgRad = Math.PI * 2 / count;\n root.DFTraverse(function (node) {\n var rad = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;\n var r = node[rScale] - root[rScale];\n node.x = Math.cos(rad) * r;\n node.y = Math.sin(rad) * r;\n });\n }\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/do-layout.js\n// module id = 2\n// module chunks = 0","/* eslint-disable no-cond-assign */\nvar util = require('../util');\nvar PEM = 18;\nvar DEFAULT_HEIGHT = PEM * 2;\nvar DEFAULT_GAP = PEM;\nvar DEFAULT_OPTIONS = {\n getId: function getId(d) {\n return d.id || d.name;\n },\n getPreH: function getPreH(d) {\n return d.preH || 0;\n },\n getPreV: function getPreV(d) {\n return d.preV || 0;\n },\n getHGap: function getHGap(d) {\n return d.hgap || DEFAULT_GAP;\n },\n getVGap: function getVGap(d) {\n return d.vgap || DEFAULT_GAP;\n },\n getChildren: function getChildren(d) {\n return d.children;\n },\n getHeight: function getHeight(d) {\n return d.height || DEFAULT_HEIGHT;\n },\n getWidth: function getWidth(d) {\n var label = d.label || ' ';\n return d.width || label.split('').length * PEM; // FIXME DO NOT get width like this\n }\n};\nfunction Node(data, options) {\n var me = this;\n me.vgap = me.hgap = 0;\n if (data instanceof Node) return data;\n me.data = data;\n /*\n * Gaps: filling space between nodes\n * (x, y) ----------------------\n * | vgap |\n * | -------------------- h\n * | h | | e\n * | g | | i\n * | a | | g\n * | p | | h\n * | --------------------- t\n * | |\n * -----------width------------\n */\n var hgap = options.getHGap(data);\n var vgap = options.getVGap(data);\n me.preH = options.getPreH(data);\n me.preV = options.getPreV(data);\n me.width = options.getWidth(data);\n me.height = options.getHeight(data);\n me.width += me.preH;\n me.height += me.preV;\n me.id = options.getId(data);\n me.x = me.y = 0;\n me.depth = 0;\n if (!me.children) {\n me.children = [];\n }\n me.addGap(hgap, vgap);\n return me;\n}\nutil.assign(Node.prototype, {\n isRoot: function isRoot() {\n return this.depth === 0;\n },\n isLeaf: function isLeaf() {\n return this.children.length === 0;\n },\n addGap: function addGap(hgap, vgap) {\n var me = this;\n me.hgap += hgap;\n me.vgap += vgap;\n me.width += 2 * hgap;\n me.height += 2 * vgap;\n },\n eachNode: function eachNode(callback) {\n // Depth First traverse\n var me = this;\n var nodes = [me];\n var current;\n while (current = nodes.shift()) {\n callback(current);\n nodes = current.children.concat(nodes);\n }\n },\n DFTraverse: function DFTraverse(callback) {\n // Depth First traverse\n this.eachNode(callback);\n },\n BFTraverse: function BFTraverse(callback) {\n // Breadth First traverse\n var me = this;\n var nodes = [me];\n var current;\n while (current = nodes.shift()) {\n callback(current);\n nodes = nodes.concat(current.children);\n }\n },\n getBoundingBox: function getBoundingBox() {\n // BBox for just one tree node\n var bb = {\n left: Number.MAX_VALUE,\n top: Number.MAX_VALUE,\n width: 0,\n height: 0\n };\n this.eachNode(function (node) {\n bb.left = Math.min(bb.left, node.x);\n bb.top = Math.min(bb.top, node.y);\n bb.width = Math.max(bb.width, node.x + node.width);\n bb.height = Math.max(bb.height, node.y + node.height);\n });\n return bb;\n },\n // translate\n translate: function translate(tx, ty) {\n if (tx === void 0) {\n tx = 0;\n }\n if (ty === void 0) {\n ty = 0;\n }\n this.eachNode(function (node) {\n node.x += tx;\n node.y += ty;\n node.x += node.preH;\n node.y += node.preV;\n });\n },\n right2left: function right2left() {\n var me = this;\n var bb = me.getBoundingBox();\n me.eachNode(function (node) {\n node.x = node.x - (node.x - bb.left) * 2 - node.width;\n // node.x = - node.x;\n });\n me.translate(bb.width, 0);\n },\n bottom2top: function bottom2top() {\n var me = this;\n var bb = me.getBoundingBox();\n me.eachNode(function (node) {\n node.y = node.y - (node.y - bb.top) * 2 - node.height;\n // node.y = - node.y;\n });\n me.translate(0, bb.height);\n }\n});\nfunction hierarchy(data, options, isolated) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n var root = new Node(data, options);\n var nodes = [root];\n var node;\n if (!isolated && !data.collapsed) {\n while (node = nodes.shift()) {\n if (!node.data.collapsed) {\n var children = options.getChildren(node.data);\n var length = children ? children.length : 0;\n node.children = new Array(length);\n if (children && length) {\n for (var i = 0; i < length; i++) {\n var child = new Node(children[i], options);\n node.children[i] = child;\n nodes.push(child);\n child.parent = node;\n child.depth = node.depth + 1;\n }\n }\n }\n }\n }\n return root;\n}\nmodule.exports = hierarchy;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/hierarchy.js\n// module id = 3\n// module chunks = 0","var hierarchy = require('./hierarchy');\nmodule.exports = function (root, options) {\n // separate into left and right trees\n var left = hierarchy(root.data, options, true); // root only\n var right = hierarchy(root.data, options, true); // root only\n // automatically\n var treeSize = root.children.length;\n var rightTreeSize = Math.round(treeSize / 2);\n // separate left and right tree by meta data\n var getSide = options.getSide || function (child, index) {\n if (index < rightTreeSize) {\n return 'right';\n }\n return 'left';\n };\n for (var i = 0; i < treeSize; i++) {\n var child = root.children[i];\n var side = getSide(child, i);\n if (side === 'right') {\n right.children.push(child);\n } else {\n left.children.push(child);\n }\n }\n left.eachNode(function (node) {\n if (!node.isRoot()) {\n node.side = 'left';\n }\n });\n right.eachNode(function (node) {\n if (!node.isRoot()) {\n node.side = 'right';\n }\n });\n return {\n left: left,\n right: right\n };\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/separate-root.js\n// module id = 4\n// module chunks = 0","var hierarchy = {\n compactBox: require('./compact-box'),\n dendrogram: require('./dendrogram'),\n indented: require('./indented'),\n mindmap: require('./mindmap')\n};\nmodule.exports = hierarchy;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/index.js\n// module id = 5\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar nonLayeredTidyTree = require('./layout/non-layered-tidy');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar CompactBoxTreeLayout = /*#__PURE__*/function (_TreeLayout) {\n function CompactBoxTreeLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(CompactBoxTreeLayout, _TreeLayout);\n var _proto = CompactBoxTreeLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n return doTreeLayout(me.rootNode, me.options, nonLayeredTidyTree);\n };\n return CompactBoxTreeLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction compactBoxLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new CompactBoxTreeLayout(root, options).execute();\n}\nmodule.exports = compactBoxLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/compact-box.js\n// module id = 6\n// module chunks = 0","// wrap tree node\nfunction WrappedTree(w, h, y, c) {\n if (c === void 0) {\n c = [];\n }\n var me = this;\n // size\n me.w = w || 0;\n me.h = h || 0;\n\n // position\n me.y = y || 0;\n me.x = 0;\n\n // children\n me.c = c || [];\n me.cs = c.length;\n\n // modified\n me.prelim = 0;\n me.mod = 0;\n me.shift = 0;\n me.change = 0;\n\n // left/right tree\n me.tl = null;\n me.tr = null;\n\n // extreme left/right tree\n me.el = null;\n me.er = null;\n\n // modified left/right tree\n me.msel = 0;\n me.mser = 0;\n}\nWrappedTree.fromNode = function (root, isHorizontal) {\n if (!root) return null;\n var children = [];\n root.children.forEach(function (child) {\n children.push(WrappedTree.fromNode(child, isHorizontal));\n });\n if (isHorizontal) return new WrappedTree(root.height, root.width, root.x, children);\n return new WrappedTree(root.width, root.height, root.y, children);\n};\n\n// node utils\nfunction moveRight(node, move, isHorizontal) {\n if (isHorizontal) {\n node.y += move;\n } else {\n node.x += move;\n }\n node.children.forEach(function (child) {\n moveRight(child, move, isHorizontal);\n });\n}\nfunction getMin(node, isHorizontal) {\n var res = isHorizontal ? node.y : node.x;\n node.children.forEach(function (child) {\n res = Math.min(getMin(child, isHorizontal), res);\n });\n return res;\n}\nfunction normalize(node, isHorizontal) {\n var min = getMin(node, isHorizontal);\n moveRight(node, -min, isHorizontal);\n}\nfunction convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {\n if (isHorizontal) {\n root.y = converted.x;\n } else {\n root.x = converted.x;\n }\n converted.c.forEach(function (child, i) {\n convertBack(child, root.children[i], isHorizontal);\n });\n}\nfunction layer(node, isHorizontal, d) {\n if (d === void 0) {\n d = 0;\n }\n if (isHorizontal) {\n node.x = d;\n d += node.width;\n } else {\n node.y = d;\n d += node.height;\n }\n node.children.forEach(function (child) {\n layer(child, isHorizontal, d);\n });\n}\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n var isHorizontal = options.isHorizontal;\n function firstWalk(t) {\n if (t.cs === 0) {\n setExtremes(t);\n return;\n }\n firstWalk(t.c[0]);\n var ih = updateIYL(bottom(t.c[0].el), 0, null);\n for (var i = 1; i < t.cs; ++i) {\n firstWalk(t.c[i]);\n var min = bottom(t.c[i].er);\n separate(t, i, ih);\n ih = updateIYL(min, i, ih);\n }\n positionRoot(t);\n setExtremes(t);\n }\n function setExtremes(t) {\n if (t.cs === 0) {\n t.el = t;\n t.er = t;\n t.msel = t.mser = 0;\n } else {\n t.el = t.c[0].el;\n t.msel = t.c[0].msel;\n t.er = t.c[t.cs - 1].er;\n t.mser = t.c[t.cs - 1].mser;\n }\n }\n function separate(t, i, ih) {\n var sr = t.c[i - 1];\n var mssr = sr.mod;\n var cl = t.c[i];\n var mscl = cl.mod;\n while (sr !== null && cl !== null) {\n if (bottom(sr) > ih.low) ih = ih.nxt;\n var dist = mssr + sr.prelim + sr.w - (mscl + cl.prelim);\n if (dist > 0) {\n mscl += dist;\n moveSubtree(t, i, ih.index, dist);\n }\n var sy = bottom(sr);\n var cy = bottom(cl);\n if (sy <= cy) {\n sr = nextRightContour(sr);\n if (sr !== null) mssr += sr.mod;\n }\n if (sy >= cy) {\n cl = nextLeftContour(cl);\n if (cl !== null) mscl += cl.mod;\n }\n }\n if (!sr && !!cl) {\n setLeftThread(t, i, cl, mscl);\n } else if (!!sr && !cl) {\n setRightThread(t, i, sr, mssr);\n }\n }\n function moveSubtree(t, i, si, dist) {\n t.c[i].mod += dist;\n t.c[i].msel += dist;\n t.c[i].mser += dist;\n distributeExtra(t, i, si, dist);\n }\n function nextLeftContour(t) {\n return t.cs === 0 ? t.tl : t.c[0];\n }\n function nextRightContour(t) {\n return t.cs === 0 ? t.tr : t.c[t.cs - 1];\n }\n function bottom(t) {\n return t.y + t.h;\n }\n function setLeftThread(t, i, cl, modsumcl) {\n var li = t.c[0].el;\n li.tl = cl;\n var diff = modsumcl - cl.mod - t.c[0].msel;\n li.mod += diff;\n li.prelim -= diff;\n t.c[0].el = t.c[i].el;\n t.c[0].msel = t.c[i].msel;\n }\n function setRightThread(t, i, sr, modsumsr) {\n var ri = t.c[i].er;\n ri.tr = sr;\n var diff = modsumsr - sr.mod - t.c[i].mser;\n ri.mod += diff;\n ri.prelim -= diff;\n t.c[i].er = t.c[i - 1].er;\n t.c[i].mser = t.c[i - 1].mser;\n }\n function positionRoot(t) {\n 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;\n }\n function secondWalk(t, modsum) {\n modsum += t.mod;\n t.x = t.prelim + modsum;\n addChildSpacing(t);\n for (var i = 0; i < t.cs; i++) {\n secondWalk(t.c[i], modsum);\n }\n }\n function distributeExtra(t, i, si, dist) {\n if (si !== i - 1) {\n var nr = i - si;\n t.c[si + 1].shift += dist / nr;\n t.c[i].shift -= dist / nr;\n t.c[i].change -= dist - dist / nr;\n }\n }\n function addChildSpacing(t) {\n var d = 0;\n var modsumdelta = 0;\n for (var i = 0; i < t.cs; i++) {\n d += t.c[i].shift;\n modsumdelta += d + t.c[i].change;\n t.c[i].mod += modsumdelta;\n }\n }\n function updateIYL(low, index, ih) {\n while (ih !== null && low >= ih.low) {\n ih = ih.nxt;\n }\n return {\n low: low,\n index: index,\n nxt: ih\n };\n }\n\n // do layout\n layer(root, isHorizontal);\n var wt = WrappedTree.fromNode(root, isHorizontal);\n firstWalk(wt);\n secondWalk(wt, 0);\n convertBack(wt, root, isHorizontal);\n normalize(root, isHorizontal);\n return root;\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/non-layered-tidy.js\n// module id = 7\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar dendrogram = require('./layout/dendrogram');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar DendrogramLayout = /*#__PURE__*/function (_TreeLayout) {\n function DendrogramLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(DendrogramLayout, _TreeLayout);\n var _proto = DendrogramLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n me.rootNode.width = 0;\n return doTreeLayout(me.rootNode, me.options, dendrogram);\n };\n return DendrogramLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction dendrogramLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new DendrogramLayout(root, options).execute();\n}\nmodule.exports = dendrogramLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/dendrogram.js\n// module id = 8\n// module chunks = 0","// wrap tree node\n// TODO considering size\nvar util = require('../util');\nfunction WrappedTree(height, children) {\n if (height === void 0) {\n height = 0;\n }\n if (children === void 0) {\n children = [];\n }\n var me = this;\n me.x = me.y = 0;\n me.leftChild = me.rightChild = null;\n me.height = 0;\n me.children = children;\n}\nvar DEFAULT_OPTIONS = {\n isHorizontal: true,\n nodeSep: 20,\n nodeSize: 20,\n rankSep: 200,\n subTreeSep: 10\n};\nfunction convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {\n if (isHorizontal) {\n root.x = converted.x;\n root.y = converted.y;\n } else {\n root.x = converted.y;\n root.y = converted.x;\n }\n converted.children.forEach(function (child, i) {\n convertBack(child, root.children[i], isHorizontal);\n });\n}\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n var maxDepth = 0;\n function wrappedTreeFromNode(n) {\n if (!n) return null;\n n.width = 0;\n if (n.depth && n.depth > maxDepth) {\n maxDepth = n.depth; // get the max depth\n }\n var children = n.children;\n var childrenCount = children.length;\n var t = new WrappedTree(n.height, []);\n children.forEach(function (child, i) {\n var childWT = wrappedTreeFromNode(child);\n t.children.push(childWT);\n if (i === 0) {\n // t.leftChild = childWT.leftChild ? childWT.leftChild : childWT\n t.leftChild = childWT;\n }\n if (i === childrenCount - 1) {\n // t.rightChild = childWT.rightChild ? childWT.rightChild : childWT\n t.rightChild = childWT;\n }\n });\n t.originNode = n;\n t.isLeaf = n.isLeaf();\n return t;\n }\n function getDrawingDepth(t) {\n if (t.isLeaf || t.children.length === 0) {\n t.drawingDepth = maxDepth;\n } else {\n var depths = t.children.map(function (child) {\n return getDrawingDepth(child);\n });\n var minChildDepth = Math.min.apply(null, depths);\n t.drawingDepth = minChildDepth - 1;\n }\n return t.drawingDepth;\n }\n var prevLeaf;\n function position(t) {\n t.x = t.drawingDepth * options.rankSep;\n if (t.isLeaf) {\n t.y = 0;\n if (prevLeaf) {\n t.y = prevLeaf.y + prevLeaf.height + options.nodeSep;\n if (t.originNode.parent !== prevLeaf.originNode.parent) {\n t.y += options.subTreeSep;\n }\n }\n prevLeaf = t;\n } else {\n t.children.forEach(function (child) {\n position(child);\n });\n t.y = (t.leftChild.y + t.rightChild.y) / 2;\n }\n }\n\n // wrap node\n var wt = wrappedTreeFromNode(root);\n // get depth for drawing\n getDrawingDepth(wt);\n // get position\n position(wt);\n // get x, y\n convertBack(wt, root, options.isHorizontal);\n return root;\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/dendrogram.js\n// module id = 9\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar indentedTree = require('./layout/indented');\nvar separateTree = require('./layout/separate-root');\nvar util = require('./util');\nvar VALID_DIRECTIONS = ['LR',\n// left to right\n'RL',\n// right to left\n'H' // horizontal\n];\nvar DEFAULT_DIRECTION = VALID_DIRECTIONS[0];\nvar IndentedLayout = /*#__PURE__*/function (_TreeLayout) {\n function IndentedLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(IndentedLayout, _TreeLayout);\n var _proto = IndentedLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n var options = me.options;\n var root = me.rootNode;\n options.isHorizontal = true;\n // default indent 20 and sink first children;\n var _options$indent = options.indent,\n indent = _options$indent === void 0 ? 20 : _options$indent,\n _options$dropCap = options.dropCap,\n dropCap = _options$dropCap === void 0 ? true : _options$dropCap,\n _options$direction = options.direction,\n direction = _options$direction === void 0 ? DEFAULT_DIRECTION : _options$direction,\n align = options.align;\n if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {\n throw new TypeError(\"Invalid direction: \" + direction);\n }\n if (direction === VALID_DIRECTIONS[0]) {\n // LR\n indentedTree(root, indent, dropCap, align);\n } else if (direction === VALID_DIRECTIONS[1]) {\n // RL\n indentedTree(root, indent, dropCap, align);\n root.right2left();\n } else if (direction === VALID_DIRECTIONS[2]) {\n // H\n // separate into left and right trees\n var _separateTree = separateTree(root, options),\n left = _separateTree.left,\n right = _separateTree.right;\n indentedTree(left, indent, dropCap, align);\n left.right2left();\n indentedTree(right, indent, dropCap, align);\n var bbox = left.getBoundingBox();\n right.translate(bbox.width, 0);\n root.x = right.x - root.width / 2;\n }\n return root;\n };\n return IndentedLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction indentedLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new IndentedLayout(root, options).execute();\n}\nmodule.exports = indentedLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/indented.js\n// module id = 10\n// module chunks = 0","var util = require(\"../util\");\nfunction positionNode(node, previousNode, indent, dropCap, align) {\n // caculate the node's horizontal offset DX, dx's type might be number or function\n var displacementX = typeof indent === \"function\" ? indent(node) : indent * node.depth;\n if (!dropCap) {\n try {\n if (node.id === node.parent.children[0].id) {\n node.x += displacementX;\n node.y = previousNode ? previousNode.y : 0;\n return;\n }\n } catch (e) {\n // skip to normal when a node has no parent\n }\n }\n node.x += displacementX;\n if (previousNode) {\n node.y = previousNode.y + util.getHeight(previousNode, node, align);\n if (previousNode.parent && node.parent.id !== previousNode.parent.id) {\n // previous node has different parent\n var prevParent = previousNode.parent;\n var preY = prevParent.y + util.getHeight(prevParent, node, align);\n node.y = preY > node.y ? preY : node.y;\n }\n } else {\n node.y = 0;\n }\n return;\n}\nmodule.exports = function (root, indent, dropCap, align) {\n var previousNode = null;\n root.eachNode(function (node) {\n positionNode(node, previousNode, indent, dropCap, align);\n previousNode = node;\n });\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/indented.js\n// module id = 11\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar mindmap = require('./layout/mindmap');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar MindmapLayout = /*#__PURE__*/function (_TreeLayout) {\n function MindmapLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(MindmapLayout, _TreeLayout);\n var _proto = MindmapLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n return doTreeLayout(me.rootNode, me.options, mindmap);\n };\n return MindmapLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction mindmapLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new MindmapLayout(root, options).execute();\n}\nmodule.exports = mindmapLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/mindmap.js\n// module id = 12\n// module chunks = 0","var util = require('../util');\nfunction secondWalk(node, options) {\n var totalHeight = 0;\n if (!node.children.length) {\n totalHeight = node.height;\n } else {\n node.children.forEach(function (c) {\n totalHeight += secondWalk(c, options);\n });\n }\n node._subTreeSep = options.getSubTreeSep(node.data);\n node.totalHeight = Math.max(node.height, totalHeight) + 2 * node._subTreeSep;\n return node.totalHeight;\n}\nfunction thirdWalk(node) {\n var children = node.children;\n var len = children.length;\n if (len) {\n children.forEach(function (c) {\n thirdWalk(c);\n });\n var first = children[0];\n var last = children[len - 1];\n var childrenHeight = last.y - first.y + last.height;\n var childrenTotalHeight = 0;\n children.forEach(function (child) {\n childrenTotalHeight += child.totalHeight;\n });\n if (childrenHeight > node.height) {\n // 当子节点总高度大于父节点高度\n node.y = first.y + childrenHeight / 2 - node.height / 2;\n } else if (children.length !== 1 || node.height > childrenTotalHeight) {\n // 多于一个子节点或者父节点大于所有子节点的总高度\n var offset = node.y + (node.height - childrenHeight) / 2 - first.y;\n children.forEach(function (c) {\n c.translate(0, offset);\n });\n } else {\n // 只有一个子节点\n node.y = (first.y + first.height / 2 + last.y + last.height / 2) / 2 - node.height / 2;\n }\n }\n}\nvar DEFAULT_OPTIONS = {\n getSubTreeSep: function getSubTreeSep() {\n return 0;\n }\n};\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n root.parent = {\n x: 0,\n width: 0,\n height: 0,\n y: 0\n };\n // first walk\n root.BFTraverse(function (node) {\n node.x = node.parent.x + node.parent.width; // simply get x\n });\n root.parent = null;\n // second walk\n secondWalk(root, options); // assign sub tree totalHeight\n // adjusting\n // separating nodes\n root.startY = 0;\n root.y = root.totalHeight / 2 - root.height / 2;\n root.eachNode(function (node) {\n var children = node.children;\n var len = children.length;\n if (len) {\n var first = children[0];\n first.startY = node.startY + node._subTreeSep;\n if (len === 1) {\n first.y = node.y + node.height / 2 - first.height / 2;\n } else {\n first.y = first.startY + first.totalHeight / 2 - first.height / 2;\n for (var i = 1; i < len; i++) {\n var c = children[i];\n c.startY = children[i - 1].startY + children[i - 1].totalHeight;\n c.y = c.startY + c.totalHeight / 2 - c.height / 2;\n }\n }\n }\n });\n\n // third walk\n thirdWalk(root);\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/mindmap.js\n// module id = 13\n// module chunks = 0"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3OA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"hierarchy.js","sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 1a412b34521e6551ed51","webpack:///./src/util.js","webpack:///./src/layout/base.js","webpack:///./src/layout/do-layout.js","webpack:///./src/layout/hierarchy.js","webpack:///./src/layout/separate-root.js","webpack:///./src/index.js","webpack:///./src/compact-box.js","webpack:///./src/layout/non-layered-tidy.js","webpack:///./src/dendrogram.js","webpack:///./src/layout/dendrogram.js","webpack:///./src/indented.js","webpack:///./src/layout/indented.js","webpack:///./src/mindmap.js","webpack:///./src/layout/mindmap.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Hierarchy\"] = factory();\n\telse\n\t\troot[\"Hierarchy\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1a412b34521e6551ed51","/**\n * Get average height or height for node's position calculation, according to align.\n * @param {*} preNode previous node\n * @param {*} node current node, whose position is going to be calculated\n * @param {'center' | undefined} align 'center' means nodes align at the center, other value means align at the left-top\n * @param {string} heightField field name for height value on preNode and node\n * @return {number} the height for calculation\n */\nfunction getHeight(preNode, node, align, heightField) {\n if (heightField === void 0) {\n heightField = 'height';\n }\n return align === 'center' ? (preNode[heightField] + node[heightField]) / 2 : preNode.height;\n}\nmodule.exports = {\n assign: Object.assign,\n getHeight: getHeight\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/util.js\n// module id = 0\n// module chunks = 0","var hierarchy = require('./hierarchy');\nvar Layout = /*#__PURE__*/function () {\n function Layout(root, options) {\n if (options === void 0) {\n options = {};\n }\n var me = this;\n me.options = options;\n me.rootNode = hierarchy(root, options);\n }\n var _proto = Layout.prototype;\n _proto.execute = function execute() {\n throw new Error('please override this method');\n };\n return Layout;\n}();\nmodule.exports = Layout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/base.js\n// module id = 1\n// module chunks = 0","var separateTree = require('./separate-root');\nvar VALID_DIRECTIONS = ['LR',\n// left to right\n'RL',\n// right to left\n'TB',\n// top to bottom\n'BT',\n// bottom to top\n'H',\n// horizontal\n'V' // vertical\n];\nvar HORIZONTAL_DIRECTIONS = ['LR', 'RL', 'H'];\nvar isHorizontal = function isHorizontal(direction) {\n return HORIZONTAL_DIRECTIONS.indexOf(direction) > -1;\n};\nvar DEFAULT_DIRECTION = VALID_DIRECTIONS[0];\nmodule.exports = function (root, options, layoutAlgrithm) {\n var direction = options.direction || DEFAULT_DIRECTION;\n options.isHorizontal = isHorizontal(direction);\n if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {\n throw new TypeError(\"Invalid direction: \" + direction);\n }\n if (direction === VALID_DIRECTIONS[0]) {\n // LR\n layoutAlgrithm(root, options);\n } else if (direction === VALID_DIRECTIONS[1]) {\n // RL\n layoutAlgrithm(root, options);\n root.right2left();\n } else if (direction === VALID_DIRECTIONS[2]) {\n // TB\n layoutAlgrithm(root, options);\n } else if (direction === VALID_DIRECTIONS[3]) {\n // BT\n layoutAlgrithm(root, options);\n root.bottom2top();\n } else if (direction === VALID_DIRECTIONS[4] || direction === VALID_DIRECTIONS[5]) {\n // H or V\n // separate into left and right trees\n var _separateTree = separateTree(root, options),\n left = _separateTree.left,\n right = _separateTree.right;\n // do layout for left and right trees\n layoutAlgrithm(left, options);\n layoutAlgrithm(right, options);\n options.isHorizontal ? left.right2left() : left.bottom2top();\n // combine left and right trees\n right.translate(left.x - right.x, left.y - right.y);\n // translate root\n root.x = left.x;\n root.y = right.y;\n var bb = root.getBoundingBox();\n if (options.isHorizontal) {\n if (bb.top < 0) {\n root.translate(0, -bb.top);\n }\n } else {\n if (bb.left < 0) {\n root.translate(-bb.left, 0);\n }\n }\n }\n // fixed root position, default value is true\n var fixedRoot = options.fixedRoot;\n if (fixedRoot === undefined) fixedRoot = true;\n if (fixedRoot) {\n root.translate(-(root.x + root.width / 2 + root.hgap), -(root.y + root.height / 2 + root.vgap));\n }\n reassignXYIfRadial(root, options);\n return root;\n};\nfunction reassignXYIfRadial(root, options) {\n if (options.radial) {\n var _ref = options.isHorizontal ? [\"x\", \"y\"] : [\"y\", \"x\"],\n rScale = _ref[0],\n radScale = _ref[1];\n var min = {\n x: Infinity,\n y: Infinity\n };\n var max = {\n x: -Infinity,\n y: -Infinity\n };\n var count = 0;\n root.DFTraverse(function (node) {\n count++;\n var x = node.x,\n y = node.y;\n min.x = Math.min(min.x, x);\n min.y = Math.min(min.y, y);\n max.x = Math.max(max.x, x);\n max.y = Math.max(max.y, y);\n });\n var radDiff = max[radScale] - min[radScale];\n if (radDiff === 0) return;\n var avgRad = Math.PI * 2 / count;\n root.DFTraverse(function (node) {\n var rad = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;\n var r = node[rScale] - root[rScale];\n node.x = Math.cos(rad) * r;\n node.y = Math.sin(rad) * r;\n });\n }\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/do-layout.js\n// module id = 2\n// module chunks = 0","/* eslint-disable no-cond-assign */\nvar util = require('../util');\nvar PEM = 18;\nvar DEFAULT_HEIGHT = PEM * 2;\nvar DEFAULT_GAP = PEM;\nvar DEFAULT_OPTIONS = {\n getId: function getId(d) {\n return d.id || d.name;\n },\n getPreH: function getPreH(d) {\n return d.preH || 0;\n },\n getPreV: function getPreV(d) {\n return d.preV || 0;\n },\n getHGap: function getHGap(d) {\n return d.hgap || DEFAULT_GAP;\n },\n getVGap: function getVGap(d) {\n return d.vgap || DEFAULT_GAP;\n },\n getChildren: function getChildren(d) {\n return d.children;\n },\n getHeight: function getHeight(d) {\n return d.height || DEFAULT_HEIGHT;\n },\n getWidth: function getWidth(d) {\n var label = d.label || ' ';\n return d.width || label.split('').length * PEM; // FIXME DO NOT get width like this\n }\n};\nfunction Node(data, options) {\n var me = this;\n me.vgap = me.hgap = 0;\n if (data instanceof Node) return data;\n me.data = data;\n /*\n * Gaps: filling space between nodes\n * (x, y) ----------------------\n * | vgap |\n * | -------------------- h\n * | h | | e\n * | g | | i\n * | a | | g\n * | p | | h\n * | --------------------- t\n * | |\n * -----------width------------\n */\n var hgap = options.getHGap(data);\n var vgap = options.getVGap(data);\n me.preH = options.getPreH(data);\n me.preV = options.getPreV(data);\n me.width = options.getWidth(data);\n me.height = options.getHeight(data);\n me.width += me.preH;\n me.height += me.preV;\n me.id = options.getId(data);\n me.x = me.y = 0;\n me.depth = 0;\n if (!me.children) {\n me.children = [];\n }\n me.addGap(hgap, vgap);\n return me;\n}\nutil.assign(Node.prototype, {\n isRoot: function isRoot() {\n return this.depth === 0;\n },\n isLeaf: function isLeaf() {\n return this.children.length === 0;\n },\n addGap: function addGap(hgap, vgap) {\n var me = this;\n me.hgap += hgap;\n me.vgap += vgap;\n me.width += 2 * hgap;\n me.height += 2 * vgap;\n },\n eachNode: function eachNode(callback) {\n // Depth First traverse\n var me = this;\n var nodes = [me];\n var current;\n while (current = nodes.shift()) {\n callback(current);\n nodes = current.children.concat(nodes);\n }\n },\n DFTraverse: function DFTraverse(callback) {\n // Depth First traverse\n this.eachNode(callback);\n },\n BFTraverse: function BFTraverse(callback) {\n // Breadth First traverse\n var me = this;\n var nodes = [me];\n var current;\n while (current = nodes.shift()) {\n callback(current);\n nodes = nodes.concat(current.children);\n }\n },\n getBoundingBox: function getBoundingBox() {\n // BBox for just one tree node\n var bb = {\n left: Number.MAX_VALUE,\n top: Number.MAX_VALUE,\n width: 0,\n height: 0\n };\n this.eachNode(function (node) {\n bb.left = Math.min(bb.left, node.x);\n bb.top = Math.min(bb.top, node.y);\n bb.width = Math.max(bb.width, node.x + node.width);\n bb.height = Math.max(bb.height, node.y + node.height);\n });\n return bb;\n },\n // translate\n translate: function translate(tx, ty) {\n if (tx === void 0) {\n tx = 0;\n }\n if (ty === void 0) {\n ty = 0;\n }\n this.eachNode(function (node) {\n node.x += tx;\n node.y += ty;\n node.x += node.preH;\n node.y += node.preV;\n });\n },\n right2left: function right2left() {\n var me = this;\n var bb = me.getBoundingBox();\n me.eachNode(function (node) {\n node.x = node.x - (node.x - bb.left) * 2 - node.width;\n // node.x = - node.x;\n });\n me.translate(bb.width, 0);\n },\n bottom2top: function bottom2top() {\n var me = this;\n var bb = me.getBoundingBox();\n me.eachNode(function (node) {\n node.y = node.y - (node.y - bb.top) * 2 - node.height;\n // node.y = - node.y;\n });\n me.translate(0, bb.height);\n }\n});\nfunction hierarchy(data, options, isolated) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n var root = new Node(data, options);\n var nodes = [root];\n var node;\n if (!isolated && !data.collapsed) {\n while (node = nodes.shift()) {\n if (!node.data.collapsed) {\n var children = options.getChildren(node.data);\n var length = children ? children.length : 0;\n node.children = new Array(length);\n if (children && length) {\n for (var i = 0; i < length; i++) {\n var child = new Node(children[i], options);\n node.children[i] = child;\n nodes.push(child);\n child.parent = node;\n child.depth = node.depth + 1;\n }\n }\n }\n }\n }\n return root;\n}\nmodule.exports = hierarchy;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/hierarchy.js\n// module id = 3\n// module chunks = 0","var hierarchy = require('./hierarchy');\nmodule.exports = function (root, options) {\n // separate into left and right trees\n var left = hierarchy(root.data, options, true); // root only\n var right = hierarchy(root.data, options, true); // root only\n // automatically\n var treeSize = root.children.length;\n var rightTreeSize = Math.round(treeSize / 2);\n // separate left and right tree by meta data\n var getSide = options.getSide || function (child, index) {\n if (index < rightTreeSize) {\n return 'right';\n }\n return 'left';\n };\n for (var i = 0; i < treeSize; i++) {\n var child = root.children[i];\n var side = getSide(child, i);\n if (side === 'right') {\n right.children.push(child);\n } else {\n left.children.push(child);\n }\n }\n left.eachNode(function (node) {\n if (!node.isRoot()) {\n node.side = 'left';\n }\n });\n right.eachNode(function (node) {\n if (!node.isRoot()) {\n node.side = 'right';\n }\n });\n return {\n left: left,\n right: right\n };\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/separate-root.js\n// module id = 4\n// module chunks = 0","var hierarchy = {\n compactBox: require('./compact-box'),\n dendrogram: require('./dendrogram'),\n indented: require('./indented'),\n mindmap: require('./mindmap')\n};\nmodule.exports = hierarchy;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/index.js\n// module id = 5\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar nonLayeredTidyTree = require('./layout/non-layered-tidy');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar CompactBoxTreeLayout = /*#__PURE__*/function (_TreeLayout) {\n function CompactBoxTreeLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(CompactBoxTreeLayout, _TreeLayout);\n var _proto = CompactBoxTreeLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n return doTreeLayout(me.rootNode, me.options, nonLayeredTidyTree);\n };\n return CompactBoxTreeLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction compactBoxLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new CompactBoxTreeLayout(root, options).execute();\n}\nmodule.exports = compactBoxLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/compact-box.js\n// module id = 6\n// module chunks = 0","// wrap tree node\nfunction WrappedTree(w, h, y, c) {\n if (c === void 0) {\n c = [];\n }\n var me = this;\n // size\n me.w = w || 0;\n me.h = h || 0;\n\n // position\n me.y = y || 0;\n me.x = 0;\n\n // children\n me.c = c || [];\n me.cs = c.length;\n\n // modified\n me.prelim = 0;\n me.mod = 0;\n me.shift = 0;\n me.change = 0;\n\n // left/right tree\n me.tl = null;\n me.tr = null;\n\n // extreme left/right tree\n me.el = null;\n me.er = null;\n\n // modified left/right tree\n me.msel = 0;\n me.mser = 0;\n}\nWrappedTree.fromNode = function (root, isHorizontal) {\n if (!root) return null;\n var children = [];\n root.children.forEach(function (child) {\n children.push(WrappedTree.fromNode(child, isHorizontal));\n });\n if (isHorizontal) return new WrappedTree(root.height, root.width, root.x, children);\n return new WrappedTree(root.width, root.height, root.y, children);\n};\n\n// node utils\nfunction moveRight(node, move, isHorizontal) {\n if (isHorizontal) {\n node.y += move;\n } else {\n node.x += move;\n }\n node.children.forEach(function (child) {\n moveRight(child, move, isHorizontal);\n });\n}\nfunction getMin(node, isHorizontal) {\n var res = isHorizontal ? node.y : node.x;\n node.children.forEach(function (child) {\n res = Math.min(getMin(child, isHorizontal), res);\n });\n return res;\n}\nfunction normalize(node, isHorizontal) {\n var min = getMin(node, isHorizontal);\n moveRight(node, -min, isHorizontal);\n}\nfunction convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {\n if (isHorizontal) {\n root.y = converted.x;\n } else {\n root.x = converted.x;\n }\n converted.c.forEach(function (child, i) {\n convertBack(child, root.children[i], isHorizontal);\n });\n}\nfunction layer(node, isHorizontal, d) {\n if (d === void 0) {\n d = 0;\n }\n if (isHorizontal) {\n node.x = d;\n d += node.width;\n } else {\n node.y = d;\n d += node.height;\n }\n node.children.forEach(function (child) {\n layer(child, isHorizontal, d);\n });\n}\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n var isHorizontal = options.isHorizontal;\n function firstWalk(t) {\n if (t.cs === 0) {\n setExtremes(t);\n return;\n }\n firstWalk(t.c[0]);\n var ih = updateIYL(bottom(t.c[0].el), 0, null);\n for (var i = 1; i < t.cs; ++i) {\n firstWalk(t.c[i]);\n var min = bottom(t.c[i].er);\n separate(t, i, ih);\n ih = updateIYL(min, i, ih);\n }\n positionRoot(t);\n setExtremes(t);\n }\n function setExtremes(t) {\n if (t.cs === 0) {\n t.el = t;\n t.er = t;\n t.msel = t.mser = 0;\n } else {\n t.el = t.c[0].el;\n t.msel = t.c[0].msel;\n t.er = t.c[t.cs - 1].er;\n t.mser = t.c[t.cs - 1].mser;\n }\n }\n function separate(t, i, ih) {\n var sr = t.c[i - 1];\n var mssr = sr.mod;\n var cl = t.c[i];\n var mscl = cl.mod;\n while (sr !== null && cl !== null) {\n if (bottom(sr) > ih.low) ih = ih.nxt;\n var dist = mssr + sr.prelim + sr.w - (mscl + cl.prelim);\n if (dist > 0) {\n mscl += dist;\n moveSubtree(t, i, ih.index, dist);\n }\n var sy = bottom(sr);\n var cy = bottom(cl);\n if (sy <= cy) {\n sr = nextRightContour(sr);\n if (sr !== null) mssr += sr.mod;\n }\n if (sy >= cy) {\n cl = nextLeftContour(cl);\n if (cl !== null) mscl += cl.mod;\n }\n }\n if (!sr && !!cl) {\n setLeftThread(t, i, cl, mscl);\n } else if (!!sr && !cl) {\n setRightThread(t, i, sr, mssr);\n }\n }\n function moveSubtree(t, i, si, dist) {\n t.c[i].mod += dist;\n t.c[i].msel += dist;\n t.c[i].mser += dist;\n distributeExtra(t, i, si, dist);\n }\n function nextLeftContour(t) {\n return t.cs === 0 ? t.tl : t.c[0];\n }\n function nextRightContour(t) {\n return t.cs === 0 ? t.tr : t.c[t.cs - 1];\n }\n function bottom(t) {\n return t.y + t.h;\n }\n function setLeftThread(t, i, cl, modsumcl) {\n var li = t.c[0].el;\n li.tl = cl;\n var diff = modsumcl - cl.mod - t.c[0].msel;\n li.mod += diff;\n li.prelim -= diff;\n t.c[0].el = t.c[i].el;\n t.c[0].msel = t.c[i].msel;\n }\n function setRightThread(t, i, sr, modsumsr) {\n var ri = t.c[i].er;\n ri.tr = sr;\n var diff = modsumsr - sr.mod - t.c[i].mser;\n ri.mod += diff;\n ri.prelim -= diff;\n t.c[i].er = t.c[i - 1].er;\n t.c[i].mser = t.c[i - 1].mser;\n }\n function positionRoot(t) {\n 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;\n }\n function secondWalk(t, modsum) {\n modsum += t.mod;\n t.x = t.prelim + modsum;\n addChildSpacing(t);\n for (var i = 0; i < t.cs; i++) {\n secondWalk(t.c[i], modsum);\n }\n }\n function distributeExtra(t, i, si, dist) {\n if (si !== i - 1) {\n var nr = i - si;\n t.c[si + 1].shift += dist / nr;\n t.c[i].shift -= dist / nr;\n t.c[i].change -= dist - dist / nr;\n }\n }\n function addChildSpacing(t) {\n var d = 0;\n var modsumdelta = 0;\n for (var i = 0; i < t.cs; i++) {\n d += t.c[i].shift;\n modsumdelta += d + t.c[i].change;\n t.c[i].mod += modsumdelta;\n }\n }\n function updateIYL(low, index, ih) {\n while (ih !== null && low >= ih.low) {\n ih = ih.nxt;\n }\n return {\n low: low,\n index: index,\n nxt: ih\n };\n }\n\n // do layout\n layer(root, isHorizontal);\n var wt = WrappedTree.fromNode(root, isHorizontal);\n firstWalk(wt);\n secondWalk(wt, 0);\n convertBack(wt, root, isHorizontal);\n normalize(root, isHorizontal);\n return root;\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/non-layered-tidy.js\n// module id = 7\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar dendrogram = require('./layout/dendrogram');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar DendrogramLayout = /*#__PURE__*/function (_TreeLayout) {\n function DendrogramLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(DendrogramLayout, _TreeLayout);\n var _proto = DendrogramLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n me.rootNode.width = 0;\n return doTreeLayout(me.rootNode, me.options, dendrogram);\n };\n return DendrogramLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction dendrogramLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new DendrogramLayout(root, options).execute();\n}\nmodule.exports = dendrogramLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/dendrogram.js\n// module id = 8\n// module chunks = 0","// wrap tree node\n// TODO considering size\nvar util = require('../util');\nfunction WrappedTree(height, children) {\n if (height === void 0) {\n height = 0;\n }\n if (children === void 0) {\n children = [];\n }\n var me = this;\n me.x = me.y = 0;\n me.leftChild = me.rightChild = null;\n me.height = 0;\n me.children = children;\n}\nvar DEFAULT_OPTIONS = {\n isHorizontal: true,\n nodeSep: 20,\n nodeSize: 20,\n rankSep: 200,\n subTreeSep: 10\n};\nfunction convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {\n if (isHorizontal) {\n root.x = converted.x;\n root.y = converted.y;\n } else {\n root.x = converted.y;\n root.y = converted.x;\n }\n converted.children.forEach(function (child, i) {\n convertBack(child, root.children[i], isHorizontal);\n });\n}\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n var maxDepth = 0;\n function wrappedTreeFromNode(n) {\n if (!n) return null;\n n.width = 0;\n if (n.depth && n.depth > maxDepth) {\n maxDepth = n.depth; // get the max depth\n }\n var children = n.children;\n var childrenCount = children.length;\n var t = new WrappedTree(n.height, []);\n children.forEach(function (child, i) {\n var childWT = wrappedTreeFromNode(child);\n t.children.push(childWT);\n if (i === 0) {\n // t.leftChild = childWT.leftChild ? childWT.leftChild : childWT\n t.leftChild = childWT;\n }\n if (i === childrenCount - 1) {\n // t.rightChild = childWT.rightChild ? childWT.rightChild : childWT\n t.rightChild = childWT;\n }\n });\n t.originNode = n;\n t.isLeaf = n.isLeaf();\n return t;\n }\n function getDrawingDepth(t) {\n if (t.isLeaf || t.children.length === 0) {\n t.drawingDepth = maxDepth;\n } else {\n var depths = t.children.map(function (child) {\n return getDrawingDepth(child);\n });\n var minChildDepth = Math.min.apply(null, depths);\n t.drawingDepth = minChildDepth - 1;\n }\n return t.drawingDepth;\n }\n var prevLeaf;\n function position(t) {\n t.x = t.drawingDepth * options.rankSep;\n if (t.isLeaf) {\n t.y = 0;\n if (prevLeaf) {\n t.y = prevLeaf.y + prevLeaf.height + options.nodeSep;\n if (t.originNode.parent !== prevLeaf.originNode.parent) {\n t.y += options.subTreeSep;\n }\n }\n prevLeaf = t;\n } else {\n t.children.forEach(function (child) {\n position(child);\n });\n t.y = (t.leftChild.y + t.rightChild.y) / 2;\n }\n }\n\n // wrap node\n var wt = wrappedTreeFromNode(root);\n // get depth for drawing\n getDrawingDepth(wt);\n // get position\n position(wt);\n // get x, y\n convertBack(wt, root, options.isHorizontal);\n return root;\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/dendrogram.js\n// module id = 9\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar indentedTree = require('./layout/indented');\nvar separateTree = require('./layout/separate-root');\nvar util = require('./util');\nvar VALID_DIRECTIONS = ['LR',\n// left to right\n'RL',\n// right to left\n'H' // horizontal\n];\nvar DEFAULT_DIRECTION = VALID_DIRECTIONS[0];\nvar IndentedLayout = /*#__PURE__*/function (_TreeLayout) {\n function IndentedLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(IndentedLayout, _TreeLayout);\n var _proto = IndentedLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n var options = me.options;\n var root = me.rootNode;\n options.isHorizontal = true;\n // default indent 20 and sink first children;\n var _options$indent = options.indent,\n indent = _options$indent === void 0 ? 20 : _options$indent,\n _options$dropCap = options.dropCap,\n dropCap = _options$dropCap === void 0 ? true : _options$dropCap,\n _options$direction = options.direction,\n direction = _options$direction === void 0 ? DEFAULT_DIRECTION : _options$direction,\n align = options.align;\n if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {\n throw new TypeError(\"Invalid direction: \" + direction);\n }\n if (direction === VALID_DIRECTIONS[0]) {\n // LR\n indentedTree(root, indent, dropCap, align);\n } else if (direction === VALID_DIRECTIONS[1]) {\n // RL\n indentedTree(root, indent, dropCap, align);\n root.right2left();\n } else if (direction === VALID_DIRECTIONS[2]) {\n // H\n // separate into left and right trees\n var _separateTree = separateTree(root, options),\n left = _separateTree.left,\n right = _separateTree.right;\n indentedTree(left, indent, dropCap, align);\n left.right2left();\n indentedTree(right, indent, dropCap, align);\n var bbox = left.getBoundingBox();\n right.translate(bbox.width, 0);\n root.x = right.x - root.width / 2;\n }\n return root;\n };\n return IndentedLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction indentedLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new IndentedLayout(root, options).execute();\n}\nmodule.exports = indentedLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/indented.js\n// module id = 10\n// module chunks = 0","var util = require(\"../util\");\nfunction positionNode(node, previousNode, indent, dropCap, align) {\n // caculate the node's horizontal offset DX, dx's type might be number or function\n var displacementX = (typeof indent === \"function\" ? indent(node) : indent) * node.depth;\n if (!dropCap) {\n try {\n if (node.id === node.parent.children[0].id) {\n node.x += displacementX;\n node.y = previousNode ? previousNode.y : 0;\n return;\n }\n } catch (e) {\n // skip to normal when a node has no parent\n }\n }\n node.x += displacementX;\n if (previousNode) {\n node.y = previousNode.y + util.getHeight(previousNode, node, align);\n if (previousNode.parent && node.parent.id !== previousNode.parent.id) {\n // previous node has different parent\n var prevParent = previousNode.parent;\n var preY = prevParent.y + util.getHeight(prevParent, node, align);\n node.y = preY > node.y ? preY : node.y;\n }\n } else {\n node.y = 0;\n }\n return;\n}\nmodule.exports = function (root, indent, dropCap, align) {\n var previousNode = null;\n root.eachNode(function (node) {\n positionNode(node, previousNode, indent, dropCap, align);\n previousNode = node;\n });\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/indented.js\n// module id = 11\n// module chunks = 0","function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar TreeLayout = require('./layout/base');\nvar mindmap = require('./layout/mindmap');\nvar doTreeLayout = require('./layout/do-layout');\nvar util = require('./util');\nvar MindmapLayout = /*#__PURE__*/function (_TreeLayout) {\n function MindmapLayout() {\n return _TreeLayout.apply(this, arguments) || this;\n }\n _inheritsLoose(MindmapLayout, _TreeLayout);\n var _proto = MindmapLayout.prototype;\n _proto.execute = function execute() {\n var me = this;\n return doTreeLayout(me.rootNode, me.options, mindmap);\n };\n return MindmapLayout;\n}(TreeLayout);\nvar DEFAULT_OPTIONS = {};\nfunction mindmapLayout(root, options) {\n options = util.assign({}, DEFAULT_OPTIONS, options);\n return new MindmapLayout(root, options).execute();\n}\nmodule.exports = mindmapLayout;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/mindmap.js\n// module id = 12\n// module chunks = 0","var util = require('../util');\nfunction secondWalk(node, options) {\n var totalHeight = 0;\n if (!node.children.length) {\n totalHeight = node.height;\n } else {\n node.children.forEach(function (c) {\n totalHeight += secondWalk(c, options);\n });\n }\n node._subTreeSep = options.getSubTreeSep(node.data);\n node.totalHeight = Math.max(node.height, totalHeight) + 2 * node._subTreeSep;\n return node.totalHeight;\n}\nfunction thirdWalk(node) {\n var children = node.children;\n var len = children.length;\n if (len) {\n children.forEach(function (c) {\n thirdWalk(c);\n });\n var first = children[0];\n var last = children[len - 1];\n var childrenHeight = last.y - first.y + last.height;\n var childrenTotalHeight = 0;\n children.forEach(function (child) {\n childrenTotalHeight += child.totalHeight;\n });\n if (childrenHeight > node.height) {\n // 当子节点总高度大于父节点高度\n node.y = first.y + childrenHeight / 2 - node.height / 2;\n } else if (children.length !== 1 || node.height > childrenTotalHeight) {\n // 多于一个子节点或者父节点大于所有子节点的总高度\n var offset = node.y + (node.height - childrenHeight) / 2 - first.y;\n children.forEach(function (c) {\n c.translate(0, offset);\n });\n } else {\n // 只有一个子节点\n node.y = (first.y + first.height / 2 + last.y + last.height / 2) / 2 - node.height / 2;\n }\n }\n}\nvar DEFAULT_OPTIONS = {\n getSubTreeSep: function getSubTreeSep() {\n return 0;\n }\n};\nmodule.exports = function (root, options) {\n if (options === void 0) {\n options = {};\n }\n options = util.assign({}, DEFAULT_OPTIONS, options);\n root.parent = {\n x: 0,\n width: 0,\n height: 0,\n y: 0\n };\n // first walk\n root.BFTraverse(function (node) {\n node.x = node.parent.x + node.parent.width; // simply get x\n });\n root.parent = null;\n // second walk\n secondWalk(root, options); // assign sub tree totalHeight\n // adjusting\n // separating nodes\n root.startY = 0;\n root.y = root.totalHeight / 2 - root.height / 2;\n root.eachNode(function (node) {\n var children = node.children;\n var len = children.length;\n if (len) {\n var first = children[0];\n first.startY = node.startY + node._subTreeSep;\n if (len === 1) {\n first.y = node.y + node.height / 2 - first.height / 2;\n } else {\n first.y = first.startY + first.totalHeight / 2 - first.height / 2;\n for (var i = 1; i < len; i++) {\n var c = children[i];\n c.startY = children[i - 1].startY + children[i - 1].totalHeight;\n c.y = c.startY + c.totalHeight / 2 - c.height / 2;\n }\n }\n }\n });\n\n // third walk\n thirdWalk(root);\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/layout/mindmap.js\n// module id = 13\n// module chunks = 0"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3OA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AC3GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}
|
package/dist/hierarchy.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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
|
+
!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)}}])});
|
package/lib/layout/indented.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var util = require("../util");
|
|
2
2
|
function positionNode(node, previousNode, indent, dropCap, align) {
|
|
3
3
|
// caculate the node's horizontal offset DX, dx's type might be number or function
|
|
4
|
-
var displacementX = typeof indent === "function" ? indent(node) : indent * node.depth;
|
|
4
|
+
var displacementX = (typeof indent === "function" ? indent(node) : indent) * node.depth;
|
|
5
5
|
if (!dropCap) {
|
|
6
6
|
try {
|
|
7
7
|
if (node.id === node.parent.children[0].id) {
|
package/package.json
CHANGED
package/src/layout/indented.js
CHANGED
|
@@ -3,7 +3,7 @@ const util = require("../util");
|
|
|
3
3
|
function positionNode(node, previousNode, indent, dropCap, align) {
|
|
4
4
|
// caculate the node's horizontal offset DX, dx's type might be number or function
|
|
5
5
|
const displacementX =
|
|
6
|
-
typeof indent === "function" ? indent(node) : indent * node.depth;
|
|
6
|
+
(typeof indent === "function" ? indent(node) : indent) * node.depth;
|
|
7
7
|
|
|
8
8
|
if (!dropCap) {
|
|
9
9
|
try {
|