@antv/hierarchy 0.6.13 → 0.7.0
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/README.md +51 -3
- package/dist/hierarchy.es.js +2 -0
- package/dist/hierarchy.es.js.map +1 -0
- package/dist/hierarchy.umd.js +2 -0
- package/dist/hierarchy.umd.js.map +1 -0
- package/lib/compact-box.d.ts +3 -0
- package/lib/compact-box.d.ts.map +1 -0
- package/lib/dendrogram.d.ts +3 -0
- package/lib/dendrogram.d.ts.map +1 -0
- package/lib/indented.d.ts +3 -0
- package/lib/indented.d.ts.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/layout/base.d.ts +8 -0
- package/lib/layout/base.d.ts.map +1 -0
- package/lib/layout/dendrogram.d.ts +3 -0
- package/lib/layout/dendrogram.d.ts.map +1 -0
- package/lib/layout/do-layout.d.ts +5 -0
- package/lib/layout/do-layout.d.ts.map +1 -0
- package/lib/layout/hierarchy.d.ts +3 -0
- package/lib/layout/hierarchy.d.ts.map +1 -0
- package/lib/layout/indented.d.ts +3 -0
- package/lib/layout/indented.d.ts.map +1 -0
- package/lib/layout/mindmap.d.ts +3 -0
- package/lib/layout/mindmap.d.ts.map +1 -0
- package/lib/layout/non-layered-tidy.d.ts +3 -0
- package/lib/layout/non-layered-tidy.d.ts.map +1 -0
- package/lib/layout/separate-root.d.ts +6 -0
- package/lib/layout/separate-root.d.ts.map +1 -0
- package/lib/mindmap.d.ts +3 -0
- package/lib/mindmap.d.ts.map +1 -0
- package/lib/types.d.ts +90 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/util.d.ts +17 -0
- package/lib/util.d.ts.map +1 -0
- package/package.json +48 -53
- package/.babelrc +0 -14
- package/.editorconfig +0 -20
- package/.eslintignore +0 -7
- package/.eslintrc +0 -28
- package/.github/workflows/build.yml +0 -32
- package/CHANGELOG.md +0 -0
- package/CONTRIBUTING.md +0 -142
- package/CONTRIBUTING.zh-CN.md +0 -148
- package/assets/compact-box-bt.png +0 -0
- package/assets/compact-box-h.png +0 -0
- package/assets/compact-box-lr.png +0 -0
- package/assets/compact-box-rl.png +0 -0
- package/assets/compact-box-tb.png +0 -0
- package/assets/compact-box-v.png +0 -0
- package/assets/dendrogram-bt.png +0 -0
- package/assets/dendrogram-h.png +0 -0
- package/assets/dendrogram-lr.png +0 -0
- package/assets/dendrogram-rl.png +0 -0
- package/assets/dendrogram-tb.png +0 -0
- package/assets/dendrogram-v.png +0 -0
- package/assets/indented-h.png +0 -0
- package/assets/indented-lr.png +0 -0
- package/assets/indented-rl.png +0 -0
- package/assets/layered-tidy-bt.png +0 -0
- package/assets/layered-tidy-h.png +0 -0
- package/assets/layered-tidy-lr.png +0 -0
- package/assets/layered-tidy-rl.png +0 -0
- package/assets/layered-tidy-tb.png +0 -0
- package/assets/layered-tidy-v.png +0 -0
- package/assets/mindmap.png +0 -0
- package/bin/mkdir-dist.js +0 -8
- package/bin/screenshot.js +0 -81
- package/bin/win-dev.js +0 -14
- package/build/hierarchy.js +0 -1131
- package/build/hierarchy.js.map +0 -1
- package/dist/hierarchy.min.js +0 -1
- package/lib/compact-box.js +0 -24
- package/lib/dendrogram.js +0 -25
- package/lib/indented.js +0 -65
- package/lib/index.js +0 -7
- package/lib/layout/base.js +0 -17
- package/lib/layout/dendrogram.js +0 -108
- package/lib/layout/do-layout.js +0 -107
- package/lib/layout/hierarchy.js +0 -184
- package/lib/layout/indented.js +0 -36
- package/lib/layout/mindmap.js +0 -92
- package/lib/layout/non-layered-tidy.js +0 -236
- package/lib/layout/separate-root.js +0 -39
- package/lib/mindmap.js +0 -24
- package/lib/util.js +0 -18
- package/src/compact-box.js +0 -21
- package/src/dendrogram.js +0 -22
- package/src/indented.js +0 -52
- package/src/index.js +0 -9
- package/src/layout/base.js +0 -16
- package/src/layout/dendrogram.js +0 -105
- package/src/layout/do-layout.js +0 -106
- package/src/layout/hierarchy.js +0 -187
- package/src/layout/indented.js +0 -40
- package/src/layout/mindmap.js +0 -93
- package/src/layout/non-layered-tidy.js +0 -250
- package/src/layout/separate-root.js +0 -40
- package/src/mindmap.js +0 -21
- package/src/util.js +0 -16
package/build/hierarchy.js
DELETED
|
@@ -1,1131 +0,0 @@
|
|
|
1
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define([], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["Hierarchy"] = factory();
|
|
8
|
-
else
|
|
9
|
-
root["Hierarchy"] = factory();
|
|
10
|
-
})(typeof self !== 'undefined' ? self : this, function() {
|
|
11
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
-
/******/ // The module cache
|
|
13
|
-
/******/ var installedModules = {};
|
|
14
|
-
/******/
|
|
15
|
-
/******/ // The require function
|
|
16
|
-
/******/ function __webpack_require__(moduleId) {
|
|
17
|
-
/******/
|
|
18
|
-
/******/ // Check if module is in cache
|
|
19
|
-
/******/ if(installedModules[moduleId]) {
|
|
20
|
-
/******/ return installedModules[moduleId].exports;
|
|
21
|
-
/******/ }
|
|
22
|
-
/******/ // Create a new module (and put it into the cache)
|
|
23
|
-
/******/ var module = installedModules[moduleId] = {
|
|
24
|
-
/******/ i: moduleId,
|
|
25
|
-
/******/ l: false,
|
|
26
|
-
/******/ exports: {}
|
|
27
|
-
/******/ };
|
|
28
|
-
/******/
|
|
29
|
-
/******/ // Execute the module function
|
|
30
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
-
/******/
|
|
32
|
-
/******/ // Flag the module as loaded
|
|
33
|
-
/******/ module.l = true;
|
|
34
|
-
/******/
|
|
35
|
-
/******/ // Return the exports of the module
|
|
36
|
-
/******/ return module.exports;
|
|
37
|
-
/******/ }
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
-
/******/ __webpack_require__.m = modules;
|
|
42
|
-
/******/
|
|
43
|
-
/******/ // expose the module cache
|
|
44
|
-
/******/ __webpack_require__.c = installedModules;
|
|
45
|
-
/******/
|
|
46
|
-
/******/ // define getter function for harmony exports
|
|
47
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
48
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
49
|
-
/******/ Object.defineProperty(exports, name, {
|
|
50
|
-
/******/ configurable: false,
|
|
51
|
-
/******/ enumerable: true,
|
|
52
|
-
/******/ get: getter
|
|
53
|
-
/******/ });
|
|
54
|
-
/******/ }
|
|
55
|
-
/******/ };
|
|
56
|
-
/******/
|
|
57
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
58
|
-
/******/ __webpack_require__.n = function(module) {
|
|
59
|
-
/******/ var getter = module && module.__esModule ?
|
|
60
|
-
/******/ function getDefault() { return module['default']; } :
|
|
61
|
-
/******/ function getModuleExports() { return module; };
|
|
62
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
63
|
-
/******/ return getter;
|
|
64
|
-
/******/ };
|
|
65
|
-
/******/
|
|
66
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
67
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
68
|
-
/******/
|
|
69
|
-
/******/ // __webpack_public_path__
|
|
70
|
-
/******/ __webpack_require__.p = "";
|
|
71
|
-
/******/
|
|
72
|
-
/******/ // Load entry module and return exports
|
|
73
|
-
/******/ return __webpack_require__(__webpack_require__.s = 5);
|
|
74
|
-
/******/ })
|
|
75
|
-
/************************************************************************/
|
|
76
|
-
/******/ ([
|
|
77
|
-
/* 0 */
|
|
78
|
-
/***/ (function(module, exports) {
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get average height or height for node's position calculation, according to align.
|
|
82
|
-
* @param {*} preNode previous node
|
|
83
|
-
* @param {*} node current node, whose position is going to be calculated
|
|
84
|
-
* @param {'center' | undefined} align 'center' means nodes align at the center, other value means align at the left-top
|
|
85
|
-
* @param {string} heightField field name for height value on preNode and node
|
|
86
|
-
* @return {number} the height for calculation
|
|
87
|
-
*/
|
|
88
|
-
function getHeight(preNode, node, align, heightField) {
|
|
89
|
-
if (heightField === void 0) {
|
|
90
|
-
heightField = 'height';
|
|
91
|
-
}
|
|
92
|
-
return align === 'center' ? (preNode[heightField] + node[heightField]) / 2 : preNode.height;
|
|
93
|
-
}
|
|
94
|
-
module.exports = {
|
|
95
|
-
assign: Object.assign,
|
|
96
|
-
getHeight: getHeight
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/***/ }),
|
|
100
|
-
/* 1 */
|
|
101
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
102
|
-
|
|
103
|
-
var hierarchy = __webpack_require__(3);
|
|
104
|
-
var Layout = /*#__PURE__*/function () {
|
|
105
|
-
function Layout(root, options) {
|
|
106
|
-
if (options === void 0) {
|
|
107
|
-
options = {};
|
|
108
|
-
}
|
|
109
|
-
var me = this;
|
|
110
|
-
me.options = options;
|
|
111
|
-
me.rootNode = hierarchy(root, options);
|
|
112
|
-
}
|
|
113
|
-
var _proto = Layout.prototype;
|
|
114
|
-
_proto.execute = function execute() {
|
|
115
|
-
throw new Error('please override this method');
|
|
116
|
-
};
|
|
117
|
-
return Layout;
|
|
118
|
-
}();
|
|
119
|
-
module.exports = Layout;
|
|
120
|
-
|
|
121
|
-
/***/ }),
|
|
122
|
-
/* 2 */
|
|
123
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
124
|
-
|
|
125
|
-
var separateTree = __webpack_require__(4);
|
|
126
|
-
var VALID_DIRECTIONS = ['LR',
|
|
127
|
-
// left to right
|
|
128
|
-
'RL',
|
|
129
|
-
// right to left
|
|
130
|
-
'TB',
|
|
131
|
-
// top to bottom
|
|
132
|
-
'BT',
|
|
133
|
-
// bottom to top
|
|
134
|
-
'H',
|
|
135
|
-
// horizontal
|
|
136
|
-
'V' // vertical
|
|
137
|
-
];
|
|
138
|
-
var HORIZONTAL_DIRECTIONS = ['LR', 'RL', 'H'];
|
|
139
|
-
var isHorizontal = function isHorizontal(direction) {
|
|
140
|
-
return HORIZONTAL_DIRECTIONS.indexOf(direction) > -1;
|
|
141
|
-
};
|
|
142
|
-
var DEFAULT_DIRECTION = VALID_DIRECTIONS[0];
|
|
143
|
-
module.exports = function (root, options, layoutAlgrithm) {
|
|
144
|
-
var direction = options.direction || DEFAULT_DIRECTION;
|
|
145
|
-
options.isHorizontal = isHorizontal(direction);
|
|
146
|
-
if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {
|
|
147
|
-
throw new TypeError("Invalid direction: " + direction);
|
|
148
|
-
}
|
|
149
|
-
if (direction === VALID_DIRECTIONS[0]) {
|
|
150
|
-
// LR
|
|
151
|
-
layoutAlgrithm(root, options);
|
|
152
|
-
} else if (direction === VALID_DIRECTIONS[1]) {
|
|
153
|
-
// RL
|
|
154
|
-
layoutAlgrithm(root, options);
|
|
155
|
-
root.right2left();
|
|
156
|
-
} else if (direction === VALID_DIRECTIONS[2]) {
|
|
157
|
-
// TB
|
|
158
|
-
layoutAlgrithm(root, options);
|
|
159
|
-
} else if (direction === VALID_DIRECTIONS[3]) {
|
|
160
|
-
// BT
|
|
161
|
-
layoutAlgrithm(root, options);
|
|
162
|
-
root.bottom2top();
|
|
163
|
-
} else if (direction === VALID_DIRECTIONS[4] || direction === VALID_DIRECTIONS[5]) {
|
|
164
|
-
// H or V
|
|
165
|
-
// separate into left and right trees
|
|
166
|
-
var _separateTree = separateTree(root, options),
|
|
167
|
-
left = _separateTree.left,
|
|
168
|
-
right = _separateTree.right;
|
|
169
|
-
// do layout for left and right trees
|
|
170
|
-
layoutAlgrithm(left, options);
|
|
171
|
-
layoutAlgrithm(right, options);
|
|
172
|
-
options.isHorizontal ? left.right2left() : left.bottom2top();
|
|
173
|
-
// combine left and right trees
|
|
174
|
-
right.translate(left.x - right.x, left.y - right.y);
|
|
175
|
-
// translate root
|
|
176
|
-
root.x = left.x;
|
|
177
|
-
root.y = right.y;
|
|
178
|
-
var bb = root.getBoundingBox();
|
|
179
|
-
if (options.isHorizontal) {
|
|
180
|
-
if (bb.top < 0) {
|
|
181
|
-
root.translate(0, -bb.top);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
if (bb.left < 0) {
|
|
185
|
-
root.translate(-bb.left, 0);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// fixed root position, default value is true
|
|
190
|
-
var fixedRoot = options.fixedRoot;
|
|
191
|
-
if (fixedRoot === undefined) fixedRoot = true;
|
|
192
|
-
if (fixedRoot) {
|
|
193
|
-
root.translate(-(root.x + root.width / 2 + root.hgap), -(root.y + root.height / 2 + root.vgap));
|
|
194
|
-
}
|
|
195
|
-
reassignXYIfRadial(root, options);
|
|
196
|
-
return root;
|
|
197
|
-
};
|
|
198
|
-
function reassignXYIfRadial(root, options) {
|
|
199
|
-
if (options.radial) {
|
|
200
|
-
var _ref = options.isHorizontal ? ["x", "y"] : ["y", "x"],
|
|
201
|
-
rScale = _ref[0],
|
|
202
|
-
radScale = _ref[1];
|
|
203
|
-
var min = {
|
|
204
|
-
x: Infinity,
|
|
205
|
-
y: Infinity
|
|
206
|
-
};
|
|
207
|
-
var max = {
|
|
208
|
-
x: -Infinity,
|
|
209
|
-
y: -Infinity
|
|
210
|
-
};
|
|
211
|
-
var count = 0;
|
|
212
|
-
root.DFTraverse(function (node) {
|
|
213
|
-
count++;
|
|
214
|
-
var x = node.x,
|
|
215
|
-
y = node.y;
|
|
216
|
-
min.x = Math.min(min.x, x);
|
|
217
|
-
min.y = Math.min(min.y, y);
|
|
218
|
-
max.x = Math.max(max.x, x);
|
|
219
|
-
max.y = Math.max(max.y, y);
|
|
220
|
-
});
|
|
221
|
-
var radDiff = max[radScale] - min[radScale];
|
|
222
|
-
if (radDiff === 0) return;
|
|
223
|
-
var avgRad = Math.PI * 2 / count;
|
|
224
|
-
root.DFTraverse(function (node) {
|
|
225
|
-
var rad = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;
|
|
226
|
-
var r = node[rScale] - root[rScale];
|
|
227
|
-
node.x = Math.cos(rad) * r;
|
|
228
|
-
node.y = Math.sin(rad) * r;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/***/ }),
|
|
234
|
-
/* 3 */
|
|
235
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
236
|
-
|
|
237
|
-
/* eslint-disable no-cond-assign */
|
|
238
|
-
var util = __webpack_require__(0);
|
|
239
|
-
var PEM = 18;
|
|
240
|
-
var DEFAULT_HEIGHT = PEM * 2;
|
|
241
|
-
var DEFAULT_GAP = PEM;
|
|
242
|
-
var DEFAULT_OPTIONS = {
|
|
243
|
-
getId: function getId(d) {
|
|
244
|
-
return d.id || d.name;
|
|
245
|
-
},
|
|
246
|
-
getPreH: function getPreH(d) {
|
|
247
|
-
return d.preH || 0;
|
|
248
|
-
},
|
|
249
|
-
getPreV: function getPreV(d) {
|
|
250
|
-
return d.preV || 0;
|
|
251
|
-
},
|
|
252
|
-
getHGap: function getHGap(d) {
|
|
253
|
-
return d.hgap || DEFAULT_GAP;
|
|
254
|
-
},
|
|
255
|
-
getVGap: function getVGap(d) {
|
|
256
|
-
return d.vgap || DEFAULT_GAP;
|
|
257
|
-
},
|
|
258
|
-
getChildren: function getChildren(d) {
|
|
259
|
-
return d.children;
|
|
260
|
-
},
|
|
261
|
-
getHeight: function getHeight(d) {
|
|
262
|
-
return d.height || DEFAULT_HEIGHT;
|
|
263
|
-
},
|
|
264
|
-
getWidth: function getWidth(d) {
|
|
265
|
-
var label = d.label || ' ';
|
|
266
|
-
return d.width || label.split('').length * PEM; // FIXME DO NOT get width like this
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
function Node(data, options) {
|
|
270
|
-
var me = this;
|
|
271
|
-
me.vgap = me.hgap = 0;
|
|
272
|
-
if (data instanceof Node) return data;
|
|
273
|
-
me.data = data;
|
|
274
|
-
/*
|
|
275
|
-
* Gaps: filling space between nodes
|
|
276
|
-
* (x, y) ----------------------
|
|
277
|
-
* | vgap |
|
|
278
|
-
* | -------------------- h
|
|
279
|
-
* | h | | e
|
|
280
|
-
* | g | | i
|
|
281
|
-
* | a | | g
|
|
282
|
-
* | p | | h
|
|
283
|
-
* | --------------------- t
|
|
284
|
-
* | |
|
|
285
|
-
* -----------width------------
|
|
286
|
-
*/
|
|
287
|
-
var hgap = options.getHGap(data);
|
|
288
|
-
var vgap = options.getVGap(data);
|
|
289
|
-
me.preH = options.getPreH(data);
|
|
290
|
-
me.preV = options.getPreV(data);
|
|
291
|
-
me.width = options.getWidth(data);
|
|
292
|
-
me.height = options.getHeight(data);
|
|
293
|
-
me.width += me.preH;
|
|
294
|
-
me.height += me.preV;
|
|
295
|
-
me.id = options.getId(data);
|
|
296
|
-
me.x = me.y = 0;
|
|
297
|
-
me.depth = 0;
|
|
298
|
-
if (!me.children) {
|
|
299
|
-
me.children = [];
|
|
300
|
-
}
|
|
301
|
-
me.addGap(hgap, vgap);
|
|
302
|
-
return me;
|
|
303
|
-
}
|
|
304
|
-
util.assign(Node.prototype, {
|
|
305
|
-
isRoot: function isRoot() {
|
|
306
|
-
return this.depth === 0;
|
|
307
|
-
},
|
|
308
|
-
isLeaf: function isLeaf() {
|
|
309
|
-
return this.children.length === 0;
|
|
310
|
-
},
|
|
311
|
-
addGap: function addGap(hgap, vgap) {
|
|
312
|
-
var me = this;
|
|
313
|
-
me.hgap += hgap;
|
|
314
|
-
me.vgap += vgap;
|
|
315
|
-
me.width += 2 * hgap;
|
|
316
|
-
me.height += 2 * vgap;
|
|
317
|
-
},
|
|
318
|
-
eachNode: function eachNode(callback) {
|
|
319
|
-
// Depth First traverse
|
|
320
|
-
var me = this;
|
|
321
|
-
var nodes = [me];
|
|
322
|
-
var current;
|
|
323
|
-
while (current = nodes.shift()) {
|
|
324
|
-
callback(current);
|
|
325
|
-
nodes = current.children.concat(nodes);
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
DFTraverse: function DFTraverse(callback) {
|
|
329
|
-
// Depth First traverse
|
|
330
|
-
this.eachNode(callback);
|
|
331
|
-
},
|
|
332
|
-
BFTraverse: function BFTraverse(callback) {
|
|
333
|
-
// Breadth First traverse
|
|
334
|
-
var me = this;
|
|
335
|
-
var nodes = [me];
|
|
336
|
-
var current;
|
|
337
|
-
while (current = nodes.shift()) {
|
|
338
|
-
callback(current);
|
|
339
|
-
nodes = nodes.concat(current.children);
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
getBoundingBox: function getBoundingBox() {
|
|
343
|
-
// BBox for just one tree node
|
|
344
|
-
var bb = {
|
|
345
|
-
left: Number.MAX_VALUE,
|
|
346
|
-
top: Number.MAX_VALUE,
|
|
347
|
-
width: 0,
|
|
348
|
-
height: 0
|
|
349
|
-
};
|
|
350
|
-
this.eachNode(function (node) {
|
|
351
|
-
bb.left = Math.min(bb.left, node.x);
|
|
352
|
-
bb.top = Math.min(bb.top, node.y);
|
|
353
|
-
bb.width = Math.max(bb.width, node.x + node.width);
|
|
354
|
-
bb.height = Math.max(bb.height, node.y + node.height);
|
|
355
|
-
});
|
|
356
|
-
return bb;
|
|
357
|
-
},
|
|
358
|
-
// translate
|
|
359
|
-
translate: function translate(tx, ty) {
|
|
360
|
-
if (tx === void 0) {
|
|
361
|
-
tx = 0;
|
|
362
|
-
}
|
|
363
|
-
if (ty === void 0) {
|
|
364
|
-
ty = 0;
|
|
365
|
-
}
|
|
366
|
-
this.eachNode(function (node) {
|
|
367
|
-
node.x += tx;
|
|
368
|
-
node.y += ty;
|
|
369
|
-
node.x += node.preH;
|
|
370
|
-
node.y += node.preV;
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
right2left: function right2left() {
|
|
374
|
-
var me = this;
|
|
375
|
-
var bb = me.getBoundingBox();
|
|
376
|
-
me.eachNode(function (node) {
|
|
377
|
-
node.x = node.x - (node.x - bb.left) * 2 - node.width;
|
|
378
|
-
// node.x = - node.x;
|
|
379
|
-
});
|
|
380
|
-
me.translate(bb.width, 0);
|
|
381
|
-
},
|
|
382
|
-
bottom2top: function bottom2top() {
|
|
383
|
-
var me = this;
|
|
384
|
-
var bb = me.getBoundingBox();
|
|
385
|
-
me.eachNode(function (node) {
|
|
386
|
-
node.y = node.y - (node.y - bb.top) * 2 - node.height;
|
|
387
|
-
// node.y = - node.y;
|
|
388
|
-
});
|
|
389
|
-
me.translate(0, bb.height);
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
function hierarchy(data, options, isolated) {
|
|
393
|
-
if (options === void 0) {
|
|
394
|
-
options = {};
|
|
395
|
-
}
|
|
396
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
397
|
-
var root = new Node(data, options);
|
|
398
|
-
var nodes = [root];
|
|
399
|
-
var node;
|
|
400
|
-
if (!isolated && !data.collapsed) {
|
|
401
|
-
while (node = nodes.shift()) {
|
|
402
|
-
if (!node.data.collapsed) {
|
|
403
|
-
var children = options.getChildren(node.data);
|
|
404
|
-
var length = children ? children.length : 0;
|
|
405
|
-
node.children = new Array(length);
|
|
406
|
-
if (children && length) {
|
|
407
|
-
for (var i = 0; i < length; i++) {
|
|
408
|
-
var child = new Node(children[i], options);
|
|
409
|
-
node.children[i] = child;
|
|
410
|
-
nodes.push(child);
|
|
411
|
-
child.parent = node;
|
|
412
|
-
child.depth = node.depth + 1;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return root;
|
|
419
|
-
}
|
|
420
|
-
module.exports = hierarchy;
|
|
421
|
-
|
|
422
|
-
/***/ }),
|
|
423
|
-
/* 4 */
|
|
424
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
425
|
-
|
|
426
|
-
var hierarchy = __webpack_require__(3);
|
|
427
|
-
module.exports = function (root, options) {
|
|
428
|
-
// separate into left and right trees
|
|
429
|
-
var left = hierarchy(root.data, options, true); // root only
|
|
430
|
-
var right = hierarchy(root.data, options, true); // root only
|
|
431
|
-
// automatically
|
|
432
|
-
var treeSize = root.children.length;
|
|
433
|
-
var rightTreeSize = Math.round(treeSize / 2);
|
|
434
|
-
// separate left and right tree by meta data
|
|
435
|
-
var getSide = options.getSide || function (child, index) {
|
|
436
|
-
if (index < rightTreeSize) {
|
|
437
|
-
return 'right';
|
|
438
|
-
}
|
|
439
|
-
return 'left';
|
|
440
|
-
};
|
|
441
|
-
for (var i = 0; i < treeSize; i++) {
|
|
442
|
-
var child = root.children[i];
|
|
443
|
-
var side = getSide(child, i);
|
|
444
|
-
if (side === 'right') {
|
|
445
|
-
right.children.push(child);
|
|
446
|
-
} else {
|
|
447
|
-
left.children.push(child);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
left.eachNode(function (node) {
|
|
451
|
-
if (!node.isRoot()) {
|
|
452
|
-
node.side = 'left';
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
right.eachNode(function (node) {
|
|
456
|
-
if (!node.isRoot()) {
|
|
457
|
-
node.side = 'right';
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
return {
|
|
461
|
-
left: left,
|
|
462
|
-
right: right
|
|
463
|
-
};
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
/***/ }),
|
|
467
|
-
/* 5 */
|
|
468
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
469
|
-
|
|
470
|
-
var hierarchy = {
|
|
471
|
-
compactBox: __webpack_require__(6),
|
|
472
|
-
dendrogram: __webpack_require__(8),
|
|
473
|
-
indented: __webpack_require__(10),
|
|
474
|
-
mindmap: __webpack_require__(12)
|
|
475
|
-
};
|
|
476
|
-
module.exports = hierarchy;
|
|
477
|
-
|
|
478
|
-
/***/ }),
|
|
479
|
-
/* 6 */
|
|
480
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
481
|
-
|
|
482
|
-
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
|
|
483
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
484
|
-
var TreeLayout = __webpack_require__(1);
|
|
485
|
-
var nonLayeredTidyTree = __webpack_require__(7);
|
|
486
|
-
var doTreeLayout = __webpack_require__(2);
|
|
487
|
-
var util = __webpack_require__(0);
|
|
488
|
-
var CompactBoxTreeLayout = /*#__PURE__*/function (_TreeLayout) {
|
|
489
|
-
function CompactBoxTreeLayout() {
|
|
490
|
-
return _TreeLayout.apply(this, arguments) || this;
|
|
491
|
-
}
|
|
492
|
-
_inheritsLoose(CompactBoxTreeLayout, _TreeLayout);
|
|
493
|
-
var _proto = CompactBoxTreeLayout.prototype;
|
|
494
|
-
_proto.execute = function execute() {
|
|
495
|
-
var me = this;
|
|
496
|
-
return doTreeLayout(me.rootNode, me.options, nonLayeredTidyTree);
|
|
497
|
-
};
|
|
498
|
-
return CompactBoxTreeLayout;
|
|
499
|
-
}(TreeLayout);
|
|
500
|
-
var DEFAULT_OPTIONS = {};
|
|
501
|
-
function compactBoxLayout(root, options) {
|
|
502
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
503
|
-
return new CompactBoxTreeLayout(root, options).execute();
|
|
504
|
-
}
|
|
505
|
-
module.exports = compactBoxLayout;
|
|
506
|
-
|
|
507
|
-
/***/ }),
|
|
508
|
-
/* 7 */
|
|
509
|
-
/***/ (function(module, exports) {
|
|
510
|
-
|
|
511
|
-
// wrap tree node
|
|
512
|
-
function WrappedTree(w, h, y, c) {
|
|
513
|
-
if (c === void 0) {
|
|
514
|
-
c = [];
|
|
515
|
-
}
|
|
516
|
-
var me = this;
|
|
517
|
-
// size
|
|
518
|
-
me.w = w || 0;
|
|
519
|
-
me.h = h || 0;
|
|
520
|
-
|
|
521
|
-
// position
|
|
522
|
-
me.y = y || 0;
|
|
523
|
-
me.x = 0;
|
|
524
|
-
|
|
525
|
-
// children
|
|
526
|
-
me.c = c || [];
|
|
527
|
-
me.cs = c.length;
|
|
528
|
-
|
|
529
|
-
// modified
|
|
530
|
-
me.prelim = 0;
|
|
531
|
-
me.mod = 0;
|
|
532
|
-
me.shift = 0;
|
|
533
|
-
me.change = 0;
|
|
534
|
-
|
|
535
|
-
// left/right tree
|
|
536
|
-
me.tl = null;
|
|
537
|
-
me.tr = null;
|
|
538
|
-
|
|
539
|
-
// extreme left/right tree
|
|
540
|
-
me.el = null;
|
|
541
|
-
me.er = null;
|
|
542
|
-
|
|
543
|
-
// modified left/right tree
|
|
544
|
-
me.msel = 0;
|
|
545
|
-
me.mser = 0;
|
|
546
|
-
}
|
|
547
|
-
WrappedTree.fromNode = function (root, isHorizontal) {
|
|
548
|
-
if (!root) return null;
|
|
549
|
-
var children = [];
|
|
550
|
-
root.children.forEach(function (child) {
|
|
551
|
-
children.push(WrappedTree.fromNode(child, isHorizontal));
|
|
552
|
-
});
|
|
553
|
-
if (isHorizontal) return new WrappedTree(root.height, root.width, root.x, children);
|
|
554
|
-
return new WrappedTree(root.width, root.height, root.y, children);
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
// node utils
|
|
558
|
-
function moveRight(node, move, isHorizontal) {
|
|
559
|
-
if (isHorizontal) {
|
|
560
|
-
node.y += move;
|
|
561
|
-
} else {
|
|
562
|
-
node.x += move;
|
|
563
|
-
}
|
|
564
|
-
node.children.forEach(function (child) {
|
|
565
|
-
moveRight(child, move, isHorizontal);
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
function getMin(node, isHorizontal) {
|
|
569
|
-
var res = isHorizontal ? node.y : node.x;
|
|
570
|
-
node.children.forEach(function (child) {
|
|
571
|
-
res = Math.min(getMin(child, isHorizontal), res);
|
|
572
|
-
});
|
|
573
|
-
return res;
|
|
574
|
-
}
|
|
575
|
-
function normalize(node, isHorizontal) {
|
|
576
|
-
var min = getMin(node, isHorizontal);
|
|
577
|
-
moveRight(node, -min, isHorizontal);
|
|
578
|
-
}
|
|
579
|
-
function convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {
|
|
580
|
-
if (isHorizontal) {
|
|
581
|
-
root.y = converted.x;
|
|
582
|
-
} else {
|
|
583
|
-
root.x = converted.x;
|
|
584
|
-
}
|
|
585
|
-
converted.c.forEach(function (child, i) {
|
|
586
|
-
convertBack(child, root.children[i], isHorizontal);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
function layer(node, isHorizontal, d) {
|
|
590
|
-
if (d === void 0) {
|
|
591
|
-
d = 0;
|
|
592
|
-
}
|
|
593
|
-
if (isHorizontal) {
|
|
594
|
-
node.x = d;
|
|
595
|
-
d += node.width;
|
|
596
|
-
} else {
|
|
597
|
-
node.y = d;
|
|
598
|
-
d += node.height;
|
|
599
|
-
}
|
|
600
|
-
node.children.forEach(function (child) {
|
|
601
|
-
layer(child, isHorizontal, d);
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
module.exports = function (root, options) {
|
|
605
|
-
if (options === void 0) {
|
|
606
|
-
options = {};
|
|
607
|
-
}
|
|
608
|
-
var isHorizontal = options.isHorizontal;
|
|
609
|
-
function firstWalk(t) {
|
|
610
|
-
if (t.cs === 0) {
|
|
611
|
-
setExtremes(t);
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
firstWalk(t.c[0]);
|
|
615
|
-
var ih = updateIYL(bottom(t.c[0].el), 0, null);
|
|
616
|
-
for (var i = 1; i < t.cs; ++i) {
|
|
617
|
-
firstWalk(t.c[i]);
|
|
618
|
-
var min = bottom(t.c[i].er);
|
|
619
|
-
separate(t, i, ih);
|
|
620
|
-
ih = updateIYL(min, i, ih);
|
|
621
|
-
}
|
|
622
|
-
positionRoot(t);
|
|
623
|
-
setExtremes(t);
|
|
624
|
-
}
|
|
625
|
-
function setExtremes(t) {
|
|
626
|
-
if (t.cs === 0) {
|
|
627
|
-
t.el = t;
|
|
628
|
-
t.er = t;
|
|
629
|
-
t.msel = t.mser = 0;
|
|
630
|
-
} else {
|
|
631
|
-
t.el = t.c[0].el;
|
|
632
|
-
t.msel = t.c[0].msel;
|
|
633
|
-
t.er = t.c[t.cs - 1].er;
|
|
634
|
-
t.mser = t.c[t.cs - 1].mser;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
function separate(t, i, ih) {
|
|
638
|
-
var sr = t.c[i - 1];
|
|
639
|
-
var mssr = sr.mod;
|
|
640
|
-
var cl = t.c[i];
|
|
641
|
-
var mscl = cl.mod;
|
|
642
|
-
while (sr !== null && cl !== null) {
|
|
643
|
-
if (bottom(sr) > ih.low) ih = ih.nxt;
|
|
644
|
-
var dist = mssr + sr.prelim + sr.w - (mscl + cl.prelim);
|
|
645
|
-
if (dist > 0) {
|
|
646
|
-
mscl += dist;
|
|
647
|
-
moveSubtree(t, i, ih.index, dist);
|
|
648
|
-
}
|
|
649
|
-
var sy = bottom(sr);
|
|
650
|
-
var cy = bottom(cl);
|
|
651
|
-
if (sy <= cy) {
|
|
652
|
-
sr = nextRightContour(sr);
|
|
653
|
-
if (sr !== null) mssr += sr.mod;
|
|
654
|
-
}
|
|
655
|
-
if (sy >= cy) {
|
|
656
|
-
cl = nextLeftContour(cl);
|
|
657
|
-
if (cl !== null) mscl += cl.mod;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
if (!sr && !!cl) {
|
|
661
|
-
setLeftThread(t, i, cl, mscl);
|
|
662
|
-
} else if (!!sr && !cl) {
|
|
663
|
-
setRightThread(t, i, sr, mssr);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function moveSubtree(t, i, si, dist) {
|
|
667
|
-
t.c[i].mod += dist;
|
|
668
|
-
t.c[i].msel += dist;
|
|
669
|
-
t.c[i].mser += dist;
|
|
670
|
-
distributeExtra(t, i, si, dist);
|
|
671
|
-
}
|
|
672
|
-
function nextLeftContour(t) {
|
|
673
|
-
return t.cs === 0 ? t.tl : t.c[0];
|
|
674
|
-
}
|
|
675
|
-
function nextRightContour(t) {
|
|
676
|
-
return t.cs === 0 ? t.tr : t.c[t.cs - 1];
|
|
677
|
-
}
|
|
678
|
-
function bottom(t) {
|
|
679
|
-
return t.y + t.h;
|
|
680
|
-
}
|
|
681
|
-
function setLeftThread(t, i, cl, modsumcl) {
|
|
682
|
-
var li = t.c[0].el;
|
|
683
|
-
li.tl = cl;
|
|
684
|
-
var diff = modsumcl - cl.mod - t.c[0].msel;
|
|
685
|
-
li.mod += diff;
|
|
686
|
-
li.prelim -= diff;
|
|
687
|
-
t.c[0].el = t.c[i].el;
|
|
688
|
-
t.c[0].msel = t.c[i].msel;
|
|
689
|
-
}
|
|
690
|
-
function setRightThread(t, i, sr, modsumsr) {
|
|
691
|
-
var ri = t.c[i].er;
|
|
692
|
-
ri.tr = sr;
|
|
693
|
-
var diff = modsumsr - sr.mod - t.c[i].mser;
|
|
694
|
-
ri.mod += diff;
|
|
695
|
-
ri.prelim -= diff;
|
|
696
|
-
t.c[i].er = t.c[i - 1].er;
|
|
697
|
-
t.c[i].mser = t.c[i - 1].mser;
|
|
698
|
-
}
|
|
699
|
-
function positionRoot(t) {
|
|
700
|
-
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;
|
|
701
|
-
}
|
|
702
|
-
function secondWalk(t, modsum) {
|
|
703
|
-
modsum += t.mod;
|
|
704
|
-
t.x = t.prelim + modsum;
|
|
705
|
-
addChildSpacing(t);
|
|
706
|
-
for (var i = 0; i < t.cs; i++) {
|
|
707
|
-
secondWalk(t.c[i], modsum);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
function distributeExtra(t, i, si, dist) {
|
|
711
|
-
if (si !== i - 1) {
|
|
712
|
-
var nr = i - si;
|
|
713
|
-
t.c[si + 1].shift += dist / nr;
|
|
714
|
-
t.c[i].shift -= dist / nr;
|
|
715
|
-
t.c[i].change -= dist - dist / nr;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
function addChildSpacing(t) {
|
|
719
|
-
var d = 0;
|
|
720
|
-
var modsumdelta = 0;
|
|
721
|
-
for (var i = 0; i < t.cs; i++) {
|
|
722
|
-
d += t.c[i].shift;
|
|
723
|
-
modsumdelta += d + t.c[i].change;
|
|
724
|
-
t.c[i].mod += modsumdelta;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
function updateIYL(low, index, ih) {
|
|
728
|
-
while (ih !== null && low >= ih.low) {
|
|
729
|
-
ih = ih.nxt;
|
|
730
|
-
}
|
|
731
|
-
return {
|
|
732
|
-
low: low,
|
|
733
|
-
index: index,
|
|
734
|
-
nxt: ih
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// do layout
|
|
739
|
-
layer(root, isHorizontal);
|
|
740
|
-
var wt = WrappedTree.fromNode(root, isHorizontal);
|
|
741
|
-
firstWalk(wt);
|
|
742
|
-
secondWalk(wt, 0);
|
|
743
|
-
convertBack(wt, root, isHorizontal);
|
|
744
|
-
normalize(root, isHorizontal);
|
|
745
|
-
return root;
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
/***/ }),
|
|
749
|
-
/* 8 */
|
|
750
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
751
|
-
|
|
752
|
-
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
|
|
753
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
754
|
-
var TreeLayout = __webpack_require__(1);
|
|
755
|
-
var dendrogram = __webpack_require__(9);
|
|
756
|
-
var doTreeLayout = __webpack_require__(2);
|
|
757
|
-
var util = __webpack_require__(0);
|
|
758
|
-
var DendrogramLayout = /*#__PURE__*/function (_TreeLayout) {
|
|
759
|
-
function DendrogramLayout() {
|
|
760
|
-
return _TreeLayout.apply(this, arguments) || this;
|
|
761
|
-
}
|
|
762
|
-
_inheritsLoose(DendrogramLayout, _TreeLayout);
|
|
763
|
-
var _proto = DendrogramLayout.prototype;
|
|
764
|
-
_proto.execute = function execute() {
|
|
765
|
-
var me = this;
|
|
766
|
-
me.rootNode.width = 0;
|
|
767
|
-
return doTreeLayout(me.rootNode, me.options, dendrogram);
|
|
768
|
-
};
|
|
769
|
-
return DendrogramLayout;
|
|
770
|
-
}(TreeLayout);
|
|
771
|
-
var DEFAULT_OPTIONS = {};
|
|
772
|
-
function dendrogramLayout(root, options) {
|
|
773
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
774
|
-
return new DendrogramLayout(root, options).execute();
|
|
775
|
-
}
|
|
776
|
-
module.exports = dendrogramLayout;
|
|
777
|
-
|
|
778
|
-
/***/ }),
|
|
779
|
-
/* 9 */
|
|
780
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
781
|
-
|
|
782
|
-
// wrap tree node
|
|
783
|
-
// TODO considering size
|
|
784
|
-
var util = __webpack_require__(0);
|
|
785
|
-
function WrappedTree(height, children) {
|
|
786
|
-
if (height === void 0) {
|
|
787
|
-
height = 0;
|
|
788
|
-
}
|
|
789
|
-
if (children === void 0) {
|
|
790
|
-
children = [];
|
|
791
|
-
}
|
|
792
|
-
var me = this;
|
|
793
|
-
me.x = me.y = 0;
|
|
794
|
-
me.leftChild = me.rightChild = null;
|
|
795
|
-
me.height = 0;
|
|
796
|
-
me.children = children;
|
|
797
|
-
}
|
|
798
|
-
var DEFAULT_OPTIONS = {
|
|
799
|
-
isHorizontal: true,
|
|
800
|
-
nodeSep: 20,
|
|
801
|
-
nodeSize: 20,
|
|
802
|
-
rankSep: 200,
|
|
803
|
-
subTreeSep: 10
|
|
804
|
-
};
|
|
805
|
-
function convertBack(converted /* WrappedTree */, root /* TreeNode */, isHorizontal) {
|
|
806
|
-
if (isHorizontal) {
|
|
807
|
-
root.x = converted.x;
|
|
808
|
-
root.y = converted.y;
|
|
809
|
-
} else {
|
|
810
|
-
root.x = converted.y;
|
|
811
|
-
root.y = converted.x;
|
|
812
|
-
}
|
|
813
|
-
converted.children.forEach(function (child, i) {
|
|
814
|
-
convertBack(child, root.children[i], isHorizontal);
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
module.exports = function (root, options) {
|
|
818
|
-
if (options === void 0) {
|
|
819
|
-
options = {};
|
|
820
|
-
}
|
|
821
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
822
|
-
var maxDepth = 0;
|
|
823
|
-
function wrappedTreeFromNode(n) {
|
|
824
|
-
if (!n) return null;
|
|
825
|
-
n.width = 0;
|
|
826
|
-
if (n.depth && n.depth > maxDepth) {
|
|
827
|
-
maxDepth = n.depth; // get the max depth
|
|
828
|
-
}
|
|
829
|
-
var children = n.children;
|
|
830
|
-
var childrenCount = children.length;
|
|
831
|
-
var t = new WrappedTree(n.height, []);
|
|
832
|
-
children.forEach(function (child, i) {
|
|
833
|
-
var childWT = wrappedTreeFromNode(child);
|
|
834
|
-
t.children.push(childWT);
|
|
835
|
-
if (i === 0) {
|
|
836
|
-
// t.leftChild = childWT.leftChild ? childWT.leftChild : childWT
|
|
837
|
-
t.leftChild = childWT;
|
|
838
|
-
}
|
|
839
|
-
if (i === childrenCount - 1) {
|
|
840
|
-
// t.rightChild = childWT.rightChild ? childWT.rightChild : childWT
|
|
841
|
-
t.rightChild = childWT;
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
t.originNode = n;
|
|
845
|
-
t.isLeaf = n.isLeaf();
|
|
846
|
-
return t;
|
|
847
|
-
}
|
|
848
|
-
function getDrawingDepth(t) {
|
|
849
|
-
if (t.isLeaf || t.children.length === 0) {
|
|
850
|
-
t.drawingDepth = maxDepth;
|
|
851
|
-
} else {
|
|
852
|
-
var depths = t.children.map(function (child) {
|
|
853
|
-
return getDrawingDepth(child);
|
|
854
|
-
});
|
|
855
|
-
var minChildDepth = Math.min.apply(null, depths);
|
|
856
|
-
t.drawingDepth = minChildDepth - 1;
|
|
857
|
-
}
|
|
858
|
-
return t.drawingDepth;
|
|
859
|
-
}
|
|
860
|
-
var prevLeaf;
|
|
861
|
-
function position(t) {
|
|
862
|
-
t.x = t.drawingDepth * options.rankSep;
|
|
863
|
-
if (t.isLeaf) {
|
|
864
|
-
t.y = 0;
|
|
865
|
-
if (prevLeaf) {
|
|
866
|
-
t.y = prevLeaf.y + prevLeaf.height + options.nodeSep;
|
|
867
|
-
if (t.originNode.parent !== prevLeaf.originNode.parent) {
|
|
868
|
-
t.y += options.subTreeSep;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
prevLeaf = t;
|
|
872
|
-
} else {
|
|
873
|
-
t.children.forEach(function (child) {
|
|
874
|
-
position(child);
|
|
875
|
-
});
|
|
876
|
-
t.y = (t.leftChild.y + t.rightChild.y) / 2;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// wrap node
|
|
881
|
-
var wt = wrappedTreeFromNode(root);
|
|
882
|
-
// get depth for drawing
|
|
883
|
-
getDrawingDepth(wt);
|
|
884
|
-
// get position
|
|
885
|
-
position(wt);
|
|
886
|
-
// get x, y
|
|
887
|
-
convertBack(wt, root, options.isHorizontal);
|
|
888
|
-
return root;
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
/***/ }),
|
|
892
|
-
/* 10 */
|
|
893
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
894
|
-
|
|
895
|
-
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
|
|
896
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
897
|
-
var TreeLayout = __webpack_require__(1);
|
|
898
|
-
var indentedTree = __webpack_require__(11);
|
|
899
|
-
var separateTree = __webpack_require__(4);
|
|
900
|
-
var util = __webpack_require__(0);
|
|
901
|
-
var VALID_DIRECTIONS = ['LR',
|
|
902
|
-
// left to right
|
|
903
|
-
'RL',
|
|
904
|
-
// right to left
|
|
905
|
-
'H' // horizontal
|
|
906
|
-
];
|
|
907
|
-
var DEFAULT_DIRECTION = VALID_DIRECTIONS[0];
|
|
908
|
-
var IndentedLayout = /*#__PURE__*/function (_TreeLayout) {
|
|
909
|
-
function IndentedLayout() {
|
|
910
|
-
return _TreeLayout.apply(this, arguments) || this;
|
|
911
|
-
}
|
|
912
|
-
_inheritsLoose(IndentedLayout, _TreeLayout);
|
|
913
|
-
var _proto = IndentedLayout.prototype;
|
|
914
|
-
_proto.execute = function execute() {
|
|
915
|
-
var me = this;
|
|
916
|
-
var options = me.options;
|
|
917
|
-
var root = me.rootNode;
|
|
918
|
-
options.isHorizontal = true;
|
|
919
|
-
// default indent 20 and sink first children;
|
|
920
|
-
var _options$indent = options.indent,
|
|
921
|
-
indent = _options$indent === void 0 ? 20 : _options$indent,
|
|
922
|
-
_options$dropCap = options.dropCap,
|
|
923
|
-
dropCap = _options$dropCap === void 0 ? true : _options$dropCap,
|
|
924
|
-
_options$direction = options.direction,
|
|
925
|
-
direction = _options$direction === void 0 ? DEFAULT_DIRECTION : _options$direction,
|
|
926
|
-
align = options.align;
|
|
927
|
-
if (direction && VALID_DIRECTIONS.indexOf(direction) === -1) {
|
|
928
|
-
throw new TypeError("Invalid direction: " + direction);
|
|
929
|
-
}
|
|
930
|
-
if (direction === VALID_DIRECTIONS[0]) {
|
|
931
|
-
// LR
|
|
932
|
-
indentedTree(root, indent, dropCap, align);
|
|
933
|
-
} else if (direction === VALID_DIRECTIONS[1]) {
|
|
934
|
-
// RL
|
|
935
|
-
indentedTree(root, indent, dropCap, align);
|
|
936
|
-
root.right2left();
|
|
937
|
-
} else if (direction === VALID_DIRECTIONS[2]) {
|
|
938
|
-
// H
|
|
939
|
-
// separate into left and right trees
|
|
940
|
-
var _separateTree = separateTree(root, options),
|
|
941
|
-
left = _separateTree.left,
|
|
942
|
-
right = _separateTree.right;
|
|
943
|
-
indentedTree(left, indent, dropCap, align);
|
|
944
|
-
left.right2left();
|
|
945
|
-
indentedTree(right, indent, dropCap, align);
|
|
946
|
-
var bbox = left.getBoundingBox();
|
|
947
|
-
right.translate(bbox.width, 0);
|
|
948
|
-
root.x = right.x - root.width / 2;
|
|
949
|
-
}
|
|
950
|
-
return root;
|
|
951
|
-
};
|
|
952
|
-
return IndentedLayout;
|
|
953
|
-
}(TreeLayout);
|
|
954
|
-
var DEFAULT_OPTIONS = {};
|
|
955
|
-
function indentedLayout(root, options) {
|
|
956
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
957
|
-
return new IndentedLayout(root, options).execute();
|
|
958
|
-
}
|
|
959
|
-
module.exports = indentedLayout;
|
|
960
|
-
|
|
961
|
-
/***/ }),
|
|
962
|
-
/* 11 */
|
|
963
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
964
|
-
|
|
965
|
-
var util = __webpack_require__(0);
|
|
966
|
-
function positionNode(node, previousNode, indent, dropCap, align) {
|
|
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;
|
|
969
|
-
if (!dropCap) {
|
|
970
|
-
try {
|
|
971
|
-
if (node.id === node.parent.children[0].id) {
|
|
972
|
-
node.x += displacementX;
|
|
973
|
-
node.y = previousNode ? previousNode.y : 0;
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
} catch (e) {
|
|
977
|
-
// skip to normal when a node has no parent
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
node.x += displacementX;
|
|
981
|
-
if (previousNode) {
|
|
982
|
-
node.y = previousNode.y + util.getHeight(previousNode, node, align);
|
|
983
|
-
if (previousNode.parent && node.parent.id !== previousNode.parent.id) {
|
|
984
|
-
// previous node has different parent
|
|
985
|
-
var prevParent = previousNode.parent;
|
|
986
|
-
var preY = prevParent.y + util.getHeight(prevParent, node, align);
|
|
987
|
-
node.y = preY > node.y ? preY : node.y;
|
|
988
|
-
}
|
|
989
|
-
} else {
|
|
990
|
-
node.y = 0;
|
|
991
|
-
}
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
|
-
module.exports = function (root, indent, dropCap, align) {
|
|
995
|
-
var previousNode = null;
|
|
996
|
-
root.eachNode(function (node) {
|
|
997
|
-
positionNode(node, previousNode, indent, dropCap, align);
|
|
998
|
-
previousNode = node;
|
|
999
|
-
});
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
|
-
/***/ }),
|
|
1003
|
-
/* 12 */
|
|
1004
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1005
|
-
|
|
1006
|
-
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
|
|
1007
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
1008
|
-
var TreeLayout = __webpack_require__(1);
|
|
1009
|
-
var mindmap = __webpack_require__(13);
|
|
1010
|
-
var doTreeLayout = __webpack_require__(2);
|
|
1011
|
-
var util = __webpack_require__(0);
|
|
1012
|
-
var MindmapLayout = /*#__PURE__*/function (_TreeLayout) {
|
|
1013
|
-
function MindmapLayout() {
|
|
1014
|
-
return _TreeLayout.apply(this, arguments) || this;
|
|
1015
|
-
}
|
|
1016
|
-
_inheritsLoose(MindmapLayout, _TreeLayout);
|
|
1017
|
-
var _proto = MindmapLayout.prototype;
|
|
1018
|
-
_proto.execute = function execute() {
|
|
1019
|
-
var me = this;
|
|
1020
|
-
return doTreeLayout(me.rootNode, me.options, mindmap);
|
|
1021
|
-
};
|
|
1022
|
-
return MindmapLayout;
|
|
1023
|
-
}(TreeLayout);
|
|
1024
|
-
var DEFAULT_OPTIONS = {};
|
|
1025
|
-
function mindmapLayout(root, options) {
|
|
1026
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
1027
|
-
return new MindmapLayout(root, options).execute();
|
|
1028
|
-
}
|
|
1029
|
-
module.exports = mindmapLayout;
|
|
1030
|
-
|
|
1031
|
-
/***/ }),
|
|
1032
|
-
/* 13 */
|
|
1033
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1034
|
-
|
|
1035
|
-
var util = __webpack_require__(0);
|
|
1036
|
-
function secondWalk(node, options) {
|
|
1037
|
-
var totalHeight = 0;
|
|
1038
|
-
if (!node.children.length) {
|
|
1039
|
-
totalHeight = node.height;
|
|
1040
|
-
} else {
|
|
1041
|
-
node.children.forEach(function (c) {
|
|
1042
|
-
totalHeight += secondWalk(c, options);
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
node._subTreeSep = options.getSubTreeSep(node.data);
|
|
1046
|
-
node.totalHeight = Math.max(node.height, totalHeight) + 2 * node._subTreeSep;
|
|
1047
|
-
return node.totalHeight;
|
|
1048
|
-
}
|
|
1049
|
-
function thirdWalk(node) {
|
|
1050
|
-
var children = node.children;
|
|
1051
|
-
var len = children.length;
|
|
1052
|
-
if (len) {
|
|
1053
|
-
children.forEach(function (c) {
|
|
1054
|
-
thirdWalk(c);
|
|
1055
|
-
});
|
|
1056
|
-
var first = children[0];
|
|
1057
|
-
var last = children[len - 1];
|
|
1058
|
-
var childrenHeight = last.y - first.y + last.height;
|
|
1059
|
-
var childrenTotalHeight = 0;
|
|
1060
|
-
children.forEach(function (child) {
|
|
1061
|
-
childrenTotalHeight += child.totalHeight;
|
|
1062
|
-
});
|
|
1063
|
-
if (childrenHeight > node.height) {
|
|
1064
|
-
// 当子节点总高度大于父节点高度
|
|
1065
|
-
node.y = first.y + childrenHeight / 2 - node.height / 2;
|
|
1066
|
-
} else if (children.length !== 1 || node.height > childrenTotalHeight) {
|
|
1067
|
-
// 多于一个子节点或者父节点大于所有子节点的总高度
|
|
1068
|
-
var offset = node.y + (node.height - childrenHeight) / 2 - first.y;
|
|
1069
|
-
children.forEach(function (c) {
|
|
1070
|
-
c.translate(0, offset);
|
|
1071
|
-
});
|
|
1072
|
-
} else {
|
|
1073
|
-
// 只有一个子节点
|
|
1074
|
-
node.y = (first.y + first.height / 2 + last.y + last.height / 2) / 2 - node.height / 2;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
var DEFAULT_OPTIONS = {
|
|
1079
|
-
getSubTreeSep: function getSubTreeSep() {
|
|
1080
|
-
return 0;
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
module.exports = function (root, options) {
|
|
1084
|
-
if (options === void 0) {
|
|
1085
|
-
options = {};
|
|
1086
|
-
}
|
|
1087
|
-
options = util.assign({}, DEFAULT_OPTIONS, options);
|
|
1088
|
-
root.parent = {
|
|
1089
|
-
x: 0,
|
|
1090
|
-
width: 0,
|
|
1091
|
-
height: 0,
|
|
1092
|
-
y: 0
|
|
1093
|
-
};
|
|
1094
|
-
// first walk
|
|
1095
|
-
root.BFTraverse(function (node) {
|
|
1096
|
-
node.x = node.parent.x + node.parent.width; // simply get x
|
|
1097
|
-
});
|
|
1098
|
-
root.parent = null;
|
|
1099
|
-
// second walk
|
|
1100
|
-
secondWalk(root, options); // assign sub tree totalHeight
|
|
1101
|
-
// adjusting
|
|
1102
|
-
// separating nodes
|
|
1103
|
-
root.startY = 0;
|
|
1104
|
-
root.y = root.totalHeight / 2 - root.height / 2;
|
|
1105
|
-
root.eachNode(function (node) {
|
|
1106
|
-
var children = node.children;
|
|
1107
|
-
var len = children.length;
|
|
1108
|
-
if (len) {
|
|
1109
|
-
var first = children[0];
|
|
1110
|
-
first.startY = node.startY + node._subTreeSep;
|
|
1111
|
-
if (len === 1) {
|
|
1112
|
-
first.y = node.y + node.height / 2 - first.height / 2;
|
|
1113
|
-
} else {
|
|
1114
|
-
first.y = first.startY + first.totalHeight / 2 - first.height / 2;
|
|
1115
|
-
for (var i = 1; i < len; i++) {
|
|
1116
|
-
var c = children[i];
|
|
1117
|
-
c.startY = children[i - 1].startY + children[i - 1].totalHeight;
|
|
1118
|
-
c.y = c.startY + c.totalHeight / 2 - c.height / 2;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
});
|
|
1123
|
-
|
|
1124
|
-
// third walk
|
|
1125
|
-
thirdWalk(root);
|
|
1126
|
-
};
|
|
1127
|
-
|
|
1128
|
-
/***/ })
|
|
1129
|
-
/******/ ]);
|
|
1130
|
-
});
|
|
1131
|
-
//# sourceMappingURL=hierarchy.js.map
|