vislite 1.4.0 → 1.5.0-alpha.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.
Files changed (85) hide show
  1. package/CHANGELOG +313 -307
  2. package/lib/BarLayout/index.es.js +347 -347
  3. package/lib/BarLayout/index.es.min.js +1 -1
  4. package/lib/Buffer/index.es.js +35 -35
  5. package/lib/Buffer/index.es.min.js +1 -1
  6. package/lib/Canvas/index.es.js +775 -774
  7. package/lib/Canvas/index.es.min.js +2 -2
  8. package/lib/Cardinal/index.es.js +90 -90
  9. package/lib/Cardinal/index.es.min.js +1 -1
  10. package/lib/Eoap/index.es.js +33 -33
  11. package/lib/Eoap/index.es.min.js +1 -1
  12. package/lib/Hermite/index.es.js +35 -35
  13. package/lib/Hermite/index.es.min.js +1 -1
  14. package/lib/MapCoordinate/index.es.js +199 -199
  15. package/lib/MapCoordinate/index.es.min.js +1 -1
  16. package/lib/Matrix4/index.es.js +124 -124
  17. package/lib/Matrix4/index.es.min.js +1 -1
  18. package/lib/Mercator/index.es.js +19 -19
  19. package/lib/Mercator/index.es.min.js +1 -1
  20. package/lib/PieLayout/index.es.js +114 -114
  21. package/lib/PieLayout/index.es.min.js +1 -1
  22. package/lib/RawCanvas/index.es.js +704 -704
  23. package/lib/RawCanvas/index.es.min.js +1 -1
  24. package/lib/SVG/index.es.js +514 -514
  25. package/lib/SVG/index.es.min.js +1 -1
  26. package/lib/Shader/index.es.js +35 -35
  27. package/lib/Shader/index.es.min.js +1 -1
  28. package/lib/Texture/index.es.js +53 -53
  29. package/lib/Texture/index.es.min.js +1 -1
  30. package/lib/TreeLayout/index.es.js +301 -301
  31. package/lib/TreeLayout/index.es.min.js +1 -1
  32. package/lib/animation/index.es.js +3 -3
  33. package/lib/animation/index.es.min.js +1 -1
  34. package/lib/assemble/index.es.js +17 -17
  35. package/lib/assemble/index.es.min.js +1 -1
  36. package/lib/getLoopColors/index.es.js +35 -35
  37. package/lib/getLoopColors/index.es.min.js +1 -1
  38. package/lib/getWebGLContext/index.es.js +62 -62
  39. package/lib/getWebGLContext/index.es.min.js +1 -1
  40. package/lib/index.umd.js +2657 -2656
  41. package/lib/index.umd.min.js +4 -4
  42. package/lib/initOption/index.es.js +6 -6
  43. package/lib/initOption/index.es.min.js +1 -1
  44. package/lib/mergeOption/index.es.js +34 -34
  45. package/lib/mergeOption/index.es.min.js +1 -1
  46. package/lib/move/index.es.js +7 -7
  47. package/lib/move/index.es.min.js +1 -1
  48. package/lib/rotate/index.es.js +7 -7
  49. package/lib/rotate/index.es.min.js +1 -1
  50. package/lib/ruler/index.es.js +137 -137
  51. package/lib/ruler/index.es.min.js +1 -1
  52. package/lib/scale/index.es.js +6 -6
  53. package/lib/scale/index.es.min.js +1 -1
  54. package/lib/throttle/index.es.js +1 -1
  55. package/lib/throttle/index.es.min.js +1 -1
  56. package/package/BarLayout/index.ts +2 -2
  57. package/package/PieLayout/index.ts +2 -2
  58. package/package/animation/index.ts +5 -5
  59. package/package/index.ts +84 -84
  60. package/package/throttle/index.ts +2 -2
  61. package/package.json +75 -75
  62. package/src/Canvas.ts +9 -4
  63. package/src/SVG.ts +55 -55
  64. package/src/common/canvas/gradient.ts +31 -31
  65. package/src/common/svg/default.ts +29 -29
  66. package/src/common/svg/gradient.ts +53 -53
  67. package/src/common/svg/index.ts +332 -332
  68. package/src/common/tree/toPlainTree.ts +135 -135
  69. package/src/common/webgl/texture.ts +98 -98
  70. package/src/layout/BarLayout.ts +248 -248
  71. package/src/layout/PieLayout.ts +141 -141
  72. package/src/layout/TreeLayout.ts +197 -197
  73. package/types/Bar.d.ts +91 -91
  74. package/types/BarConfig.d.ts +4 -4
  75. package/types/BarLayout.d.ts +48 -48
  76. package/types/BarOption.d.ts +31 -31
  77. package/types/CanvasOption.d.ts +5 -0
  78. package/types/Pie.d.ts +73 -73
  79. package/types/PieConfig.d.ts +26 -26
  80. package/types/PieLayout.d.ts +40 -40
  81. package/types/PieOption.d.ts +21 -21
  82. package/types/SVG.d.ts +247 -247
  83. package/types/animation.d.ts +11 -11
  84. package/types/index.d.ts +195 -195
  85. package/types/throttle.d.ts +5 -5
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * TreeLayout of VISLite JavaScript Library v1.4.0
2
+ * TreeLayout of VISLite JavaScript Library v1.5.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  /******************************************************************************
@@ -38,152 +38,152 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
38
38
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
39
39
  };
40
40
 
41
- var toInnerTree = (function (initTree, config) {
42
- var tempTree = {};
43
- var temp = config.root(initTree);
44
- var id, rid;
45
- id = rid = config.id(temp);
46
- tempTree[id] = {
47
- "data": temp,
48
- "pid": null,
49
- "id": id,
50
- "isOpen": true,
51
- "show": true,
52
- "deg": 0,
53
- "children": []
54
- };
55
- var num = 1;
56
- (function createTree(pdata, pid) {
57
- var children = config.children(pdata, initTree);
58
- num += children ? children.length : 0;
59
- for (var flag = 0; children && flag < children.length; flag++) {
60
- id = config.id(children[flag]);
61
- tempTree[pid].children.push(id);
62
- tempTree[id] = {
63
- "data": children[flag],
64
- "pid": pid,
65
- "id": id,
66
- "isOpen": true,
67
- "show": true,
68
- "deg": 0,
69
- "children": []
70
- };
71
- createTree(children[flag], id);
72
- }
73
- })(temp, id);
74
- return {
75
- rid: rid,
76
- value: tempTree,
77
- num: num
78
- };
41
+ var toInnerTree = (function (initTree, config) {
42
+ var tempTree = {};
43
+ var temp = config.root(initTree);
44
+ var id, rid;
45
+ id = rid = config.id(temp);
46
+ tempTree[id] = {
47
+ "data": temp,
48
+ "pid": null,
49
+ "id": id,
50
+ "isOpen": true,
51
+ "show": true,
52
+ "deg": 0,
53
+ "children": []
54
+ };
55
+ var num = 1;
56
+ (function createTree(pdata, pid) {
57
+ var children = config.children(pdata, initTree);
58
+ num += children ? children.length : 0;
59
+ for (var flag = 0; children && flag < children.length; flag++) {
60
+ id = config.id(children[flag]);
61
+ tempTree[pid].children.push(id);
62
+ tempTree[id] = {
63
+ "data": children[flag],
64
+ "pid": pid,
65
+ "id": id,
66
+ "isOpen": true,
67
+ "show": true,
68
+ "deg": 0,
69
+ "children": []
70
+ };
71
+ createTree(children[flag], id);
72
+ }
73
+ })(temp, id);
74
+ return {
75
+ rid: rid,
76
+ value: tempTree,
77
+ num: num
78
+ };
79
79
  });
80
80
 
81
- function toPlainTree (initTree, config, noOpens) {
82
- var treeData = toInnerTree(initTree, config);
83
- var alltreedata = treeData.value;
84
- var rootid = treeData.rid;
85
- if (treeData.num == 1) {
86
- alltreedata[rootid].left = 0.5;
87
- alltreedata[rootid].top = 0.5;
88
- alltreedata[rootid].show = true;
89
- return {
90
- deep: 1,
91
- node: alltreedata,
92
- root: rootid,
93
- size: 1
94
- };
95
- }
96
- else {
97
- var beforeDis_1 = [];
98
- var size_1 = 0, maxDeep_1 = 0;
99
- if (noOpens[rootid]) {
100
- alltreedata[rootid].left = 0.5;
101
- alltreedata[rootid].top = 0.5;
102
- alltreedata[rootid].show = true;
103
- size_1 = 1;
104
- }
105
- else {
106
- (function positionCalc(pNode, deep) {
107
- if (deep > maxDeep_1)
108
- maxDeep_1 = deep;
109
- var flag = 0;
110
- if (!noOpens[pNode.id]) {
111
- for (flag = 0; flag < pNode.children.length; flag++)
112
- positionCalc(alltreedata[pNode.children[flag]], deep + 1);
113
- }
114
- alltreedata[pNode.id].left = deep + 0.5;
115
- if (flag == 0) {
116
- if (beforeDis_1[deep] == void 0)
117
- beforeDis_1[deep] = -0.5;
118
- if (beforeDis_1[deep - 1] == void 0)
119
- beforeDis_1[deep - 1] = -0.5;
120
- alltreedata[pNode.id].top = beforeDis_1[deep] + 1;
121
- var pTop = beforeDis_1[deep] + 1 + (alltreedata[pNode.pid].children.length - 1) * 0.5;
122
- if (pTop - 1 < beforeDis_1[deep - 1])
123
- alltreedata[pNode.id].top = beforeDis_1[deep - 1] + 1 - (alltreedata[pNode.pid].children.length - 1) * 0.5;
124
- }
125
- else {
126
- alltreedata[pNode.id].top = (alltreedata[pNode.children[0]].top + alltreedata[pNode.children[flag - 1]].top) * 0.5;
127
- }
128
- if (alltreedata[pNode.id].top <= beforeDis_1[deep]) {
129
- var needUp_1 = beforeDis_1[deep] + 1 - alltreedata[pNode.id].top(function doUp(_pid, _deep) {
130
- alltreedata[_pid].top += needUp_1;
131
- if (beforeDis_1[_deep] < alltreedata[_pid].top)
132
- beforeDis_1[_deep] = alltreedata[_pid].top;
133
- for (var _flag = 0; _flag < alltreedata[_pid].children.length; _flag++) {
134
- doUp(alltreedata[_pid].children[_flag], _deep + 1);
135
- }
136
- })(pNode.id, deep);
137
- }
138
- beforeDis_1[deep] = alltreedata[pNode.id].top;
139
- if (alltreedata[pNode.id].top + 0.5 > size_1)
140
- size_1 = alltreedata[pNode.id].top + 0.5;
141
- })(alltreedata[rootid], 0);
142
- }
143
- for (var key in noOpens) {
144
- if (noOpens[key]) {
145
- alltreedata[key].isOpen = false;
146
- (function updateHidden(pid, left, top) {
147
- for (var index = 0; index < alltreedata[pid].children.length; index++) {
148
- alltreedata[alltreedata[pid].children[index]].left = left;
149
- alltreedata[alltreedata[pid].children[index]].top = top;
150
- alltreedata[alltreedata[pid].children[index]].show = false;
151
- updateHidden(alltreedata[pid].children[index], left, top);
152
- }
153
- })(key, alltreedata[key].left, alltreedata[key].top);
154
- }
155
- }
156
- return {
157
- "node": alltreedata,
158
- "root": rootid,
159
- "size": size_1,
160
- "deep": maxDeep_1 + 1
161
- };
162
- }
81
+ function toPlainTree (initTree, config, noOpens) {
82
+ var treeData = toInnerTree(initTree, config);
83
+ var alltreedata = treeData.value;
84
+ var rootid = treeData.rid;
85
+ if (treeData.num == 1) {
86
+ alltreedata[rootid].left = 0.5;
87
+ alltreedata[rootid].top = 0.5;
88
+ alltreedata[rootid].show = true;
89
+ return {
90
+ deep: 1,
91
+ node: alltreedata,
92
+ root: rootid,
93
+ size: 1
94
+ };
95
+ }
96
+ else {
97
+ var beforeDis_1 = [];
98
+ var size_1 = 0, maxDeep_1 = 0;
99
+ if (noOpens[rootid]) {
100
+ alltreedata[rootid].left = 0.5;
101
+ alltreedata[rootid].top = 0.5;
102
+ alltreedata[rootid].show = true;
103
+ size_1 = 1;
104
+ }
105
+ else {
106
+ (function positionCalc(pNode, deep) {
107
+ if (deep > maxDeep_1)
108
+ maxDeep_1 = deep;
109
+ var flag = 0;
110
+ if (!noOpens[pNode.id]) {
111
+ for (flag = 0; flag < pNode.children.length; flag++)
112
+ positionCalc(alltreedata[pNode.children[flag]], deep + 1);
113
+ }
114
+ alltreedata[pNode.id].left = deep + 0.5;
115
+ if (flag == 0) {
116
+ if (beforeDis_1[deep] == void 0)
117
+ beforeDis_1[deep] = -0.5;
118
+ if (beforeDis_1[deep - 1] == void 0)
119
+ beforeDis_1[deep - 1] = -0.5;
120
+ alltreedata[pNode.id].top = beforeDis_1[deep] + 1;
121
+ var pTop = beforeDis_1[deep] + 1 + (alltreedata[pNode.pid].children.length - 1) * 0.5;
122
+ if (pTop - 1 < beforeDis_1[deep - 1])
123
+ alltreedata[pNode.id].top = beforeDis_1[deep - 1] + 1 - (alltreedata[pNode.pid].children.length - 1) * 0.5;
124
+ }
125
+ else {
126
+ alltreedata[pNode.id].top = (alltreedata[pNode.children[0]].top + alltreedata[pNode.children[flag - 1]].top) * 0.5;
127
+ }
128
+ if (alltreedata[pNode.id].top <= beforeDis_1[deep]) {
129
+ var needUp_1 = beforeDis_1[deep] + 1 - alltreedata[pNode.id].top(function doUp(_pid, _deep) {
130
+ alltreedata[_pid].top += needUp_1;
131
+ if (beforeDis_1[_deep] < alltreedata[_pid].top)
132
+ beforeDis_1[_deep] = alltreedata[_pid].top;
133
+ for (var _flag = 0; _flag < alltreedata[_pid].children.length; _flag++) {
134
+ doUp(alltreedata[_pid].children[_flag], _deep + 1);
135
+ }
136
+ })(pNode.id, deep);
137
+ }
138
+ beforeDis_1[deep] = alltreedata[pNode.id].top;
139
+ if (alltreedata[pNode.id].top + 0.5 > size_1)
140
+ size_1 = alltreedata[pNode.id].top + 0.5;
141
+ })(alltreedata[rootid], 0);
142
+ }
143
+ for (var key in noOpens) {
144
+ if (noOpens[key]) {
145
+ alltreedata[key].isOpen = false;
146
+ (function updateHidden(pid, left, top) {
147
+ for (var index = 0; index < alltreedata[pid].children.length; index++) {
148
+ alltreedata[alltreedata[pid].children[index]].left = left;
149
+ alltreedata[alltreedata[pid].children[index]].top = top;
150
+ alltreedata[alltreedata[pid].children[index]].show = false;
151
+ updateHidden(alltreedata[pid].children[index], left, top);
152
+ }
153
+ })(key, alltreedata[key].left, alltreedata[key].top);
154
+ }
155
+ }
156
+ return {
157
+ "node": alltreedata,
158
+ "root": rootid,
159
+ "size": size_1,
160
+ "deep": maxDeep_1 + 1
161
+ };
162
+ }
163
163
  }
164
164
 
165
- function initOption(setOption, defaultOption) {
166
- for (var key in setOption) {
167
- defaultOption[key] = setOption[key];
168
- }
169
- return defaultOption;
165
+ function initOption(setOption, defaultOption) {
166
+ for (var key in setOption) {
167
+ defaultOption[key] = setOption[key];
168
+ }
169
+ return defaultOption;
170
170
  }
171
171
 
172
- var Tree = (function () {
173
- function Tree(config) {
174
- if (config === void 0) { config = {}; }
175
- this.name = 'Tree';
176
- this.__config = initOption(config, {
177
- root: function (initTree) { return initTree; },
178
- children: function (parentTree) { return parentTree.children; },
179
- id: function (treedata) { return treedata.name; }
180
- });
181
- }
182
- Tree.prototype.use = function (initTree, noOpens) {
183
- if (noOpens === void 0) { noOpens = {}; }
184
- return toPlainTree(initTree, this.__config, noOpens);
185
- };
186
- return Tree;
172
+ var Tree = (function () {
173
+ function Tree(config) {
174
+ if (config === void 0) { config = {}; }
175
+ this.name = 'Tree';
176
+ this.__config = initOption(config, {
177
+ root: function (initTree) { return initTree; },
178
+ children: function (parentTree) { return parentTree.children; },
179
+ id: function (treedata) { return treedata.name; }
180
+ });
181
+ }
182
+ Tree.prototype.use = function (initTree, noOpens) {
183
+ if (noOpens === void 0) { noOpens = {}; }
184
+ return toPlainTree(initTree, this.__config, noOpens);
185
+ };
186
+ return Tree;
187
187
  }());
188
188
 
189
189
  /*!
@@ -296,168 +296,168 @@ function animation(doback, duration, callback) {
296
296
 
297
297
  }
298
298
 
299
- function rotate (cx, cy, deg, x, y) {
300
- var cos = Math.cos(deg), sin = Math.sin(deg);
301
- return [
302
- (x - cx) * cos - (y - cy) * sin + cx,
303
- (x - cx) * sin + (y - cy) * cos + cy
304
- ];
299
+ function rotate (cx, cy, deg, x, y) {
300
+ var cos = Math.cos(deg), sin = Math.sin(deg);
301
+ return [
302
+ (x - cx) * cos - (y - cy) * sin + cx,
303
+ (x - cx) * sin + (y - cy) * cos + cy
304
+ ];
305
305
  }
306
306
 
307
- var TreeLayout = (function (_super) {
308
- __extends(TreeLayout, _super);
309
- function TreeLayout() {
310
- var _this = _super !== null && _super.apply(this, arguments) || this;
311
- _this.name = 'TreeLayout';
312
- _this.__option = {
313
- offsetX: 0,
314
- offsetY: 0,
315
- duration: 500,
316
- type: "plain",
317
- direction: "LR",
318
- x: 100,
319
- y: 100,
320
- width: 100,
321
- height: 100,
322
- radius: 100
323
- };
324
- _this.__noOpens = {};
325
- return _this;
326
- }
327
- TreeLayout.prototype.setOption = function (option) {
328
- initOption(option, this.__option);
329
- return this;
330
- };
331
- TreeLayout.prototype.use = function (initTree, noOpens) {
332
- if (noOpens === void 0) { noOpens = {}; }
333
- var tree = _super.prototype.use.call(this, initTree, noOpens);
334
- if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
335
- for (var key in tree.node) {
336
- if (!tree.node[key].show) {
337
- var deep = 0, pid = key;
338
- do {
339
- pid = tree.node[pid].pid;
340
- deep++;
341
- } while (!tree.node[pid].show);
342
- tree.node[key].left += this.__option.offsetX * deep;
343
- tree.node[key].top += this.__option.offsetY * deep;
344
- }
345
- }
346
- }
347
- if (this.__option.type == 'rect') {
348
- if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
349
- var perW = this.__option.height / tree.size;
350
- var perD = this.__option.width / (tree.deep - 1);
351
- var balanceW = this.__option.y - this.__option.height * 0.5;
352
- var flag = this.__option.direction == 'LR' ? 1 : -1;
353
- for (var key in tree.node) {
354
- if (tree.deep == 1) {
355
- tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag;
356
- tree.node[key].top = this.__option.y;
357
- }
358
- else {
359
- tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag;
360
- tree.node[key].top = tree.node[key].top * perW + balanceW;
361
- }
362
- }
363
- }
364
- else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
365
- var perW = this.__option.width / tree.size;
366
- var perD = this.__option.height / (tree.deep - 1);
367
- var balanceW = this.__option.x - this.__option.width * 0.5;
368
- var flag = this.__option.direction == 'TB' ? 1 : -1;
369
- for (var key in tree.node) {
370
- tree.node[key].deg = this.__option.direction == 'TB' ? Math.PI * 0.5 : Math.PI * -0.5;
371
- if (tree.deep == 1) {
372
- tree.node[key].left = this.__option.x;
373
- tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag;
374
- }
375
- else {
376
- var left = tree.node[key].left;
377
- tree.node[key].left = tree.node[key].top * perW + balanceW;
378
- tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag;
379
- }
380
- }
381
- }
382
- }
383
- else if (this.__option.type == 'circle') {
384
- var cx = this.__option.x, cy = this.__option.y;
385
- var deg = Math.PI * 2 / tree.size;
386
- var per = this.__option.radius / (tree.deep - 1);
387
- for (var key in tree.node) {
388
- if (tree.node[key].left == 0.5) {
389
- tree.node[key].left = cx;
390
- tree.node[key].top = cy;
391
- }
392
- else {
393
- var position = rotate(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy);
394
- tree.node[key].deg = deg * tree.node[key].top;
395
- tree.node[key].left = position[0];
396
- tree.node[key].top = position[1];
397
- }
398
- }
399
- }
400
- return tree;
401
- };
402
- TreeLayout.prototype.bind = function (initTree, renderBack, noOpens) {
403
- if (noOpens === void 0) { noOpens = {}; }
404
- this.__rback = renderBack;
405
- this.__oralTree = initTree;
406
- this.__noOpens = noOpens;
407
- this.__preTree = this.use(this.__oralTree, this.__noOpens);
408
- this.__rback(this.__preTree);
409
- return this;
410
- };
411
- TreeLayout.prototype.unbind = function () {
412
- this.__rback = function () { return null; };
413
- this.__oralTree = null;
414
- this.__preTree = null;
415
- this.__noOpens = {};
416
- return this;
417
- };
418
- TreeLayout.prototype.doUpdate = function () {
419
- var _this = this;
420
- var newTree = this.use(this.__oralTree, this.__noOpens);
421
- var cacheTree = JSON.parse(JSON.stringify(newTree));
422
- animation(function (deep) {
423
- if (_this.__preTree) {
424
- for (var key in cacheTree.node) {
425
- if (newTree.node[key].show || _this.__preTree.node[key].show) {
426
- cacheTree.node[key].show = true;
427
- cacheTree.node[key].left = _this.__preTree.node[key].left + (newTree.node[key].left - _this.__preTree.node[key].left) * deep;
428
- cacheTree.node[key].top = _this.__preTree.node[key].top + (newTree.node[key].top - _this.__preTree.node[key].top) * deep;
429
- }
430
- }
431
- }
432
- _this.__rback(cacheTree);
433
- }, this.__option.duration, function () {
434
- _this.__preTree = newTree;
435
- _this.__rback(_this.__preTree);
436
- });
437
- return this;
438
- };
439
- TreeLayout.prototype.closeNode = function (id) {
440
- if (!this.__preTree)
441
- return this;
442
- this.__noOpens[id] = true;
443
- this.doUpdate();
444
- return this;
445
- };
446
- TreeLayout.prototype.openNode = function (id) {
447
- if (!this.__preTree)
448
- return this;
449
- this.__noOpens[id] = false;
450
- this.doUpdate();
451
- return this;
452
- };
453
- TreeLayout.prototype.toggleNode = function (id) {
454
- if (!this.__preTree)
455
- return this;
456
- this.__noOpens[id] = !this.__noOpens[id];
457
- this.doUpdate();
458
- return this;
459
- };
460
- return TreeLayout;
307
+ var TreeLayout = (function (_super) {
308
+ __extends(TreeLayout, _super);
309
+ function TreeLayout() {
310
+ var _this = _super !== null && _super.apply(this, arguments) || this;
311
+ _this.name = 'TreeLayout';
312
+ _this.__option = {
313
+ offsetX: 0,
314
+ offsetY: 0,
315
+ duration: 500,
316
+ type: "plain",
317
+ direction: "LR",
318
+ x: 100,
319
+ y: 100,
320
+ width: 100,
321
+ height: 100,
322
+ radius: 100
323
+ };
324
+ _this.__noOpens = {};
325
+ return _this;
326
+ }
327
+ TreeLayout.prototype.setOption = function (option) {
328
+ initOption(option, this.__option);
329
+ return this;
330
+ };
331
+ TreeLayout.prototype.use = function (initTree, noOpens) {
332
+ if (noOpens === void 0) { noOpens = {}; }
333
+ var tree = _super.prototype.use.call(this, initTree, noOpens);
334
+ if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
335
+ for (var key in tree.node) {
336
+ if (!tree.node[key].show) {
337
+ var deep = 0, pid = key;
338
+ do {
339
+ pid = tree.node[pid].pid;
340
+ deep++;
341
+ } while (!tree.node[pid].show);
342
+ tree.node[key].left += this.__option.offsetX * deep;
343
+ tree.node[key].top += this.__option.offsetY * deep;
344
+ }
345
+ }
346
+ }
347
+ if (this.__option.type == 'rect') {
348
+ if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
349
+ var perW = this.__option.height / tree.size;
350
+ var perD = this.__option.width / (tree.deep - 1);
351
+ var balanceW = this.__option.y - this.__option.height * 0.5;
352
+ var flag = this.__option.direction == 'LR' ? 1 : -1;
353
+ for (var key in tree.node) {
354
+ if (tree.deep == 1) {
355
+ tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag;
356
+ tree.node[key].top = this.__option.y;
357
+ }
358
+ else {
359
+ tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag;
360
+ tree.node[key].top = tree.node[key].top * perW + balanceW;
361
+ }
362
+ }
363
+ }
364
+ else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
365
+ var perW = this.__option.width / tree.size;
366
+ var perD = this.__option.height / (tree.deep - 1);
367
+ var balanceW = this.__option.x - this.__option.width * 0.5;
368
+ var flag = this.__option.direction == 'TB' ? 1 : -1;
369
+ for (var key in tree.node) {
370
+ tree.node[key].deg = this.__option.direction == 'TB' ? Math.PI * 0.5 : Math.PI * -0.5;
371
+ if (tree.deep == 1) {
372
+ tree.node[key].left = this.__option.x;
373
+ tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag;
374
+ }
375
+ else {
376
+ var left = tree.node[key].left;
377
+ tree.node[key].left = tree.node[key].top * perW + balanceW;
378
+ tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag;
379
+ }
380
+ }
381
+ }
382
+ }
383
+ else if (this.__option.type == 'circle') {
384
+ var cx = this.__option.x, cy = this.__option.y;
385
+ var deg = Math.PI * 2 / tree.size;
386
+ var per = this.__option.radius / (tree.deep - 1);
387
+ for (var key in tree.node) {
388
+ if (tree.node[key].left == 0.5) {
389
+ tree.node[key].left = cx;
390
+ tree.node[key].top = cy;
391
+ }
392
+ else {
393
+ var position = rotate(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy);
394
+ tree.node[key].deg = deg * tree.node[key].top;
395
+ tree.node[key].left = position[0];
396
+ tree.node[key].top = position[1];
397
+ }
398
+ }
399
+ }
400
+ return tree;
401
+ };
402
+ TreeLayout.prototype.bind = function (initTree, renderBack, noOpens) {
403
+ if (noOpens === void 0) { noOpens = {}; }
404
+ this.__rback = renderBack;
405
+ this.__oralTree = initTree;
406
+ this.__noOpens = noOpens;
407
+ this.__preTree = this.use(this.__oralTree, this.__noOpens);
408
+ this.__rback(this.__preTree);
409
+ return this;
410
+ };
411
+ TreeLayout.prototype.unbind = function () {
412
+ this.__rback = function () { return null; };
413
+ this.__oralTree = null;
414
+ this.__preTree = null;
415
+ this.__noOpens = {};
416
+ return this;
417
+ };
418
+ TreeLayout.prototype.doUpdate = function () {
419
+ var _this = this;
420
+ var newTree = this.use(this.__oralTree, this.__noOpens);
421
+ var cacheTree = JSON.parse(JSON.stringify(newTree));
422
+ animation(function (deep) {
423
+ if (_this.__preTree) {
424
+ for (var key in cacheTree.node) {
425
+ if (newTree.node[key].show || _this.__preTree.node[key].show) {
426
+ cacheTree.node[key].show = true;
427
+ cacheTree.node[key].left = _this.__preTree.node[key].left + (newTree.node[key].left - _this.__preTree.node[key].left) * deep;
428
+ cacheTree.node[key].top = _this.__preTree.node[key].top + (newTree.node[key].top - _this.__preTree.node[key].top) * deep;
429
+ }
430
+ }
431
+ }
432
+ _this.__rback(cacheTree);
433
+ }, this.__option.duration, function () {
434
+ _this.__preTree = newTree;
435
+ _this.__rback(_this.__preTree);
436
+ });
437
+ return this;
438
+ };
439
+ TreeLayout.prototype.closeNode = function (id) {
440
+ if (!this.__preTree)
441
+ return this;
442
+ this.__noOpens[id] = true;
443
+ this.doUpdate();
444
+ return this;
445
+ };
446
+ TreeLayout.prototype.openNode = function (id) {
447
+ if (!this.__preTree)
448
+ return this;
449
+ this.__noOpens[id] = false;
450
+ this.doUpdate();
451
+ return this;
452
+ };
453
+ TreeLayout.prototype.toggleNode = function (id) {
454
+ if (!this.__preTree)
455
+ return this;
456
+ this.__noOpens[id] = !this.__noOpens[id];
457
+ this.doUpdate();
458
+ return this;
459
+ };
460
+ return TreeLayout;
461
461
  }(Tree));
462
462
 
463
463
  export { TreeLayout as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * TreeLayout of VISLite JavaScript Library v1.4.0
2
+ * TreeLayout of VISLite JavaScript Library v1.5.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};"function"==typeof SuppressedError&&SuppressedError;function e(t,e){for(var o in t)e[o]=t[o];return e}var o,n=function(){function t(t){void 0===t&&(t={}),this.name="Tree",this.__config=e(t,{root:function(t){return t},children:function(t){return t.children},id:function(t){return t.name}})}return t.prototype.use=function(t,e){return void 0===e&&(e={}),function(t,e,o){var n=function(t,e){var o,n,i={},r=e.root(t);o=n=e.id(r),i[o]={data:r,pid:null,id:o,isOpen:!0,show:!0,deg:0,children:[]};var p=1;return function n(r,s){var h=e.children(r,t);p+=h?h.length:0;for(var _=0;h&&_<h.length;_++)o=e.id(h[_]),i[s].children.push(o),i[o]={data:h[_],pid:s,id:o,isOpen:!0,show:!0,deg:0,children:[]},n(h[_],o)}(r,o),{rid:n,value:i,num:p}}(t,e),i=n.value,r=n.rid;if(1==n.num)return i[r].left=.5,i[r].top=.5,i[r].show=!0,{deep:1,node:i,root:r,size:1};var p=[],s=0,h=0;for(var _ in o[r]?(i[r].left=.5,i[r].top=.5,i[r].show=!0,s=1):function t(e,n){n>h&&(h=n);var r=0;if(!o[e.id])for(r=0;r<e.children.length;r++)t(i[e.children[r]],n+1);if(i[e.id].left=n+.5,0==r?(null==p[n]&&(p[n]=-.5),null==p[n-1]&&(p[n-1]=-.5),i[e.id].top=p[n]+1,p[n]+1+.5*(i[e.pid].children.length-1)-1<p[n-1]&&(i[e.id].top=p[n-1]+1-.5*(i[e.pid].children.length-1))):i[e.id].top=.5*(i[e.children[0]].top+i[e.children[r-1]].top),i[e.id].top<=p[n])var _=p[n]+1-i[e.id].top((function t(e,o){i[e].top+=_,p[o]<i[e].top&&(p[o]=i[e].top);for(var n=0;n<i[e].children.length;n++)t(i[e].children[n],o+1)}))(e.id,n);p[n]=i[e.id].top,i[e.id].top+.5>s&&(s=i[e.id].top+.5)}(i[r],0),o)o[_]&&(i[_].isOpen=!1,function t(e,o,n){for(var r=0;r<i[e].children.length;r++)i[i[e].children[r]].left=o,i[i[e].children[r]].top=n,i[i[e].children[r]].show=!1,t(i[e].children[r],o,n)}(_,i[_].left,i[_].top));return{node:i,root:r,size:s,deep:h+1}}(t,this.__config,e)},t}(),i=[];
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of VISLite JavaScript Library v1.4.0
2
+ * animation of VISLite JavaScript Library v1.5.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  /*!
@@ -112,8 +112,8 @@ function animation(doback, duration, callback) {
112
112
 
113
113
  }
114
114
 
115
- function index (doback, duration, callback) {
116
- return animation(doback, duration || 400, callback || function () { }).stop;
115
+ function index (doback, duration, callback) {
116
+ return animation(doback, duration || 400, callback || function () { }).stop;
117
117
  }
118
118
 
119
119
  export { index as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of VISLite JavaScript Library v1.4.0
2
+ * animation of VISLite JavaScript Library v1.5.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  /*!