vislite 1.10.0 → 1.11.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/CHANGELOG +6 -0
- package/README-en.md +249 -0
- package/README.md +2 -0
- package/lib/BarLayout/index.es.js +38 -9
- package/lib/BarLayout/index.es.min.js +1 -1
- package/lib/PieLayout/index.es.js +38 -9
- package/lib/PieLayout/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +38 -9
- package/lib/TreeLayout/index.es.min.js +1 -1
- package/lib/animation/index.es.js +38 -9
- package/lib/animation/index.es.min.js +1 -1
- package/lib/index.umd.js +39 -10
- package/lib/index.umd.min.js +2 -2
- package/package.json +3 -3
- package/skills/vislite-lib/BarLayout.md +118 -0
- package/skills/vislite-lib/Canvas.md +184 -0
- package/skills/vislite-lib/Interpolation.md +130 -0
- package/skills/vislite-lib/Matrix.md +175 -0
- package/skills/vislite-lib/PieLayout.md +132 -0
- package/skills/vislite-lib/Projections.md +159 -0
- package/skills/vislite-lib/SKILL.md +176 -0
- package/skills/vislite-lib/SVG.md +138 -0
- package/skills/vislite-lib/TreeLayout.md +177 -0
- package/skills/vislite-lib/Utilities.md +177 -0
- package/skills/vislite-lib/WebGL.md +107 -0
- package/skills/vislite-lib/minialipay/ui-canvas.md +96 -0
- package/skills/vislite-lib/miniprogram/ui-canvas.md +99 -0
- package/skills/vislite-lib/uniapp/ui-canvas.md +114 -0
package/CHANGELOG
CHANGED
package/README-en.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
**English** · [中文](./README.md) · [📖 Online Docs](https://oi-contrib.github.io/VISLite)
|
|
2
|
+
|
|
3
|
+
- 💘 Open source is not easy, please <i>[Give a Star on Github](https://github.com/oi-contrib/VISLite) </i>!
|
|
4
|
+
|
|
5
|
+
<img src='https://oi-contrib.github.io/VISLite/images/logo.png' height='300px'/>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=vislite&interval=7">
|
|
9
|
+
<img src="https://img.shields.io/npm/dm/vislite.svg" alt="downloads">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/vislite">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/vislite.svg" alt="npm">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://www.jsdelivr.com/package/npm/vislite">
|
|
15
|
+
<img src="https://data.jsdelivr.com/v1/package/npm/vislite/badge" alt="cdn">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/oi-contrib/VISLite/issues">
|
|
18
|
+
<img src="https://img.shields.io/github/issues/oi-contrib/VISLite" alt="issue">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://github.com/oi-contrib/VISLite" target='_blank'>
|
|
21
|
+
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/oi-contrib/VISLite">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://github.com/oi-contrib/VISLite">
|
|
24
|
+
<img src="https://img.shields.io/github/forks/oi-contrib/VISLite" alt="forks">
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://gitee.com/oi-contrib/VISLite" target='_blank'>
|
|
27
|
+
<img alt="Gitee repo stars" src="https://gitee.com/oi-contrib/VISLite/badge/star.svg">
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://gitee.com/oi-contrib/VISLite">
|
|
30
|
+
<img src="https://gitee.com/oi-contrib/VISLite/badge/fork.svg" alt="forks">
|
|
31
|
+
</a>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<img src="https://nodei.co/npm/vislite.png?downloads=true&downloadRank=true&stars=true" alt="NPM">
|
|
35
|
+
|
|
36
|
+
# VISLite
|
|
37
|
+
|
|
38
|
+
🚀 A lightweight and elegant cross-platform data visualization solution
|
|
39
|
+
|
|
40
|
+
`VISLite` is a high-performance visualization library built with `TypeScript`. Official website: [https://oi-contrib.github.io/VISLite](https://oi-contrib.github.io/VISLite)
|
|
41
|
+
|
|
42
|
+
It provides unified cross-platform canvas drawing and computing capabilities, allowing developers to focus on business logic and easily implement visualization applications across Web, uni-app, WeChat Mini Program, Alipay Mini Program and other platforms. Except for minor platform differences in initialization configuration, the core business code is completely universal.
|
|
43
|
+
|
|
44
|
+
## Introduction
|
|
45
|
+
|
|
46
|
+
🎯 Lightweight data visualization development library —— Help you build visualization products faster, simpler and more efficiently.
|
|
47
|
+
|
|
48
|
+
> This project has been open sourced on [Open Source China](https://www.oschina.net/p/vislite), welcome to follow and leave comments.
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
### 📦 Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install --save vislite
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 🖼️ Prepare Canvas
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<div id="root" style="width:500px;height:300px;"></div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 🎨 Start Drawing
|
|
65
|
+
|
|
66
|
+
Get the painter to draw any content you need. For example, get the Canvas painter to draw a red circle:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import { Canvas } from 'vislite';
|
|
70
|
+
|
|
71
|
+
var painter = new Canvas(document.getElementById('root'));
|
|
72
|
+
|
|
73
|
+
painter.config({
|
|
74
|
+
fillStyle: "red"
|
|
75
|
+
}).fillCircle(200, 150, 100);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
More complex charts? We provide rich auxiliary APIs. Take tree layout as an example, you can draw a tree diagram in just a few steps:
|
|
79
|
+
|
|
80
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/tree.png" width="500"/>
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import { Canvas, TreeLayout } from 'vislite';
|
|
84
|
+
|
|
85
|
+
var painter = new Canvas(document.getElementById('root'));
|
|
86
|
+
var treeLayout = new TreeLayout();
|
|
87
|
+
|
|
88
|
+
treeLayout.setOption({
|
|
89
|
+
type: "rect",
|
|
90
|
+
direction: "TB",
|
|
91
|
+
x: 250,
|
|
92
|
+
y: 20,
|
|
93
|
+
width: 500,
|
|
94
|
+
height: 260
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
var data = {
|
|
98
|
+
"name": "Frontend",
|
|
99
|
+
"children": [{
|
|
100
|
+
"name": "Basic",
|
|
101
|
+
"children": [{
|
|
102
|
+
"name": "HTML"
|
|
103
|
+
}, {
|
|
104
|
+
"name": "CSS"
|
|
105
|
+
}, {
|
|
106
|
+
"name": "JavaScript"
|
|
107
|
+
}, {
|
|
108
|
+
"name": "DOM"
|
|
109
|
+
}]
|
|
110
|
+
}, {
|
|
111
|
+
"name": "Framework"
|
|
112
|
+
}, {
|
|
113
|
+
"name": "Techniques"
|
|
114
|
+
}]
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var tree = treeLayout.use(data);
|
|
118
|
+
|
|
119
|
+
// Draw connections
|
|
120
|
+
painter.config({
|
|
121
|
+
strokeStyle: 'red'
|
|
122
|
+
});
|
|
123
|
+
for (var key in tree.node) {
|
|
124
|
+
var pid = tree.node[key].pid;
|
|
125
|
+
|
|
126
|
+
if (pid) {
|
|
127
|
+
var dist = (tree.node[key].top - tree.node[pid].top) * 0.5;
|
|
128
|
+
|
|
129
|
+
painter
|
|
130
|
+
.beginPath()
|
|
131
|
+
.moveTo(tree.node[key].left, tree.node[key].top)
|
|
132
|
+
.bezierCurveTo(
|
|
133
|
+
tree.node[key].left, tree.node[key].top - dist,
|
|
134
|
+
tree.node[pid].left, tree.node[pid].top + dist,
|
|
135
|
+
tree.node[pid].left, tree.node[pid].top
|
|
136
|
+
).stroke();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Draw nodes and text
|
|
141
|
+
painter.config({
|
|
142
|
+
strokeStyle: 'red',
|
|
143
|
+
fontSize: 12
|
|
144
|
+
});
|
|
145
|
+
for (var key in tree.node) {
|
|
146
|
+
painter.config({
|
|
147
|
+
fillStyle: "white"
|
|
148
|
+
}).fullCircle(tree.node[key].left, tree.node[key].top, 10);
|
|
149
|
+
|
|
150
|
+
painter.config({
|
|
151
|
+
fillStyle: "black"
|
|
152
|
+
}).fillText(key, tree.node[key].left + 15, tree.node[key].top);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For detailed usage of tree layout, please refer to: [《Tutorial / Tree Layout》](https://oi-contrib.github.io/VISLite/#/course/tree-layout)
|
|
157
|
+
|
|
158
|
+
## Core Features
|
|
159
|
+
|
|
160
|
+
### 🧮 Visualization Algorithm Library
|
|
161
|
+
|
|
162
|
+
We have encapsulated commonly used algorithms in visualization development to help you easily draw complex charts. Through simple configuration, you can convert any format of data into drawing data with coordinates:
|
|
163
|
+
|
|
164
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/what_1.png" width="400"/>
|
|
165
|
+
|
|
166
|
+
> Demo: [Left-to-right Tree Diagram](https://oi-contrib.github.io/VISLite/#/example/canvas/tree-layout-lr)
|
|
167
|
+
|
|
168
|
+
In addition to [Tree Layout](https://oi-contrib.github.io/VISLite/#/api/treeLayout), we also provide: [Ruler Algorithm](https://oi-contrib.github.io/VISLite/#/api/ruler), [Equirectangular Oblique Azimuthal Projection](https://oi-contrib.github.io/VISLite/#/api/eoap), [Mercator Projection](https://oi-contrib.github.io/VISLite/#/api/mercator), [Interpolation Function](https://oi-contrib.github.io/VISLite/#/api/cardinal), [Transformation Matrix](https://oi-contrib.github.io/VISLite/#/api/matrix4), etc.
|
|
169
|
+
|
|
170
|
+
### 🖌️ Enhanced Painter
|
|
171
|
+
|
|
172
|
+
The painter has been carefully designed to be simpler to use and more powerful. Taking Canvas as an example, we abstract the concept of "region", so that no matter how irregular the shape is, you can easily implement interactions:
|
|
173
|
+
|
|
174
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/what_2.png" width="400"/>
|
|
175
|
+
|
|
176
|
+
> Demo: [China Map](https://oi-contrib.github.io/VISLite/#/example/canvas/china)
|
|
177
|
+
|
|
178
|
+
The painter not only designs regions for interaction, but also elegantly encapsulates native APIs with more user-friendly and intuitive interfaces (e.g., WebGL makes 3D development zero-threshold, SVG eliminates the need to memorize obscure attributes). It also automatically eliminates browser compatibility differences.
|
|
179
|
+
|
|
180
|
+
### 📱 Cross-platform Support
|
|
181
|
+
|
|
182
|
+
In addition to Web, it also supports uni-app, WeChat Mini Program, Alipay Mini Program and other platforms with unified APIs, greatly improving code reuse:
|
|
183
|
+
|
|
184
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/what_3.png" width="600"/>
|
|
185
|
+
|
|
186
|
+
> Demo: [Money Wave Ball](https://oi-contrib.github.io/VISLite/#/example/svg/money-schedule)
|
|
187
|
+
|
|
188
|
+
Currently `Canvas` supports: Web, native WeChat Mini Program, native Alipay Mini Program, uni-app (compiled to H5, WeChat Mini Program, Alipay Mini Program, etc.). We will continue to expand more platforms and painter types in the future.
|
|
189
|
+
|
|
190
|
+
## Core Advantages
|
|
191
|
+
|
|
192
|
+
- **Flexible import methods**: Supports ES Module / CommonJS import after npm installation, as well as script tag CDN method
|
|
193
|
+
- **On-demand loading**: TS source import, on-demand JS import or full import, multiple modes to choose from
|
|
194
|
+
- **Simplicity and power coexist**: Provides basic visualization components that can be freely combined, and also supports encapsulation solutions for common scenarios
|
|
195
|
+
- **Stable and reliable**: Fully backward compatible within the same major version (except alpha and beta versions), always keep the latest version as the best choice
|
|
196
|
+
|
|
197
|
+
> Version specification: alpha (development version) → beta (testing version) → rc (release candidate) → next (pre-release version) → official release
|
|
198
|
+
|
|
199
|
+
## Feedback
|
|
200
|
+
|
|
201
|
+
We are committed to continuously improving visualization functions and look forward to your valuable suggestions! Welcome to communicate with us through [Issues](https://github.com/oi-contrib/VISLite/issues).
|
|
202
|
+
|
|
203
|
+
All suggestions will be responded to within one week.
|
|
204
|
+
|
|
205
|
+
## Changelog
|
|
206
|
+
|
|
207
|
+
See [CHANGELOG](./CHANGELOG) for details, updated after each official version release.
|
|
208
|
+
|
|
209
|
+
## Roadmap
|
|
210
|
+
|
|
211
|
+
Recent work focus:
|
|
212
|
+
|
|
213
|
+
- Provide commonly used coordinate systems and layout components to accelerate development
|
|
214
|
+
- Continuously optimize documentation (improve readability, enrich examples, improve tutorials)
|
|
215
|
+
|
|
216
|
+
Want a feature? [Tell us](https://github.com/oi-contrib/VISLite/issues) and we'll prioritize it!
|
|
217
|
+
|
|
218
|
+
## Contribution Guide
|
|
219
|
+
|
|
220
|
+
Welcome to participate in the project through the following ways:
|
|
221
|
+
|
|
222
|
+
- **Code maintenance**: Handle new feature development and Bug fixes
|
|
223
|
+
- **Documentation improvement**: Write and optimize interface documentation and tutorials
|
|
224
|
+
- **Test cases**: Supplement test cases in the test directory and examples in the docs directory
|
|
225
|
+
- **Direction discussion**: Participate in discussions on the future development of the project
|
|
226
|
+
|
|
227
|
+
Interested in joining? Please contact us through [issue](https://github.com/oi-contrib/VISLite/issues), please briefly describe the situation, and we will reply as soon as possible.
|
|
228
|
+
|
|
229
|
+
See [VISLite Contribution Guide](./.github/CONTRIBUTING.md) and [AUTHORS.txt](./AUTHORS.txt)
|
|
230
|
+
|
|
231
|
+
## Example Projects
|
|
232
|
+
|
|
233
|
+
Examples developed based on VISLite and related plugins (such as [@vislite/canvas](https://github.com/oi-contrib/vislite-plugin-canvas), [@vislite/chart](https://github.com/oi-contrib/vislite-plugin-chart)):
|
|
234
|
+
|
|
235
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/examples/review1.png" style="width:700px;border:2px solid black;margin-bottom:20px;"/>
|
|
236
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/examples/review2.png" style="width:700px;border:2px solid black;margin-bottom:20px;"/>
|
|
237
|
+
<img src="https://oi-contrib.github.io/VISLite/images/docs/examples/review3.png" style="width:300px;border:2px solid black;margin-bottom:20px;"/>
|
|
238
|
+
|
|
239
|
+
For more examples, please visit: [VISLite Example Projects](https://rapid-start.github.io/VISLite-examples/index.html)
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
MIT License
|
|
244
|
+
|
|
245
|
+
<<<<<<< HEAD
|
|
246
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) Step By Step
|
|
247
|
+
=======
|
|
248
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) Step By Step
|
|
249
|
+
>>>>>>> dev
|
package/README.md
CHANGED
|
@@ -171,7 +171,10 @@ function animation(doback, duration, callback) {
|
|
|
171
171
|
let id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
172
172
|
$timers.push({
|
|
173
173
|
"id": id,
|
|
174
|
-
"createTime": new Date(),
|
|
174
|
+
"createTime": new Date(), // 开始时间
|
|
175
|
+
"pauseTime": -1, // 暂停的时间,继续运行的时候,借助此计算暂停的时间差
|
|
176
|
+
"pauseKeepTime": 0, // 暂停用去的时间
|
|
177
|
+
"status": "running", // running(运行中), paused(暂停中)
|
|
175
178
|
"tick": tick,
|
|
176
179
|
"duration": duration,
|
|
177
180
|
"callback": callback
|
|
@@ -214,15 +217,21 @@ function animation(doback, duration, callback) {
|
|
|
214
217
|
callback = timer.callback;
|
|
215
218
|
|
|
216
219
|
//执行
|
|
217
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
220
|
+
passTime = (+new Date().valueOf() - createTime.valueOf() - timer.pauseKeepTime) / duration;
|
|
218
221
|
passTime = passTime > 1 ? 1 : passTime;
|
|
219
|
-
|
|
220
|
-
if (
|
|
222
|
+
|
|
223
|
+
if (timer.status === "running") {
|
|
224
|
+
tick(passTime);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 只有当动画没有结束或者动画处于暂停状态时,才继续添加到timers堆栈
|
|
228
|
+
if ((passTime < 1 || timer.status === "paused") && timer.id) {
|
|
221
229
|
//动画没有结束再添加
|
|
222
230
|
$timers.push(timer);
|
|
223
231
|
} else {
|
|
224
232
|
callback(passTime);
|
|
225
233
|
}
|
|
234
|
+
|
|
226
235
|
}
|
|
227
236
|
if ($timers.length <= 0) {
|
|
228
237
|
clock.stop();
|
|
@@ -249,14 +258,34 @@ function animation(doback, duration, callback) {
|
|
|
249
258
|
}, duration, callback);
|
|
250
259
|
|
|
251
260
|
return {
|
|
252
|
-
//
|
|
253
|
-
// 用于在动画结束前结束动画
|
|
261
|
+
// 结束动画
|
|
254
262
|
stop: function () {
|
|
255
|
-
let i
|
|
256
|
-
for (i in $timers) {
|
|
263
|
+
for (let i in $timers) {
|
|
257
264
|
if ($timers[i].id == id) {
|
|
258
265
|
$timers[i].id = void 0;
|
|
259
|
-
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
// 暂停动画
|
|
270
|
+
pause: function () {
|
|
271
|
+
for (let i in $timers) {
|
|
272
|
+
if ($timers[i].id == id) {
|
|
273
|
+
if ($timers[i].pauseTime === -1) {
|
|
274
|
+
$timers[i].pauseTime = new Date();
|
|
275
|
+
$timers[i].status = "paused";
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
// 继续动画
|
|
281
|
+
resume: function () {
|
|
282
|
+
for (let i in $timers) {
|
|
283
|
+
if ($timers[i].id == id) {
|
|
284
|
+
if ($timers[i].pauseTime !== -1) {
|
|
285
|
+
$timers[i].pauseKeepTime += (new Date().valueOf() - $timers[i].pauseTime.valueOf());
|
|
286
|
+
$timers[i].pauseTime = -1;
|
|
287
|
+
$timers[i].status = "running";
|
|
288
|
+
}
|
|
260
289
|
}
|
|
261
290
|
}
|
|
262
291
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,i){for(var a in t)i[a]=t[a];return i}let i,a=[];var e=function(){function e(i){void 0===i&&(i={}),this.name="BarLayout",this.__option={x:50,y:350,width:400,height:300,category:"xAxis",duration:200},this.__config=t(i,{})}return e.prototype.setOption=function(i){return t(i,this.__option),this},e.prototype.use=function(t){var i={coordinate:{x:this.__option.x,y:this.__option.y,width:this.__option.width,height:this.__option.height,xAxis:{type:"xAxis"===this.__option.category?"category":"value",data:[]},yAxis:{type:"xAxis"===this.__option.category?"value":"category",data:[]}},node:[]},a=void 0,e=void 0;if(t.data)for(var n=0,r=t.data;n<r.length;n++){var o=r[n];(void 0===a||o>a)&&(a=o),(void 0===e||o<e)&&(e=o)}else{if(!t.value)throw new Error("No data leads to parsing errors");for(var h=0,
|
|
1
|
+
function t(t,i){for(var a in t)i[a]=t[a];return i}let i,a=[];var e=function(){function e(i){void 0===i&&(i={}),this.name="BarLayout",this.__option={x:50,y:350,width:400,height:300,category:"xAxis",duration:200},this.__config=t(i,{})}return e.prototype.setOption=function(i){return t(i,this.__option),this},e.prototype.use=function(t){var i={coordinate:{x:this.__option.x,y:this.__option.y,width:this.__option.width,height:this.__option.height,xAxis:{type:"xAxis"===this.__option.category?"category":"value",data:[]},yAxis:{type:"xAxis"===this.__option.category?"value":"category",data:[]}},node:[]},a=void 0,e=void 0;if(t.data)for(var n=0,r=t.data;n<r.length;n++){var o=r[n];(void 0===a||o>a)&&(a=o),(void 0===e||o<e)&&(e=o)}else{if(!t.value)throw new Error("No data leads to parsing errors");for(var h=0,s=t.value;h<s.length;h++)for(var u=0,l=s[h].data;u<l.length;u++){o=l[u];(void 0===a||o>a)&&(a=o),(void 0===e||o<e)&&(e=o)}}var _,d,p=function(t,i,a,e){if(t<i){var n=i;i=t,t=n}else if(t==i)return[t];var r=function(t){for(var i=t<100&&t>-100?10:.1,a=-1,e=t;10==i?e>=-100&&e<=100:e<=-100||e>=100;)a+=1,e*=i;if(10==i)return Math.pow(10,a);for(var n="0.",r=1;r<a;r++)n+="0";return+(n+"1")}(t-i),o=Math.ceil((t-i)*r/a),h=function(a){var e=({3:2,4:5,6:5,7:5,8:10,9:10,11:10,12:10,13:15,14:15,16:15,17:15,18:20,19:20,21:20,22:20,23:25,24:25,26:25,27:25}[o+a]||o+a)/r,n=Math.floor(i/e)*e,h=[];h.push(n);for(var s=1;h[h.length-1]<t;s++)h.push(n+e*s);return h},s=h(0),u=function(){for(var t=[],a=s[s.length-1]-(null==e?void 0:e.max),n=0;n<s.length;n++)n+1<s.length&&s[n+1]-a<i||t.push(s[n]-a);return t},l=function(){for(var i=[],a=s[0]-(null==e?void 0:e.min),n=0;n<s.length&&(i[n]=s[n]-a,!(t<=i[n]));n++);return i};if(e){if("max"in e&&"min"in e&&e.max>=t&&e.min<=i){var _=function(){if(s[0]>=e.min&&s[s.length-1]<=e.max)return!0;var t=u();if(t[0]>=e.min&&t[t.length-1]<=e.max)return s=t,!0;var i=l();return i[0]>=e.min&&i[t.length-1]<=e.max?(s=i,!0):void 0};if(_())return s;for(var d=1;d<100;d++){if(s=h(d),_())return s;if(s=h(-d),_())return s}}"max"in e&&e.max>=t?e.max<s[s.length-1]&&(s=u()):"min"in e&&e.min<=i&&e.min>s[0]&&(s=l())}for(var p=0;p<s.length;p++){var f=s[p]+"";/\./.test(f)&&(/9{7,}$/.test(f)?(f=f.replace(/9{7,}$/,""),s[p]=+(f.substring(0,f.length-1)+(+f[f.length-1]+1))):/0{7,}\d$/.test(f)&&(s[p]=+f.replace(/0{7,}\d$/,"")))}return s}(a||0,e||0,5);"xAxis"===this.__option.category?(i.coordinate.xAxis.data=t.category,i.coordinate.yAxis.data=p,_=this.__option.width,d=-1*this.__option.height):(i.coordinate.xAxis.data=p,i.coordinate.yAxis.data=t.category,_=this.__option.height,d=this.__option.width);var f=[],c=_/t.category.length,v=.9*c,g=.05*c;if(t.data)for(var m=0;m<t.data.length;m++)f.push([g+c*m,v]);else{var x=v/t.value.length,y=.9*x,b=.05*x;for(m=0;m<t.value[0].data.length;m++){f[m]=[];for(var w=0;w<t.value.length;w++)f[m].push([g+c*m+x*w+b,y])}}var A=d/(p[p.length-1]-p[0]),k=function(t){return A*(t-p[0])};if("xAxis"===this.__option.category)if(t.data){var T=[];for(m=0;m<t.data.length;m++)T.push({x:this.__option.x+f[m][0],y:this.__option.y,width:f[m][1],height:k(t.data[m]),value:t.data[m]});i.node.push({bar:T})}else for(w=0;w<t.value.length;w++){for(T=[],m=0;m<t.value[w].data.length;m++)T.push({x:this.__option.x+f[m][w][0],y:this.__option.y,width:f[m][w][1],height:k(t.value[w].data[m]),value:t.value[w].data[m]});i.node.push({name:t.value[w].name,bar:T})}else if(t.data){for(T=[],m=0;m<t.data.length;m++)T.push({x:this.__option.x,y:this.__option.y-this.__option.height+f[m][0],width:k(t.data[m]),height:f[m][1],value:t.data[m]});i.node.push({bar:T})}else for(w=0;w<t.value.length;w++){for(T=[],m=0;m<t.value[w].data.length;m++)T.push({x:this.__option.x,y:this.__option.y-this.__option.height+f[m][w][0],width:k(t.value[w].data[m]),height:f[m][w][1],value:t.value[w].data[m]});i.node.push({name:t.value[w].name,bar:T})}return i},e.prototype.bind=function(t,i){return this.__rback=i,this.__oralBar=t,this.__preBar=this.use(this.__oralBar),this.__rback(this.__preBar),this},e.prototype.unbind=function(){return this.__rback=function(){return null},this.__oralBar=null,this.__preBar=null,this},e.prototype.doUpdate=function(){var t=this,e=this.use(this.__oralBar),n=JSON.parse(JSON.stringify(e));return function(t,e,n){arguments.length<2&&(e=400),arguments.length<3&&(n=function(){});let r={timer:function(t,i,e){if(!t)throw new Error("Tick is required!");let n=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return a.push({id:n,createTime:new Date,pauseTime:-1,pauseKeepTime:0,status:"running",tick:t,duration:i,callback:e}),r.start(),n},start:function(){if(!i)try{i=globalThis&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame((function t(){r.tick(),i&&(i=globalThis.requestAnimationFrame(t))})):setInterval(r.tick,13)}catch(t){i=setInterval(r.tick,13)}},tick:function(){let t,i,e,n,o,h,s,u=a;for(a=[],a.length=0,i=0;i<u.length;i++)o=u[i],t=o.createTime,e=o.tick,h=o.duration,n=o.callback,s=(+(new Date).valueOf()-t.valueOf()-o.pauseKeepTime)/h,s=s>1?1:s,"running"===o.status&&e(s),(s<1||"paused"===o.status)&&o.id?a.push(o):n(s);a.length<=0&&r.stop()},stop:function(){if(i){try{globalThis&&globalThis.requestAnimationFrame?globalThis.cancelAnimationFrame(i):clearInterval(i)}catch(t){clearInterval(i)}i=null}}},o=r.timer((function(i){t(i)}),e,n)}((function(i){t.__preBar||t.__rback(n)}),this.__option.duration,(function(){t.__preBar=e,t.__rback(t.__preBar)})),this},e}();export{e as default};
|
|
@@ -41,7 +41,10 @@ function animation(doback, duration, callback) {
|
|
|
41
41
|
let id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
42
42
|
$timers.push({
|
|
43
43
|
"id": id,
|
|
44
|
-
"createTime": new Date(),
|
|
44
|
+
"createTime": new Date(), // 开始时间
|
|
45
|
+
"pauseTime": -1, // 暂停的时间,继续运行的时候,借助此计算暂停的时间差
|
|
46
|
+
"pauseKeepTime": 0, // 暂停用去的时间
|
|
47
|
+
"status": "running", // running(运行中), paused(暂停中)
|
|
45
48
|
"tick": tick,
|
|
46
49
|
"duration": duration,
|
|
47
50
|
"callback": callback
|
|
@@ -84,15 +87,21 @@ function animation(doback, duration, callback) {
|
|
|
84
87
|
callback = timer.callback;
|
|
85
88
|
|
|
86
89
|
//执行
|
|
87
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
90
|
+
passTime = (+new Date().valueOf() - createTime.valueOf() - timer.pauseKeepTime) / duration;
|
|
88
91
|
passTime = passTime > 1 ? 1 : passTime;
|
|
89
|
-
|
|
90
|
-
if (
|
|
92
|
+
|
|
93
|
+
if (timer.status === "running") {
|
|
94
|
+
tick(passTime);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 只有当动画没有结束或者动画处于暂停状态时,才继续添加到timers堆栈
|
|
98
|
+
if ((passTime < 1 || timer.status === "paused") && timer.id) {
|
|
91
99
|
//动画没有结束再添加
|
|
92
100
|
$timers.push(timer);
|
|
93
101
|
} else {
|
|
94
102
|
callback(passTime);
|
|
95
103
|
}
|
|
104
|
+
|
|
96
105
|
}
|
|
97
106
|
if ($timers.length <= 0) {
|
|
98
107
|
clock.stop();
|
|
@@ -119,14 +128,34 @@ function animation(doback, duration, callback) {
|
|
|
119
128
|
}, duration, callback);
|
|
120
129
|
|
|
121
130
|
return {
|
|
122
|
-
//
|
|
123
|
-
// 用于在动画结束前结束动画
|
|
131
|
+
// 结束动画
|
|
124
132
|
stop: function () {
|
|
125
|
-
let i
|
|
126
|
-
for (i in $timers) {
|
|
133
|
+
for (let i in $timers) {
|
|
127
134
|
if ($timers[i].id == id) {
|
|
128
135
|
$timers[i].id = void 0;
|
|
129
|
-
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
// 暂停动画
|
|
140
|
+
pause: function () {
|
|
141
|
+
for (let i in $timers) {
|
|
142
|
+
if ($timers[i].id == id) {
|
|
143
|
+
if ($timers[i].pauseTime === -1) {
|
|
144
|
+
$timers[i].pauseTime = new Date();
|
|
145
|
+
$timers[i].status = "paused";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
// 继续动画
|
|
151
|
+
resume: function () {
|
|
152
|
+
for (let i in $timers) {
|
|
153
|
+
if ($timers[i].id == id) {
|
|
154
|
+
if ($timers[i].pauseTime !== -1) {
|
|
155
|
+
$timers[i].pauseKeepTime += (new Date().valueOf() - $timers[i].pauseTime.valueOf());
|
|
156
|
+
$timers[i].pauseTime = -1;
|
|
157
|
+
$timers[i].status = "running";
|
|
158
|
+
}
|
|
130
159
|
}
|
|
131
160
|
}
|
|
132
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,i){for(var e in t)i[e]=t[e];return i}function i(t,i,e,n,r){var o=Math.cos(e),a=Math.sin(e);return[(n-t)*o-(r-i)*a+t,(n-t)*a+(r-i)*o+i]}let e,n=[];var r=function(){function r(i){void 0===i&&(i={}),this.name="PieLayout",this.__option={cx:200,cy:200,radius:[50,100],duration:200},this.__hoverIndex=-1,this.__config=t(i,{name:function(t,i){return t.name},value:function(t,i){return t.value}})}return r.prototype.setOption=function(i){return t(i,this.__option),this},r.prototype.use=function(t,e){void 0===e&&(e=-1);for(var n={count:t.length,cx:this.__option.cx,cy:this.__option.cy,radius:this.__option.radius,hoverIndex:e,node:[]},r=0,o=[],a=[],s=0;s<t.length;s++)o[s]=this.__config.name(t[s],t),a[s]=this.__config.value(t[s],t),r+=a[s];var u,_=-.5*Math.PI;for(s=0;s<t.length;s++){u=a[s]/r*Math.PI*2;var h=[this.__option.radius[0]*(1+(this.__option.radius[0]>0&&e===s?-.1:0)),this.__option.radius[1]*(1+(e===s?.05:0))],c=_+.5*u,l=Math.max(this.__option.radius[0],this.__option.radius[1]),d=i(n.cx,n.cy,c,n.cx+l,n.cy),p=i(n.cx,n.cy,c,n.cx+l+15,n.cy),f=d[0]>n.cx?1:-1,v=[p[0]+20*f,p[1]],g=[p[0]+25*f,p[1]];n.node[s]={value:a[s],name:o[s],beginDeg:_,deg:u,isHover:e===s,radius:h,label:{line:[d,p,v],position:g,align:-1===f?"right":"left"}},_+=u}return n},r.prototype.bind=function(t,i){return this.__rback=i,this.__oralPie=t,this.__prePie=this.use(this.__oralPie,this.__hoverIndex),this.__rback(this.__prePie),this},r.prototype.unbind=function(){return this.__rback=function(){return null},this.__oralPie=null,this.__prePie=null,this.__hoverIndex=-1,this},r.prototype.setHover=function(t){return this.__prePie&&this.__hoverIndex!==t?(this.__hoverIndex=t,this.doUpdate(),this):this},r.prototype.doUpdate=function(){var t=this,i=this.use(this.__oralPie,this.__hoverIndex),r=JSON.parse(JSON.stringify(i));return function(t,i,r){arguments.length<2&&(i=400),arguments.length<3&&(r=function(){});let o={timer:function(t,i,e){if(!t)throw new Error("Tick is required!");let r=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return n.push({id:r,createTime:new Date,tick:t,duration:i,callback:e}),o.start(),r},start:function(){if(!e)try{e=globalThis&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame((function t(){o.tick(),e&&(e=globalThis.requestAnimationFrame(t))})):setInterval(o.tick,13)}catch(t){e=setInterval(o.tick,13)}},tick:function(){let t,i,e,r,a,s,u,_=n;for(n=[],n.length=0,i=0;i<_.length;i++)a=_[i],t=a.createTime,e=a.tick,s=a.duration,r=a.callback,u=(+(new Date).valueOf()-t.valueOf())/s,u=u>1?1:u,e(u),u<1&&a.id?n.push(a):r(u);n.length<=0&&o.stop()},stop:function(){if(e){try{globalThis&&globalThis.requestAnimationFrame?globalThis.cancelAnimationFrame(e):clearInterval(e)}catch(t){clearInterval(e)}e=null}}},a=o.timer((function(i){t(i)}),i,r)}((function(e){if(t.__prePie)for(var n=0;n<r.count;n++)r.node[n].radius[0]=t.__prePie.node[n].radius[0]+(i.node[n].radius[0]-t.__prePie.node[n].radius[0])*e,r.node[n].radius[1]=t.__prePie.node[n].radius[1]+(i.node[n].radius[1]-t.__prePie.node[n].radius[1])*e;t.__rback(r)}),this.__option.duration,(function(){t.__prePie=i,t.__rback(t.__prePie)})),this},r}();export{r as default};
|
|
1
|
+
function t(t,i){for(var e in t)i[e]=t[e];return i}function i(t,i,e,n,r){var o=Math.cos(e),a=Math.sin(e);return[(n-t)*o-(r-i)*a+t,(n-t)*a+(r-i)*o+i]}let e,n=[];var r=function(){function r(i){void 0===i&&(i={}),this.name="PieLayout",this.__option={cx:200,cy:200,radius:[50,100],duration:200},this.__hoverIndex=-1,this.__config=t(i,{name:function(t,i){return t.name},value:function(t,i){return t.value}})}return r.prototype.setOption=function(i){return t(i,this.__option),this},r.prototype.use=function(t,e){void 0===e&&(e=-1);for(var n={count:t.length,cx:this.__option.cx,cy:this.__option.cy,radius:this.__option.radius,hoverIndex:e,node:[]},r=0,o=[],a=[],s=0;s<t.length;s++)o[s]=this.__config.name(t[s],t),a[s]=this.__config.value(t[s],t),r+=a[s];var u,_=-.5*Math.PI;for(s=0;s<t.length;s++){u=a[s]/r*Math.PI*2;var h=[this.__option.radius[0]*(1+(this.__option.radius[0]>0&&e===s?-.1:0)),this.__option.radius[1]*(1+(e===s?.05:0))],c=_+.5*u,l=Math.max(this.__option.radius[0],this.__option.radius[1]),d=i(n.cx,n.cy,c,n.cx+l,n.cy),p=i(n.cx,n.cy,c,n.cx+l+15,n.cy),f=d[0]>n.cx?1:-1,v=[p[0]+20*f,p[1]],g=[p[0]+25*f,p[1]];n.node[s]={value:a[s],name:o[s],beginDeg:_,deg:u,isHover:e===s,radius:h,label:{line:[d,p,v],position:g,align:-1===f?"right":"left"}},_+=u}return n},r.prototype.bind=function(t,i){return this.__rback=i,this.__oralPie=t,this.__prePie=this.use(this.__oralPie,this.__hoverIndex),this.__rback(this.__prePie),this},r.prototype.unbind=function(){return this.__rback=function(){return null},this.__oralPie=null,this.__prePie=null,this.__hoverIndex=-1,this},r.prototype.setHover=function(t){return this.__prePie&&this.__hoverIndex!==t?(this.__hoverIndex=t,this.doUpdate(),this):this},r.prototype.doUpdate=function(){var t=this,i=this.use(this.__oralPie,this.__hoverIndex),r=JSON.parse(JSON.stringify(i));return function(t,i,r){arguments.length<2&&(i=400),arguments.length<3&&(r=function(){});let o={timer:function(t,i,e){if(!t)throw new Error("Tick is required!");let r=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return n.push({id:r,createTime:new Date,pauseTime:-1,pauseKeepTime:0,status:"running",tick:t,duration:i,callback:e}),o.start(),r},start:function(){if(!e)try{e=globalThis&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame((function t(){o.tick(),e&&(e=globalThis.requestAnimationFrame(t))})):setInterval(o.tick,13)}catch(t){e=setInterval(o.tick,13)}},tick:function(){let t,i,e,r,a,s,u,_=n;for(n=[],n.length=0,i=0;i<_.length;i++)a=_[i],t=a.createTime,e=a.tick,s=a.duration,r=a.callback,u=(+(new Date).valueOf()-t.valueOf()-a.pauseKeepTime)/s,u=u>1?1:u,"running"===a.status&&e(u),(u<1||"paused"===a.status)&&a.id?n.push(a):r(u);n.length<=0&&o.stop()},stop:function(){if(e){try{globalThis&&globalThis.requestAnimationFrame?globalThis.cancelAnimationFrame(e):clearInterval(e)}catch(t){clearInterval(e)}e=null}}},a=o.timer((function(i){t(i)}),i,r)}((function(e){if(t.__prePie)for(var n=0;n<r.count;n++)r.node[n].radius[0]=t.__prePie.node[n].radius[0]+(i.node[n].radius[0]-t.__prePie.node[n].radius[0])*e,r.node[n].radius[1]=t.__prePie.node[n].radius[1]+(i.node[n].radius[1]-t.__prePie.node[n].radius[1])*e;t.__rback(r)}),this.__option.duration,(function(){t.__prePie=i,t.__rback(t.__prePie)})),this},r}();export{r as default};
|
|
@@ -211,7 +211,10 @@ function animation(doback, duration, callback) {
|
|
|
211
211
|
let id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
212
212
|
$timers.push({
|
|
213
213
|
"id": id,
|
|
214
|
-
"createTime": new Date(),
|
|
214
|
+
"createTime": new Date(), // 开始时间
|
|
215
|
+
"pauseTime": -1, // 暂停的时间,继续运行的时候,借助此计算暂停的时间差
|
|
216
|
+
"pauseKeepTime": 0, // 暂停用去的时间
|
|
217
|
+
"status": "running", // running(运行中), paused(暂停中)
|
|
215
218
|
"tick": tick,
|
|
216
219
|
"duration": duration,
|
|
217
220
|
"callback": callback
|
|
@@ -254,15 +257,21 @@ function animation(doback, duration, callback) {
|
|
|
254
257
|
callback = timer.callback;
|
|
255
258
|
|
|
256
259
|
//执行
|
|
257
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
260
|
+
passTime = (+new Date().valueOf() - createTime.valueOf() - timer.pauseKeepTime) / duration;
|
|
258
261
|
passTime = passTime > 1 ? 1 : passTime;
|
|
259
|
-
|
|
260
|
-
if (
|
|
262
|
+
|
|
263
|
+
if (timer.status === "running") {
|
|
264
|
+
tick(passTime);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 只有当动画没有结束或者动画处于暂停状态时,才继续添加到timers堆栈
|
|
268
|
+
if ((passTime < 1 || timer.status === "paused") && timer.id) {
|
|
261
269
|
//动画没有结束再添加
|
|
262
270
|
$timers.push(timer);
|
|
263
271
|
} else {
|
|
264
272
|
callback(passTime);
|
|
265
273
|
}
|
|
274
|
+
|
|
266
275
|
}
|
|
267
276
|
if ($timers.length <= 0) {
|
|
268
277
|
clock.stop();
|
|
@@ -289,14 +298,34 @@ function animation(doback, duration, callback) {
|
|
|
289
298
|
}, duration, callback);
|
|
290
299
|
|
|
291
300
|
return {
|
|
292
|
-
//
|
|
293
|
-
// 用于在动画结束前结束动画
|
|
301
|
+
// 结束动画
|
|
294
302
|
stop: function () {
|
|
295
|
-
let i
|
|
296
|
-
for (i in $timers) {
|
|
303
|
+
for (let i in $timers) {
|
|
297
304
|
if ($timers[i].id == id) {
|
|
298
305
|
$timers[i].id = void 0;
|
|
299
|
-
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
// 暂停动画
|
|
310
|
+
pause: function () {
|
|
311
|
+
for (let i in $timers) {
|
|
312
|
+
if ($timers[i].id == id) {
|
|
313
|
+
if ($timers[i].pauseTime === -1) {
|
|
314
|
+
$timers[i].pauseTime = new Date();
|
|
315
|
+
$timers[i].status = "paused";
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
// 继续动画
|
|
321
|
+
resume: function () {
|
|
322
|
+
for (let i in $timers) {
|
|
323
|
+
if ($timers[i].id == id) {
|
|
324
|
+
if ($timers[i].pauseTime !== -1) {
|
|
325
|
+
$timers[i].pauseKeepTime += (new Date().valueOf() - $timers[i].pauseTime.valueOf());
|
|
326
|
+
$timers[i].pauseTime = -1;
|
|
327
|
+
$timers[i].status = "running";
|
|
328
|
+
}
|
|
300
329
|
}
|
|
301
330
|
}
|
|
302
331
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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=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){void 0===o&&(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
|
|
1
|
+
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=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){void 0===o&&(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 s=1;return function n(r,p){var h=e.children(r,t);s+=h?h.length:0;for(var d=0;h&&d<h.length;d++)o=e.id(h[d]),i[p].children.push(o),i[o]={data:h[d],pid:p,id:o,isOpen:!0,show:!0,deg:0,children:[]},n(h[d],o)}(r,o),{rid:n,value:i,num:s}}(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 s=[],p=0,h=0;for(var d in o[r]?(i[r].left=.5,i[r].top=.5,i[r].show=!0,p=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==s[n]&&(s[n]=-.5),null==s[n-1]&&(s[n-1]=-.5),i[e.id].top=s[n]+1,s[n]+1+.5*(i[e.pid].children.length-1)-1<s[n-1]&&(i[e.id].top=s[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<=s[n])var d=s[n]+1-i[e.id].top((function t(e,o){i[e].top+=d,s[o]<i[e].top&&(s[o]=i[e].top);for(var n=0;n<i[e].children.length;n++)t(i[e].children[n],o+1)}))(e.id,n);s[n]=i[e.id].top,i[e.id].top+.5>p&&(p=i[e.id].top+.5)}(i[r],0),o)o[d]&&(i[d].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)}(d,i[d].left,i[d].top));return{node:i,root:r,size:p,deep:h+1}}(t,this.__config,e)},t}();let n,i=[];function r(t,e,o,n,i){var r=Math.cos(o),s=Math.sin(o);return[(n-t)*r-(i-e)*s+t,(n-t)*s+(i-e)*r+e]}var s=function(o){function s(){var t=null!==o&&o.apply(this,arguments)||this;return t.name="TreeLayout",t.__option={offsetX:0,offsetY:0,duration:500,type:"plain",direction:"LR",x:100,y:100,width:100,height:100,radius:100},t.__noOpens={},t}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(s,o),s.prototype.setOption=function(t){return e(t,this.__option),this},s.prototype.use=function(t,e){void 0===e&&(e={});var n=o.prototype.use.call(this,t,e);if(0!=this.__option.offsetX||0!=this.__option.offsetY)for(var i in n.node)if(!n.node[i].show){var s=0,p=i;do{p=n.node[p].pid,s++}while(!n.node[p].show);n.node[i].left+=this.__option.offsetX*s,n.node[i].top+=this.__option.offsetY*s}if("rect"==this.__option.type){if("LR"==this.__option.direction||"RL"==this.__option.direction){var h=this.__option.height/n.size,d=this.__option.width/(n.deep-1),_=this.__option.y-.5*this.__option.height,l="LR"==this.__option.direction?1:-1;for(var i in n.node)1==n.deep?(n.node[i].left=this.__option.x+.5*this.__option.width*l,n.node[i].top=this.__option.y):(n.node[i].left=this.__option.x+(n.node[i].left-.5)*d*l,n.node[i].top=n.node[i].top*h+_)}else if("TB"==this.__option.direction||"BT"==this.__option.direction){h=this.__option.width/n.size,d=this.__option.height/(n.deep-1),_=this.__option.x-.5*this.__option.width,l="TB"==this.__option.direction?1:-1;for(var i in n.node)if(n.node[i].deg="TB"==this.__option.direction?.5*Math.PI:-.5*Math.PI,1==n.deep)n.node[i].left=this.__option.x,n.node[i].top=this.__option.y+.5*this.__option.height*l;else{var a=n.node[i].left;n.node[i].left=n.node[i].top*h+_,n.node[i].top=this.__option.y+(a-.5)*d*l}}}else if("circle"==this.__option.type){var u=this.__option.x,f=this.__option.y,c=2*Math.PI/n.size,v=this.__option.radius/(n.deep-1);for(var i in n.node)if(.5==n.node[i].left)n.node[i].left=u,n.node[i].top=f;else{var T=r(u,f,c*n.node[i].top,u+(n.node[i].left-.5)*v,f);n.node[i].deg=c*n.node[i].top,n.node[i].left=T[0],n.node[i].top=T[1]}}return n},s.prototype.bind=function(t,e,o){return void 0===o&&(o={}),this.__rback=e,this.__oralTree=t,this.__noOpens=o,this.__preTree=this.use(this.__oralTree,this.__noOpens),this.__rback(this.__preTree),this},s.prototype.unbind=function(){return this.__rback=function(){return null},this.__oralTree=null,this.__preTree=null,this.__noOpens={},this},s.prototype.doUpdate=function(){var t=this,e=this.use(this.__oralTree,this.__noOpens),o=JSON.parse(JSON.stringify(e));return function(t,e,o){arguments.length<2&&(e=400),arguments.length<3&&(o=function(){});let r={timer:function(t,e,o){if(!t)throw new Error("Tick is required!");let n=(new Date).valueOf()+"_"+(1e3*Math.random()).toFixed(0);return i.push({id:n,createTime:new Date,pauseTime:-1,pauseKeepTime:0,status:"running",tick:t,duration:e,callback:o}),r.start(),n},start:function(){if(!n)try{n=globalThis&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame((function t(){r.tick(),n&&(n=globalThis.requestAnimationFrame(t))})):setInterval(r.tick,13)}catch(t){n=setInterval(r.tick,13)}},tick:function(){let t,e,o,n,s,p,h,d=i;for(i=[],i.length=0,e=0;e<d.length;e++)s=d[e],t=s.createTime,o=s.tick,p=s.duration,n=s.callback,h=(+(new Date).valueOf()-t.valueOf()-s.pauseKeepTime)/p,h=h>1?1:h,"running"===s.status&&o(h),(h<1||"paused"===s.status)&&s.id?i.push(s):n(h);i.length<=0&&r.stop()},stop:function(){if(n){try{globalThis&&globalThis.requestAnimationFrame?globalThis.cancelAnimationFrame(n):clearInterval(n)}catch(t){clearInterval(n)}n=null}}},s=r.timer((function(e){t(e)}),e,o)}((function(n){if(t.__preTree)for(var i in o.node)(e.node[i].show||t.__preTree.node[i].show)&&(o.node[i].show=!0,o.node[i].left=t.__preTree.node[i].left+(e.node[i].left-t.__preTree.node[i].left)*n,o.node[i].top=t.__preTree.node[i].top+(e.node[i].top-t.__preTree.node[i].top)*n);t.__rback(o)}),this.__option.duration,(function(){t.__preTree=e,t.__rback(t.__preTree)})),this},s.prototype.closeNode=function(t){return this.__preTree?(this.__noOpens[t]=!0,this.doUpdate(),this):this},s.prototype.openNode=function(t){return this.__preTree?(this.__noOpens[t]=!1,this.doUpdate(),this):this},s.prototype.toggleNode=function(t){return this.__preTree?(this.__noOpens[t]=!this.__noOpens[t],this.doUpdate(),this):this},s}(o);export{s as default};
|