vislite 1.3.0 → 1.4.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.
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +307 -300
- package/LICENSE +20 -20
- package/README.md +284 -284
- package/lib/BarLayout/index.es.d.ts +3 -0
- package/lib/BarLayout/index.es.js +467 -0
- package/lib/BarLayout/index.es.min.d.ts +3 -0
- package/lib/BarLayout/index.es.min.js +10 -0
- package/lib/Buffer/index.es.js +35 -35
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +774 -774
- package/lib/Canvas/index.es.min.js +1 -1
- package/lib/Cardinal/index.es.js +90 -90
- package/lib/Cardinal/index.es.min.js +1 -1
- package/lib/Eoap/index.es.js +33 -33
- package/lib/Eoap/index.es.min.js +1 -1
- package/lib/Hermite/index.es.js +35 -35
- package/lib/Hermite/index.es.min.js +1 -1
- package/lib/MapCoordinate/index.es.js +199 -199
- package/lib/MapCoordinate/index.es.min.js +1 -1
- package/lib/Matrix4/index.es.js +124 -124
- package/lib/Matrix4/index.es.min.js +1 -1
- package/lib/Mercator/index.es.js +19 -19
- package/lib/Mercator/index.es.min.js +1 -1
- package/lib/PieLayout/index.es.d.ts +3 -0
- package/lib/PieLayout/index.es.js +234 -0
- package/lib/PieLayout/index.es.min.d.ts +3 -0
- package/lib/PieLayout/index.es.min.js +9 -0
- package/lib/RawCanvas/index.es.js +704 -704
- package/lib/RawCanvas/index.es.min.js +1 -1
- package/lib/SVG/index.es.js +514 -491
- package/lib/SVG/index.es.min.js +2 -2
- package/lib/Shader/index.es.js +35 -35
- package/lib/Shader/index.es.min.js +1 -1
- package/lib/Texture/index.es.js +53 -53
- package/lib/Texture/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +316 -309
- package/lib/TreeLayout/index.es.min.js +6 -2
- package/lib/animation/index.es.js +16 -9
- package/lib/animation/index.es.min.js +6 -2
- package/lib/assemble/index.es.js +17 -17
- package/lib/assemble/index.es.min.js +1 -1
- package/lib/getLoopColors/index.es.js +35 -35
- package/lib/getLoopColors/index.es.min.js +1 -1
- package/lib/getWebGLContext/index.es.js +62 -62
- package/lib/getWebGLContext/index.es.min.js +1 -1
- package/lib/index.umd.js +2675 -2327
- package/lib/index.umd.min.js +12 -2
- package/lib/initOption/index.es.js +6 -6
- package/lib/initOption/index.es.min.js +1 -1
- package/lib/mergeOption/index.es.js +34 -34
- package/lib/mergeOption/index.es.min.js +1 -1
- package/lib/move/index.es.js +7 -7
- package/lib/move/index.es.min.js +1 -1
- package/lib/rotate/index.es.js +7 -7
- package/lib/rotate/index.es.min.js +1 -1
- package/lib/ruler/index.es.js +137 -137
- package/lib/ruler/index.es.min.js +1 -1
- package/lib/scale/index.es.js +6 -6
- package/lib/scale/index.es.min.js +1 -1
- package/lib/throttle/index.es.js +7 -2
- package/lib/throttle/index.es.min.js +5 -1
- package/minialipay/ui-canvas/drawImage.js +35 -35
- package/minialipay/ui-canvas/index.acss +4 -4
- package/minialipay/ui-canvas/index.axml +3 -3
- package/minialipay/ui-canvas/index.d.ts +1 -1
- package/minialipay/ui-canvas/index.js +100 -100
- package/minialipay/ui-canvas/index.json +6 -6
- package/miniprogram/ui-canvas/drawImage.js +35 -35
- package/miniprogram/ui-canvas/index.js +117 -117
- package/miniprogram/ui-canvas/index.json +4 -4
- package/miniprogram/ui-canvas/index.wxml +4 -4
- package/miniprogram/ui-canvas/index.wxss +5 -5
- package/package/BarLayout/index.ts +3 -0
- package/package/Buffer/index.ts +2 -2
- package/package/Canvas/index.ts +2 -2
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/MapCoordinate/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/Mercator/index.ts +2 -2
- package/package/PieLayout/index.ts +3 -0
- package/package/RawCanvas/index.ts +2 -2
- package/package/SVG/index.ts +2 -2
- package/package/Shader/index.ts +2 -2
- package/package/Texture/index.ts +2 -2
- package/package/TreeLayout/index.ts +2 -2
- package/package/animation/index.ts +2 -2
- package/package/assemble/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/getWebGLContext/index.ts +40 -40
- package/package/index.ts +84 -80
- package/package/initOption/index.ts +2 -2
- package/package/mergeOption/index.ts +2 -2
- package/package/move/index.ts +2 -2
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package/scale/index.ts +2 -2
- package/package/throttle/index.ts +2 -2
- package/package.json +75 -75
- package/src/Canvas.ts +84 -84
- package/src/Eoap.ts +66 -66
- package/src/Matrix4/index.ts +84 -84
- package/src/Matrix4/move.ts +12 -12
- package/src/Matrix4/rotate.ts +15 -15
- package/src/Matrix4/scale.ts +11 -11
- package/src/Matrix4/transform.ts +64 -64
- package/src/Mercator.ts +27 -27
- package/src/SVG.ts +55 -24
- package/src/common/assemble.ts +22 -22
- package/src/common/canvas/arc.ts +51 -51
- package/src/common/canvas/config.ts +176 -176
- package/src/common/canvas/default.ts +64 -64
- package/src/common/canvas/gradient.ts +31 -31
- package/src/common/canvas/index.ts +188 -188
- package/src/common/canvas/painter.ts +443 -443
- package/src/common/canvas/texts.ts +18 -18
- package/src/common/map/getBoundary.ts +15 -15
- package/src/common/map/tool.ts +29 -29
- package/src/common/option.ts +29 -29
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +213 -213
- package/src/common/svg/default.ts +29 -29
- package/src/common/svg/gradient.ts +53 -53
- package/src/common/svg/index.ts +332 -332
- package/src/common/svg/tool.ts +51 -51
- package/src/common/tree/index.ts +25 -25
- package/src/common/tree/toInnerTree.ts +61 -61
- package/src/common/tree/toPlainTree.ts +135 -132
- package/src/common/type.ts +26 -26
- package/src/common/webgl/buffer.ts +79 -79
- package/src/common/webgl/getWebGLContext.ts +45 -45
- package/src/common/webgl/shader.ts +75 -75
- package/src/common/webgl/texture.ts +98 -97
- package/src/coordinate/MapCoordinate.ts +80 -80
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +110 -110
- package/src/interpolation/Hermite.ts +65 -65
- package/src/layout/BarLayout.ts +249 -0
- package/src/layout/PieLayout.ts +142 -0
- package/src/layout/TreeLayout.ts +197 -194
- package/src/move.ts +7 -7
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +209 -209
- package/src/scale.ts +6 -6
- package/types/Bar.d.ts +92 -0
- package/types/BarConfig.d.ts +5 -0
- package/types/BarLayout.d.ts +49 -0
- package/types/BarOption.d.ts +32 -0
- package/types/Buffer.d.ts +23 -23
- package/types/Canvas.d.ts +352 -352
- package/types/CanvasConfig.d.ts +88 -88
- package/types/CanvasOption.d.ts +8 -8
- package/types/CanvasOpts.d.ts +9 -9
- package/types/Cardinal.d.ts +13 -13
- package/types/Gradient.d.ts +14 -14
- package/types/Hermite.d.ts +18 -18
- package/types/Map.d.ts +9 -9
- package/types/MapConfig.d.ts +27 -27
- package/types/MapCoordinate.d.ts +22 -22
- package/types/Matrix4.d.ts +47 -47
- package/types/Pie.d.ts +74 -0
- package/types/PieConfig.d.ts +27 -0
- package/types/PieLayout.d.ts +41 -0
- package/types/PieOption.d.ts +22 -0
- package/types/SVG.d.ts +247 -243
- package/types/SVGConfig.d.ts +71 -71
- package/types/Shader.d.ts +16 -16
- package/types/Texture.d.ts +16 -16
- package/types/Tree.d.ts +74 -74
- package/types/TreeConfig.d.ts +36 -36
- package/types/TreeLayout.d.ts +59 -59
- package/types/TreeOption.d.ts +48 -48
- package/types/animation.d.ts +5 -5
- package/types/assemble.d.ts +5 -5
- package/types/getLoopColors.d.ts +5 -5
- package/types/getWebGLContext.d.ts +7 -7
- package/types/index.d.ts +195 -179
- package/types/move.d.ts +5 -5
- package/types/option.d.ts +12 -12
- package/types/painterConfig.d.ts +4 -4
- package/types/rotate.d.ts +5 -5
- package/types/ruler.d.ts +10 -10
- package/types/scale.d.ts +5 -5
- package/types/throttle.d.ts +5 -5
- package/types/throttleOption.d.ts +1 -1
- package/types/ui-canvas.d.ts +4 -4
- package/types/uni-canvas.d.ts +3 -3
- package/uni-app/drawImage.js +19 -19
- package/uni-app/ui-canvas.vue +284 -284
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* TreeLayout of VISLite JavaScript Library v1.
|
|
2
|
+
* TreeLayout of VISLite JavaScript Library v1.4.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
/******************************************************************************
|
|
@@ -38,154 +38,159 @@ 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
|
+
/*!
|
|
190
|
+
* animation of OIPage v1.2.0
|
|
191
|
+
* git+https://github.com/oi-contrib/OIPage.git
|
|
192
|
+
*/
|
|
193
|
+
|
|
189
194
|
//当前正在运动的动画的tick函数堆栈
|
|
190
195
|
var $timers = [];
|
|
191
196
|
//唯一定时器的定时间隔
|
|
@@ -275,182 +280,184 @@ function animation(doback, duration, callback) {
|
|
|
275
280
|
doback(deep);
|
|
276
281
|
}, duration, callback);
|
|
277
282
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
$timers[i].id
|
|
285
|
-
|
|
283
|
+
return {
|
|
284
|
+
// 一个函数
|
|
285
|
+
// 用于在动画结束前结束动画
|
|
286
|
+
stop: function () {
|
|
287
|
+
var i;
|
|
288
|
+
for (i in $timers) {
|
|
289
|
+
if ($timers[i].id == id) {
|
|
290
|
+
$timers[i].id = void 0;
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
286
293
|
}
|
|
287
294
|
}
|
|
288
295
|
};
|
|
289
296
|
|
|
290
297
|
}
|
|
291
298
|
|
|
292
|
-
function rotate (cx, cy, deg, x, y) {
|
|
293
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
294
|
-
return [
|
|
295
|
-
(x - cx) * cos - (y - cy) * sin + cx,
|
|
296
|
-
(x - cx) * sin + (y - cy) * cos + cy
|
|
297
|
-
];
|
|
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
|
+
];
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
var TreeLayout = (function (_super) {
|
|
301
|
-
__extends(TreeLayout, _super);
|
|
302
|
-
function TreeLayout() {
|
|
303
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
304
|
-
_this.name = 'TreeLayout';
|
|
305
|
-
_this.__option = {
|
|
306
|
-
offsetX: 0,
|
|
307
|
-
offsetY: 0,
|
|
308
|
-
duration: 500,
|
|
309
|
-
type: "plain",
|
|
310
|
-
direction: "LR",
|
|
311
|
-
x: 100,
|
|
312
|
-
y: 100,
|
|
313
|
-
width: 100,
|
|
314
|
-
height: 100,
|
|
315
|
-
radius: 100
|
|
316
|
-
};
|
|
317
|
-
_this.__noOpens = {};
|
|
318
|
-
return _this;
|
|
319
|
-
}
|
|
320
|
-
TreeLayout.prototype.setOption = function (option) {
|
|
321
|
-
initOption(option, this.__option);
|
|
322
|
-
return this;
|
|
323
|
-
};
|
|
324
|
-
TreeLayout.prototype.use = function (initTree, noOpens) {
|
|
325
|
-
if (noOpens === void 0) { noOpens = {}; }
|
|
326
|
-
var tree = _super.prototype.use.call(this, initTree, noOpens);
|
|
327
|
-
if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
|
|
328
|
-
for (var key in tree.node) {
|
|
329
|
-
if (!tree.node[key].show) {
|
|
330
|
-
var deep = 0, pid = key;
|
|
331
|
-
do {
|
|
332
|
-
pid = tree.node[pid].pid;
|
|
333
|
-
deep++;
|
|
334
|
-
} while (!tree.node[pid].show);
|
|
335
|
-
tree.node[key].left += this.__option.offsetX * deep;
|
|
336
|
-
tree.node[key].top += this.__option.offsetY * deep;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (this.__option.type == 'rect') {
|
|
341
|
-
if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
|
|
342
|
-
var perW = this.__option.height / tree.size;
|
|
343
|
-
var perD = this.__option.width / (tree.deep - 1);
|
|
344
|
-
var balanceW = this.__option.y - this.__option.height * 0.5;
|
|
345
|
-
var flag = this.__option.direction == 'LR' ? 1 : -1;
|
|
346
|
-
for (var key in tree.node) {
|
|
347
|
-
if (tree.deep == 1) {
|
|
348
|
-
tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag;
|
|
349
|
-
tree.node[key].top = this.__option.y;
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag;
|
|
353
|
-
tree.node[key].top = tree.node[key].top * perW + balanceW;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
|
|
358
|
-
var perW = this.__option.width / tree.size;
|
|
359
|
-
var perD = this.__option.height / (tree.deep - 1);
|
|
360
|
-
var balanceW = this.__option.x - this.__option.width * 0.5;
|
|
361
|
-
var flag = this.__option.direction == 'TB' ? 1 : -1;
|
|
362
|
-
for (var key in tree.node) {
|
|
363
|
-
tree.node[key].deg = this.__option.direction == 'TB' ? Math.PI * 0.5 : Math.PI * -0.5;
|
|
364
|
-
if (tree.deep == 1) {
|
|
365
|
-
tree.node[key].left = this.__option.x;
|
|
366
|
-
tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag;
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
var left = tree.node[key].left;
|
|
370
|
-
tree.node[key].left = tree.node[key].top * perW + balanceW;
|
|
371
|
-
tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
else if (this.__option.type == 'circle') {
|
|
377
|
-
var cx = this.__option.x, cy = this.__option.y;
|
|
378
|
-
var deg = Math.PI * 2 / tree.size;
|
|
379
|
-
var per = this.__option.radius / (tree.deep - 1);
|
|
380
|
-
for (var key in tree.node) {
|
|
381
|
-
if (tree.node[key].left == 0.5) {
|
|
382
|
-
tree.node[key].left = cx;
|
|
383
|
-
tree.node[key].top = cy;
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
var position = rotate(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy);
|
|
387
|
-
tree.node[key].deg = deg * tree.node[key].top;
|
|
388
|
-
tree.node[key].left = position[0];
|
|
389
|
-
tree.node[key].top = position[1];
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return tree;
|
|
394
|
-
};
|
|
395
|
-
TreeLayout.prototype.bind = function (initTree, renderBack, noOpens) {
|
|
396
|
-
if (noOpens === void 0) { noOpens = {}; }
|
|
397
|
-
this.__rback = renderBack;
|
|
398
|
-
this.__oralTree = initTree;
|
|
399
|
-
this.__noOpens = noOpens;
|
|
400
|
-
this.__preTree = this.use(this.__oralTree, this.__noOpens);
|
|
401
|
-
this.__rback(this.__preTree);
|
|
402
|
-
return this;
|
|
403
|
-
};
|
|
404
|
-
TreeLayout.prototype.unbind = function () {
|
|
405
|
-
this.__rback = function () { return null; };
|
|
406
|
-
this.__oralTree = null;
|
|
407
|
-
this.__preTree = null;
|
|
408
|
-
this.__noOpens = {};
|
|
409
|
-
return this;
|
|
410
|
-
};
|
|
411
|
-
TreeLayout.prototype.doUpdate = function () {
|
|
412
|
-
var _this = this;
|
|
413
|
-
var newTree = this.use(this.__oralTree, this.__noOpens);
|
|
414
|
-
var cacheTree = JSON.parse(JSON.stringify(newTree));
|
|
415
|
-
animation(function (deep) {
|
|
416
|
-
if (_this.__preTree) {
|
|
417
|
-
for (var key in cacheTree.node) {
|
|
418
|
-
if (newTree.node[key].show || _this.__preTree.node[key].show) {
|
|
419
|
-
cacheTree.node[key].show = true;
|
|
420
|
-
cacheTree.node[key].left = _this.__preTree.node[key].left + (newTree.node[key].left - _this.__preTree.node[key].left) * deep;
|
|
421
|
-
cacheTree.node[key].top = _this.__preTree.node[key].top + (newTree.node[key].top - _this.__preTree.node[key].top) * deep;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
_this.__rback(cacheTree);
|
|
426
|
-
}, this.__option.duration, function () {
|
|
427
|
-
_this.__preTree = newTree;
|
|
428
|
-
_this.__rback(_this.__preTree);
|
|
429
|
-
});
|
|
430
|
-
return this;
|
|
431
|
-
};
|
|
432
|
-
TreeLayout.prototype.closeNode = function (id) {
|
|
433
|
-
if (!this.__preTree)
|
|
434
|
-
return this;
|
|
435
|
-
this.__noOpens[id] = true;
|
|
436
|
-
this.doUpdate();
|
|
437
|
-
return this;
|
|
438
|
-
};
|
|
439
|
-
TreeLayout.prototype.openNode = function (id) {
|
|
440
|
-
if (!this.__preTree)
|
|
441
|
-
return this;
|
|
442
|
-
this.__noOpens[id] = false;
|
|
443
|
-
this.doUpdate();
|
|
444
|
-
return this;
|
|
445
|
-
};
|
|
446
|
-
TreeLayout.prototype.toggleNode = function (id) {
|
|
447
|
-
if (!this.__preTree)
|
|
448
|
-
return this;
|
|
449
|
-
this.__noOpens[id] = !this.__noOpens[id];
|
|
450
|
-
this.doUpdate();
|
|
451
|
-
return this;
|
|
452
|
-
};
|
|
453
|
-
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;
|
|
454
461
|
}(Tree));
|
|
455
462
|
|
|
456
463
|
export { TreeLayout as default };
|