vislite 1.3.0 → 1.4.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 +12 -5
- 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 +1 -1
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +2 -2
- package/lib/Canvas/index.es.min.js +1 -1
- package/lib/Cardinal/index.es.js +1 -1
- package/lib/Cardinal/index.es.min.js +1 -1
- package/lib/Eoap/index.es.js +1 -1
- package/lib/Eoap/index.es.min.js +1 -1
- package/lib/Hermite/index.es.js +1 -1
- package/lib/Hermite/index.es.min.js +1 -1
- package/lib/MapCoordinate/index.es.js +1 -1
- package/lib/MapCoordinate/index.es.min.js +1 -1
- package/lib/Matrix4/index.es.js +1 -1
- package/lib/Matrix4/index.es.min.js +1 -1
- package/lib/Mercator/index.es.js +1 -1
- 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 +2 -2
- package/lib/RawCanvas/index.es.min.js +1 -1
- package/lib/SVG/index.es.js +29 -6
- package/lib/SVG/index.es.min.js +2 -2
- package/lib/Shader/index.es.js +1 -1
- package/lib/Shader/index.es.min.js +1 -1
- package/lib/Texture/index.es.js +1 -1
- package/lib/Texture/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +109 -102
- package/lib/TreeLayout/index.es.min.js +6 -2
- package/lib/animation/index.es.js +114 -103
- package/lib/animation/index.es.min.js +6 -2
- package/lib/assemble/index.es.js +1 -1
- package/lib/assemble/index.es.min.js +1 -1
- package/lib/getLoopColors/index.es.js +1 -1
- package/lib/getLoopColors/index.es.min.js +1 -1
- package/lib/getWebGLContext/index.es.js +1 -1
- package/lib/getWebGLContext/index.es.min.js +1 -1
- package/lib/index.umd.js +510 -158
- package/lib/index.umd.min.js +12 -2
- package/lib/initOption/index.es.js +1 -1
- package/lib/initOption/index.es.min.js +1 -1
- package/lib/mergeOption/index.es.js +1 -1
- package/lib/mergeOption/index.es.min.js +1 -1
- package/lib/move/index.es.js +1 -1
- package/lib/move/index.es.min.js +1 -1
- package/lib/rotate/index.es.js +1 -1
- package/lib/rotate/index.es.min.js +1 -1
- package/lib/ruler/index.es.js +1 -1
- package/lib/ruler/index.es.min.js +1 -1
- package/lib/scale/index.es.js +1 -1
- package/lib/scale/index.es.min.js +1 -1
- package/lib/throttle/index.es.js +55 -50
- 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 +5 -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 +4 -0
- 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 +1 -1
- package/package.json +3 -3
- 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 +31 -0
- 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 +1 -1
- 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 +2 -2
- package/src/common/svg/gradient.ts +2 -2
- package/src/common/svg/index.ts +1 -1
- 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 +3 -0
- 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 +1 -0
- 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 +4 -1
- 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 +4 -0
- 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 +7 -1
- 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 +16 -0
- 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 +1 -1
- 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
package/lib/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v1.
|
|
2
|
+
* VISLite JavaScript Library v1.4.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -293,107 +293,118 @@
|
|
|
293
293
|
return colors;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
*
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
296
|
+
/*!
|
|
297
|
+
* animation of OIPage v1.3.0
|
|
298
|
+
* git+https://github.com/oi-contrib/OIPage.git
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
//当前正在运动的动画的tick函数堆栈
|
|
302
|
+
var $timers = [];
|
|
303
|
+
//唯一定时器的定时间隔
|
|
304
|
+
var $interval = 13;
|
|
305
|
+
//定时器ID
|
|
306
|
+
var $timerId;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 动画轮播
|
|
310
|
+
* @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
|
|
311
|
+
* @param {number} duration 动画时长,可选
|
|
312
|
+
* @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
|
|
313
|
+
*
|
|
314
|
+
* @returns {function} 返回一个函数,调用该函数,可以提前结束动画
|
|
315
|
+
*/
|
|
316
|
+
function animation$1(doback, duration, callback) {
|
|
317
|
+
if (arguments.length < 2) duration = 400;
|
|
318
|
+
if (arguments.length < 3) callback = function () { };
|
|
319
|
+
|
|
320
|
+
var clock = {
|
|
321
|
+
//把tick函数推入堆栈
|
|
322
|
+
"timer": function (tick, duration, callback) {
|
|
323
|
+
if (!tick) {
|
|
324
|
+
throw new Error('Tick is required!');
|
|
325
|
+
}
|
|
326
|
+
var id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
327
|
+
$timers.push({
|
|
328
|
+
"id": id,
|
|
329
|
+
"createTime": new Date(),
|
|
330
|
+
"tick": tick,
|
|
331
|
+
"duration": duration,
|
|
332
|
+
"callback": callback
|
|
333
|
+
});
|
|
334
|
+
clock.start();
|
|
335
|
+
return id;
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
//开启唯一的定时器timerId
|
|
339
|
+
"start": function () {
|
|
340
|
+
if (!$timerId) {
|
|
341
|
+
$timerId = setInterval(clock.tick, $interval);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
//被定时器调用,遍历timers堆栈
|
|
346
|
+
"tick": function () {
|
|
347
|
+
var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
|
|
348
|
+
|
|
349
|
+
$timers = [];
|
|
350
|
+
$timers.length = 0;
|
|
351
|
+
|
|
352
|
+
for (flag = 0; flag < timers.length; flag++) {
|
|
353
|
+
//初始化数据
|
|
354
|
+
timer = timers[flag];
|
|
355
|
+
createTime = timer.createTime;
|
|
356
|
+
tick = timer.tick;
|
|
357
|
+
duration = timer.duration;
|
|
358
|
+
callback = timer.callback;
|
|
359
|
+
|
|
360
|
+
//执行
|
|
361
|
+
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
362
|
+
passTime = passTime > 1 ? 1 : passTime;
|
|
363
|
+
tick(passTime);
|
|
364
|
+
if (passTime < 1 && timer.id) {
|
|
365
|
+
//动画没有结束再添加
|
|
366
|
+
$timers.push(timer);
|
|
367
|
+
} else {
|
|
368
|
+
callback(passTime);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if ($timers.length <= 0) {
|
|
372
|
+
clock.stop();
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
//停止定时器,重置timerId=null
|
|
377
|
+
"stop": function () {
|
|
378
|
+
if ($timerId) {
|
|
379
|
+
clearInterval($timerId);
|
|
380
|
+
$timerId = null;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
var id = clock.timer(function (deep) {
|
|
386
|
+
//其中deep为0-1,表示改变的程度
|
|
387
|
+
doback(deep);
|
|
388
|
+
}, duration, callback);
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
// 一个函数
|
|
392
|
+
// 用于在动画结束前结束动画
|
|
393
|
+
stop: function () {
|
|
394
|
+
var i;
|
|
395
|
+
for (i in $timers) {
|
|
396
|
+
if ($timers[i].id == id) {
|
|
397
|
+
$timers[i].id = void 0;
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function animation (doback, duration, callback) {
|
|
407
|
+
return animation$1(doback, duration || 400, callback || function () { }).stop;
|
|
397
408
|
}
|
|
398
409
|
|
|
399
410
|
function ruler (maxValue, minValue, num, option) {
|
|
@@ -802,7 +813,7 @@
|
|
|
802
813
|
};
|
|
803
814
|
var linearGradient$1 = function (el, x0, y0, x1, y1) {
|
|
804
815
|
var defs = initDefs(el);
|
|
805
|
-
var gradientId = "
|
|
816
|
+
var gradientId = "visliteLg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
|
|
806
817
|
var linearGradient = toNode("linearGradient");
|
|
807
818
|
defs.appendChild(linearGradient);
|
|
808
819
|
setAttribute(linearGradient, "id", gradientId);
|
|
@@ -814,7 +825,7 @@
|
|
|
814
825
|
};
|
|
815
826
|
var radialGradient$1 = function (el, cx, cy, r) {
|
|
816
827
|
var defs = initDefs(el);
|
|
817
|
-
var gradientId = "
|
|
828
|
+
var gradientId = "visliteRg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
|
|
818
829
|
var radialGradient = toNode("radialGradient");
|
|
819
830
|
defs.appendChild(radialGradient);
|
|
820
831
|
setAttribute(radialGradient, "id", gradientId);
|
|
@@ -826,8 +837,8 @@
|
|
|
826
837
|
|
|
827
838
|
function defaultFactory$1 () {
|
|
828
839
|
return {
|
|
829
|
-
fillStyle: "
|
|
830
|
-
strokeStyle: "
|
|
840
|
+
fillStyle: "rgb(0,0,0)",
|
|
841
|
+
strokeStyle: "rgb(0,0,0)",
|
|
831
842
|
textAlign: "left",
|
|
832
843
|
textBaseline: "middle",
|
|
833
844
|
"fontSize": 16,
|
|
@@ -1069,6 +1080,7 @@
|
|
|
1069
1080
|
var SVG = (function (_super) {
|
|
1070
1081
|
__extends(SVG, _super);
|
|
1071
1082
|
function SVG(el) {
|
|
1083
|
+
var _this = this;
|
|
1072
1084
|
if (!el) {
|
|
1073
1085
|
throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
|
|
1074
1086
|
}
|
|
@@ -1078,8 +1090,30 @@
|
|
|
1078
1090
|
ViewSVG.setAttribute("width", width + "");
|
|
1079
1091
|
ViewSVG.setAttribute("height", height + "");
|
|
1080
1092
|
ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
|
|
1081
|
-
|
|
1093
|
+
_this = _super.call(this, ViewSVG) || this;
|
|
1094
|
+
_this.__el = el;
|
|
1095
|
+
return _this;
|
|
1082
1096
|
}
|
|
1097
|
+
SVG.prototype.toDataURL = function () {
|
|
1098
|
+
var _this = this;
|
|
1099
|
+
return new Promise(function (resolve) {
|
|
1100
|
+
var width = _this.__el.clientWidth, height = _this.__el.clientHeight;
|
|
1101
|
+
var img = document.createElement('img');
|
|
1102
|
+
img.setAttribute('width', width + "");
|
|
1103
|
+
img.setAttribute('height', height + "");
|
|
1104
|
+
var base64_svg = "data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='" + width + "' height='" + height + "'>" + _this.__svg.innerHTML.replace(/"/g, "'") + "</svg>";
|
|
1105
|
+
img.setAttribute('src', base64_svg);
|
|
1106
|
+
setTimeout(function () {
|
|
1107
|
+
var canvas = document.createElement('canvas');
|
|
1108
|
+
canvas.setAttribute('width', width + "");
|
|
1109
|
+
canvas.setAttribute('height', height + "");
|
|
1110
|
+
var painter = canvas.getContext('2d');
|
|
1111
|
+
if (painter)
|
|
1112
|
+
painter.drawImage(img, 0, 0, width, height);
|
|
1113
|
+
resolve(canvas.toDataURL());
|
|
1114
|
+
}, 100);
|
|
1115
|
+
});
|
|
1116
|
+
};
|
|
1083
1117
|
return SVG;
|
|
1084
1118
|
}(SVG$1));
|
|
1085
1119
|
|
|
@@ -1640,7 +1674,7 @@
|
|
|
1640
1674
|
var gradient = painter.createConicGradient(startDeg, cx, cy);
|
|
1641
1675
|
return enhanceGradient(gradient, deg ? function (stop) {
|
|
1642
1676
|
return deg / (Math.PI * 2) * stop;
|
|
1643
|
-
} :
|
|
1677
|
+
} : void 0);
|
|
1644
1678
|
};
|
|
1645
1679
|
|
|
1646
1680
|
var Canvas$1 = (function (_super) {
|
|
@@ -2128,55 +2162,60 @@
|
|
|
2128
2162
|
return Mercator;
|
|
2129
2163
|
}());
|
|
2130
2164
|
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2165
|
+
/*!
|
|
2166
|
+
* throttle of OIPage v1.3.0
|
|
2167
|
+
* git+https://github.com/oi-contrib/OIPage.git
|
|
2168
|
+
*/
|
|
2169
|
+
|
|
2170
|
+
function throttle(callback, _option) {
|
|
2171
|
+
|
|
2172
|
+
// 缺省值
|
|
2173
|
+
var option = {
|
|
2174
|
+
time: 200,
|
|
2175
|
+
keep: false,
|
|
2176
|
+
opportunity: "end"
|
|
2177
|
+
};
|
|
2178
|
+
|
|
2179
|
+
// 校对
|
|
2180
|
+
if (_option) {
|
|
2181
|
+
for (var key in _option) {
|
|
2182
|
+
option[key] = _option[key];
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
var hadInterval = false, hadClick = false, oneClick = false, arg;
|
|
2187
|
+
return function () {
|
|
2188
|
+
const _this = this;
|
|
2189
|
+
arg = arguments;
|
|
2190
|
+
|
|
2191
|
+
// 如果前置任务都完成了
|
|
2192
|
+
if (!hadInterval) {
|
|
2193
|
+
if (option.opportunity != 'end') {
|
|
2194
|
+
callback.apply(_this, arg);
|
|
2195
|
+
}
|
|
2196
|
+
hadInterval = true;
|
|
2197
|
+
|
|
2198
|
+
var interval = setInterval(() => {
|
|
2199
|
+
if (hadClick) {
|
|
2200
|
+
if (!option.keep) {
|
|
2201
|
+
callback.apply(_this, arg);
|
|
2202
|
+
}
|
|
2203
|
+
} else {
|
|
2204
|
+
if (option.opportunity != 'begin') {
|
|
2205
|
+
if (oneClick || option.opportunity == 'end') callback.apply(_this, arg);
|
|
2206
|
+
}
|
|
2207
|
+
hadInterval = false;
|
|
2208
|
+
oneClick = false;
|
|
2209
|
+
clearInterval(interval);
|
|
2210
|
+
}
|
|
2211
|
+
hadClick = false;
|
|
2212
|
+
}, option.time);
|
|
2213
|
+
} else {
|
|
2214
|
+
hadClick = true;
|
|
2215
|
+
oneClick = true;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
};
|
|
2180
2219
|
}
|
|
2181
2220
|
|
|
2182
2221
|
function mllData(geoJson) {
|
|
@@ -2550,7 +2589,7 @@
|
|
|
2550
2589
|
var _this = this;
|
|
2551
2590
|
var newTree = this.use(this.__oralTree, this.__noOpens);
|
|
2552
2591
|
var cacheTree = JSON.parse(JSON.stringify(newTree));
|
|
2553
|
-
animation(function (deep) {
|
|
2592
|
+
animation$1(function (deep) {
|
|
2554
2593
|
if (_this.__preTree) {
|
|
2555
2594
|
for (var key in cacheTree.node) {
|
|
2556
2595
|
if (newTree.node[key].show || _this.__preTree.node[key].show) {
|
|
@@ -2591,6 +2630,317 @@
|
|
|
2591
2630
|
return TreeLayout;
|
|
2592
2631
|
}(Tree));
|
|
2593
2632
|
|
|
2633
|
+
var PieLayout = (function () {
|
|
2634
|
+
function PieLayout(config) {
|
|
2635
|
+
if (config === void 0) { config = {}; }
|
|
2636
|
+
this.name = 'PieLayout';
|
|
2637
|
+
this.__option = {
|
|
2638
|
+
cx: 200,
|
|
2639
|
+
cy: 200,
|
|
2640
|
+
radius: [50, 100],
|
|
2641
|
+
duration: 200,
|
|
2642
|
+
};
|
|
2643
|
+
this.__hoverIndex = -1;
|
|
2644
|
+
this.__config = initOption(config, {
|
|
2645
|
+
name: function (pieData, initPie) { return pieData.name; },
|
|
2646
|
+
value: function (pieData, initPie) { return pieData.value; }
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
PieLayout.prototype.setOption = function (option) {
|
|
2650
|
+
initOption(option, this.__option);
|
|
2651
|
+
return this;
|
|
2652
|
+
};
|
|
2653
|
+
PieLayout.prototype.use = function (initPie, hoverIndex) {
|
|
2654
|
+
if (hoverIndex === void 0) { hoverIndex = -1; }
|
|
2655
|
+
var pie = {
|
|
2656
|
+
count: initPie.length,
|
|
2657
|
+
cx: this.__option.cx,
|
|
2658
|
+
cy: this.__option.cy,
|
|
2659
|
+
radius: this.__option.radius,
|
|
2660
|
+
hoverIndex: hoverIndex,
|
|
2661
|
+
node: []
|
|
2662
|
+
};
|
|
2663
|
+
var totalValue = 0, names = [], values = [];
|
|
2664
|
+
for (var i = 0; i < initPie.length; i++) {
|
|
2665
|
+
names[i] = this.__config.name(initPie[i], initPie);
|
|
2666
|
+
values[i] = this.__config.value(initPie[i], initPie);
|
|
2667
|
+
totalValue += values[i];
|
|
2668
|
+
}
|
|
2669
|
+
var beginDeg = Math.PI * -0.5, currenDeg;
|
|
2670
|
+
for (var i = 0; i < initPie.length; i++) {
|
|
2671
|
+
currenDeg = values[i] / totalValue * Math.PI * 2;
|
|
2672
|
+
var radius = [this.__option.radius[0], this.__option.radius[1] * (1 + (hoverIndex === i ? 0.05 : 0))];
|
|
2673
|
+
var pdeg = beginDeg + currenDeg * 0.5, pradius = Math.max(this.__option.radius[0], this.__option.radius[1]);
|
|
2674
|
+
var p0 = rotate$1(pie.cx, pie.cy, pdeg, pie.cx + pradius, pie.cy);
|
|
2675
|
+
var p1 = rotate$1(pie.cx, pie.cy, pdeg, pie.cx + pradius + 15, pie.cy);
|
|
2676
|
+
var pflag = p0[0] > pie.cx ? 1 : -1;
|
|
2677
|
+
var p2 = [p1[0] + pflag * 20, p1[1]];
|
|
2678
|
+
var p3 = [p1[0] + pflag * 25, p1[1]];
|
|
2679
|
+
pie.node[i] = {
|
|
2680
|
+
value: values[i],
|
|
2681
|
+
name: names[i],
|
|
2682
|
+
beginDeg: beginDeg,
|
|
2683
|
+
deg: currenDeg,
|
|
2684
|
+
isHover: hoverIndex === i,
|
|
2685
|
+
radius: radius,
|
|
2686
|
+
label: {
|
|
2687
|
+
line: [p0, p1, p2],
|
|
2688
|
+
position: p3,
|
|
2689
|
+
align: pflag === -1 ? "right" : "left"
|
|
2690
|
+
}
|
|
2691
|
+
};
|
|
2692
|
+
beginDeg += currenDeg;
|
|
2693
|
+
}
|
|
2694
|
+
return pie;
|
|
2695
|
+
};
|
|
2696
|
+
PieLayout.prototype.bind = function (initPie, renderBack) {
|
|
2697
|
+
this.__rback = renderBack;
|
|
2698
|
+
this.__oralPie = initPie;
|
|
2699
|
+
this.__prePie = this.use(this.__oralPie, this.__hoverIndex);
|
|
2700
|
+
this.__rback(this.__prePie);
|
|
2701
|
+
return this;
|
|
2702
|
+
};
|
|
2703
|
+
PieLayout.prototype.unbind = function () {
|
|
2704
|
+
this.__rback = function () { return null; };
|
|
2705
|
+
this.__oralPie = null;
|
|
2706
|
+
this.__prePie = null;
|
|
2707
|
+
this.__hoverIndex = -1;
|
|
2708
|
+
return this;
|
|
2709
|
+
};
|
|
2710
|
+
PieLayout.prototype.setHover = function (index) {
|
|
2711
|
+
if (!this.__prePie || this.__hoverIndex === index)
|
|
2712
|
+
return this;
|
|
2713
|
+
this.__hoverIndex = index;
|
|
2714
|
+
this.doUpdate();
|
|
2715
|
+
return this;
|
|
2716
|
+
};
|
|
2717
|
+
PieLayout.prototype.doUpdate = function () {
|
|
2718
|
+
var _this = this;
|
|
2719
|
+
var newPie = this.use(this.__oralPie, this.__hoverIndex);
|
|
2720
|
+
var cachePie = JSON.parse(JSON.stringify(newPie));
|
|
2721
|
+
animation$1(function (deep) {
|
|
2722
|
+
if (_this.__prePie) {
|
|
2723
|
+
for (var i = 0; i < cachePie.count; i++) {
|
|
2724
|
+
cachePie.node[i].radius[1] = _this.__prePie.node[i].radius[1] + (newPie.node[i].radius[1] - _this.__prePie.node[i].radius[1]) * deep;
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
_this.__rback(cachePie);
|
|
2728
|
+
}, this.__option.duration, function () {
|
|
2729
|
+
_this.__prePie = newPie;
|
|
2730
|
+
_this.__rback(_this.__prePie);
|
|
2731
|
+
});
|
|
2732
|
+
return this;
|
|
2733
|
+
};
|
|
2734
|
+
return PieLayout;
|
|
2735
|
+
}());
|
|
2736
|
+
|
|
2737
|
+
var BarLayout = (function () {
|
|
2738
|
+
function BarLayout(config) {
|
|
2739
|
+
if (config === void 0) { config = {}; }
|
|
2740
|
+
this.name = 'BarLayout';
|
|
2741
|
+
this.__option = {
|
|
2742
|
+
x: 50,
|
|
2743
|
+
y: 350,
|
|
2744
|
+
width: 400,
|
|
2745
|
+
height: 300,
|
|
2746
|
+
category: "xAxis",
|
|
2747
|
+
duration: 200
|
|
2748
|
+
};
|
|
2749
|
+
this.__config = initOption(config, {});
|
|
2750
|
+
}
|
|
2751
|
+
BarLayout.prototype.setOption = function (option) {
|
|
2752
|
+
initOption(option, this.__option);
|
|
2753
|
+
return this;
|
|
2754
|
+
};
|
|
2755
|
+
BarLayout.prototype.use = function (initBar) {
|
|
2756
|
+
var bar = {
|
|
2757
|
+
coordinate: {
|
|
2758
|
+
x: this.__option.x,
|
|
2759
|
+
y: this.__option.y,
|
|
2760
|
+
width: this.__option.width,
|
|
2761
|
+
height: this.__option.height,
|
|
2762
|
+
xAxis: {
|
|
2763
|
+
type: this.__option.category === "xAxis" ? "category" : "value",
|
|
2764
|
+
data: []
|
|
2765
|
+
},
|
|
2766
|
+
yAxis: {
|
|
2767
|
+
type: this.__option.category === "xAxis" ? "value" : "category",
|
|
2768
|
+
data: []
|
|
2769
|
+
}
|
|
2770
|
+
},
|
|
2771
|
+
node: []
|
|
2772
|
+
};
|
|
2773
|
+
var maxValue = void 0, minValue = void 0;
|
|
2774
|
+
if (initBar.data) {
|
|
2775
|
+
for (var _i = 0, _a = initBar.data; _i < _a.length; _i++) {
|
|
2776
|
+
var val = _a[_i];
|
|
2777
|
+
if (maxValue === void 0 || val > maxValue)
|
|
2778
|
+
maxValue = val;
|
|
2779
|
+
if (minValue === void 0 || val < minValue)
|
|
2780
|
+
minValue = val;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
else if (initBar.value) {
|
|
2784
|
+
for (var _b = 0, _c = initBar.value; _b < _c.length; _b++) {
|
|
2785
|
+
var item = _c[_b];
|
|
2786
|
+
for (var _d = 0, _e = item.data; _d < _e.length; _d++) {
|
|
2787
|
+
var val = _e[_d];
|
|
2788
|
+
if (maxValue === void 0 || val > maxValue)
|
|
2789
|
+
maxValue = val;
|
|
2790
|
+
if (minValue === void 0 || val < minValue)
|
|
2791
|
+
minValue = val;
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
else {
|
|
2796
|
+
throw new Error('No data leads to parsing errors');
|
|
2797
|
+
}
|
|
2798
|
+
var rulerArray = ruler(maxValue || 0, minValue || 0, 5);
|
|
2799
|
+
var categoryLen;
|
|
2800
|
+
var valueLen;
|
|
2801
|
+
if (this.__option.category === "xAxis") {
|
|
2802
|
+
bar.coordinate.xAxis.data = initBar.category;
|
|
2803
|
+
bar.coordinate.yAxis.data = rulerArray;
|
|
2804
|
+
categoryLen = this.__option.width;
|
|
2805
|
+
valueLen = -1 * this.__option.height;
|
|
2806
|
+
}
|
|
2807
|
+
else {
|
|
2808
|
+
bar.coordinate.xAxis.data = rulerArray;
|
|
2809
|
+
bar.coordinate.yAxis.data = initBar.category;
|
|
2810
|
+
categoryLen = this.__option.height;
|
|
2811
|
+
valueLen = this.__option.width;
|
|
2812
|
+
}
|
|
2813
|
+
var category = [];
|
|
2814
|
+
var categorySingle1Width = categoryLen / initBar.category.length;
|
|
2815
|
+
var categorySingle2Width = categorySingle1Width * 0.9;
|
|
2816
|
+
var categoryStart = categorySingle1Width * 0.05;
|
|
2817
|
+
if (initBar.data) {
|
|
2818
|
+
for (var i = 0; i < initBar.data.length; i++) {
|
|
2819
|
+
category.push([
|
|
2820
|
+
categoryStart + categorySingle1Width * i,
|
|
2821
|
+
categorySingle2Width
|
|
2822
|
+
]);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
else {
|
|
2826
|
+
var categorySingle3Width = categorySingle2Width / initBar.value.length;
|
|
2827
|
+
var categorySingle4Width = categorySingle3Width * 0.9;
|
|
2828
|
+
var categoryStartBlance = categorySingle3Width * 0.05;
|
|
2829
|
+
for (var i = 0; i < initBar.value[0].data.length; i++) {
|
|
2830
|
+
category[i] = [];
|
|
2831
|
+
for (var j = 0; j < initBar.value.length; j++) {
|
|
2832
|
+
category[i].push([
|
|
2833
|
+
categoryStart + categorySingle1Width * i + categorySingle3Width * j + categoryStartBlance,
|
|
2834
|
+
categorySingle4Width
|
|
2835
|
+
]);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
var singleValueLen = valueLen / (rulerArray[rulerArray.length - 1] - rulerArray[0]);
|
|
2840
|
+
var getLenByValue = function (value) {
|
|
2841
|
+
return singleValueLen * (value - rulerArray[0]);
|
|
2842
|
+
};
|
|
2843
|
+
if (this.__option.category === "xAxis") {
|
|
2844
|
+
if (initBar.data) {
|
|
2845
|
+
var nodeBar = [];
|
|
2846
|
+
for (var i = 0; i < initBar.data.length; i++) {
|
|
2847
|
+
nodeBar.push({
|
|
2848
|
+
x: this.__option.x + category[i][0],
|
|
2849
|
+
y: this.__option.y,
|
|
2850
|
+
width: category[i][1],
|
|
2851
|
+
height: getLenByValue(initBar.data[i]),
|
|
2852
|
+
value: initBar.data[i]
|
|
2853
|
+
});
|
|
2854
|
+
}
|
|
2855
|
+
bar.node.push({
|
|
2856
|
+
bar: nodeBar
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
else {
|
|
2860
|
+
for (var j = 0; j < initBar.value.length; j++) {
|
|
2861
|
+
var nodeBar = [];
|
|
2862
|
+
for (var i = 0; i < initBar.value[j].data.length; i++) {
|
|
2863
|
+
nodeBar.push({
|
|
2864
|
+
x: this.__option.x + category[i][j][0],
|
|
2865
|
+
y: this.__option.y,
|
|
2866
|
+
width: category[i][j][1],
|
|
2867
|
+
height: getLenByValue(initBar.value[j].data[i]),
|
|
2868
|
+
value: initBar.value[j].data[i]
|
|
2869
|
+
});
|
|
2870
|
+
}
|
|
2871
|
+
bar.node.push({
|
|
2872
|
+
name: initBar.value[j].name,
|
|
2873
|
+
bar: nodeBar
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
else {
|
|
2879
|
+
if (initBar.data) {
|
|
2880
|
+
var nodeBar = [];
|
|
2881
|
+
for (var i = 0; i < initBar.data.length; i++) {
|
|
2882
|
+
nodeBar.push({
|
|
2883
|
+
x: this.__option.x,
|
|
2884
|
+
y: this.__option.y - this.__option.height + category[i][0],
|
|
2885
|
+
width: getLenByValue(initBar.data[i]),
|
|
2886
|
+
height: category[i][1],
|
|
2887
|
+
value: initBar.data[i]
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
bar.node.push({
|
|
2891
|
+
bar: nodeBar
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
else {
|
|
2895
|
+
for (var j = 0; j < initBar.value.length; j++) {
|
|
2896
|
+
var nodeBar = [];
|
|
2897
|
+
for (var i = 0; i < initBar.value[j].data.length; i++) {
|
|
2898
|
+
nodeBar.push({
|
|
2899
|
+
x: this.__option.x,
|
|
2900
|
+
y: this.__option.y - this.__option.height + category[i][j][0],
|
|
2901
|
+
width: getLenByValue(initBar.value[j].data[i]),
|
|
2902
|
+
height: category[i][j][1],
|
|
2903
|
+
value: initBar.value[j].data[i]
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
bar.node.push({
|
|
2907
|
+
name: initBar.value[j].name,
|
|
2908
|
+
bar: nodeBar
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
return bar;
|
|
2914
|
+
};
|
|
2915
|
+
BarLayout.prototype.bind = function (initBar, renderBack) {
|
|
2916
|
+
this.__rback = renderBack;
|
|
2917
|
+
this.__oralBar = initBar;
|
|
2918
|
+
this.__preBar = this.use(this.__oralBar);
|
|
2919
|
+
this.__rback(this.__preBar);
|
|
2920
|
+
return this;
|
|
2921
|
+
};
|
|
2922
|
+
BarLayout.prototype.unbind = function () {
|
|
2923
|
+
this.__rback = function () { return null; };
|
|
2924
|
+
this.__oralBar = null;
|
|
2925
|
+
this.__preBar = null;
|
|
2926
|
+
return this;
|
|
2927
|
+
};
|
|
2928
|
+
BarLayout.prototype.doUpdate = function () {
|
|
2929
|
+
var _this = this;
|
|
2930
|
+
var newBar = this.use(this.__oralBar);
|
|
2931
|
+
var cacheBar = JSON.parse(JSON.stringify(newBar));
|
|
2932
|
+
animation$1(function (deep) {
|
|
2933
|
+
if (_this.__preBar) ;
|
|
2934
|
+
_this.__rback(cacheBar);
|
|
2935
|
+
}, this.__option.duration, function () {
|
|
2936
|
+
_this.__preBar = newBar;
|
|
2937
|
+
_this.__rback(_this.__preBar);
|
|
2938
|
+
});
|
|
2939
|
+
return this;
|
|
2940
|
+
};
|
|
2941
|
+
return BarLayout;
|
|
2942
|
+
}());
|
|
2943
|
+
|
|
2594
2944
|
var index = {
|
|
2595
2945
|
Cardinal: Cardinal,
|
|
2596
2946
|
Hermite: Hermite,
|
|
@@ -2614,6 +2964,8 @@
|
|
|
2614
2964
|
assemble: assemble,
|
|
2615
2965
|
MapCoordinate: MapCoordinate,
|
|
2616
2966
|
TreeLayout: TreeLayout,
|
|
2967
|
+
PieLayout: PieLayout,
|
|
2968
|
+
BarLayout: BarLayout,
|
|
2617
2969
|
initOption: initOption,
|
|
2618
2970
|
mergeOption: mergeOption
|
|
2619
2971
|
};
|