vislite 1.2.0-alpha.0 → 1.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG +5 -1
  2. package/README.md +165 -142
  3. package/lib/Buffer/index.es.js +1 -1
  4. package/lib/Buffer/index.es.min.js +1 -1
  5. package/lib/Canvas/index.es.js +15 -5
  6. package/lib/Canvas/index.es.min.js +2 -2
  7. package/lib/Cardinal/index.es.js +1 -1
  8. package/lib/Cardinal/index.es.min.js +1 -1
  9. package/lib/Eoap/index.es.js +1 -1
  10. package/lib/Eoap/index.es.min.js +1 -1
  11. package/lib/Hermite/index.es.js +1 -1
  12. package/lib/Hermite/index.es.min.js +1 -1
  13. package/lib/Matrix4/index.es.js +1 -1
  14. package/lib/Matrix4/index.es.min.js +1 -1
  15. package/lib/Mercator/index.es.js +1 -1
  16. package/lib/Mercator/index.es.min.js +1 -1
  17. package/lib/RawCanvas/index.es.js +1 -1
  18. package/lib/RawCanvas/index.es.min.js +1 -1
  19. package/lib/SVG/index.es.js +1 -1
  20. package/lib/SVG/index.es.min.js +1 -1
  21. package/lib/Shader/index.es.js +1 -1
  22. package/lib/Shader/index.es.min.js +1 -1
  23. package/lib/Texture/index.es.js +1 -1
  24. package/lib/Texture/index.es.min.js +1 -1
  25. package/lib/TreeLayout/index.es.js +6 -6
  26. package/lib/TreeLayout/index.es.min.js +1 -1
  27. package/lib/animation/index.es.js +1 -1
  28. package/lib/animation/index.es.min.js +1 -1
  29. package/lib/assemble/index.es.d.ts +3 -0
  30. package/lib/assemble/index.es.js +23 -0
  31. package/lib/assemble/index.es.min.d.ts +3 -0
  32. package/lib/assemble/index.es.min.js +5 -0
  33. package/lib/getLoopColors/index.es.js +1 -1
  34. package/lib/getLoopColors/index.es.min.js +1 -1
  35. package/lib/getWebGLContext/index.es.js +1 -1
  36. package/lib/getWebGLContext/index.es.min.js +1 -1
  37. package/lib/index.umd.js +58 -9
  38. package/lib/index.umd.min.js +2 -2
  39. package/lib/initOption/index.es.d.ts +3 -0
  40. package/lib/initOption/index.es.js +12 -0
  41. package/lib/initOption/index.es.min.d.ts +3 -0
  42. package/lib/initOption/index.es.min.js +5 -0
  43. package/lib/mergeOption/index.es.d.ts +3 -0
  44. package/lib/mergeOption/index.es.js +42 -0
  45. package/lib/mergeOption/index.es.min.d.ts +3 -0
  46. package/lib/mergeOption/index.es.min.js +5 -0
  47. package/lib/move/index.es.js +1 -1
  48. package/lib/move/index.es.min.js +1 -1
  49. package/lib/rotate/index.es.js +1 -1
  50. package/lib/rotate/index.es.min.js +1 -1
  51. package/lib/ruler/index.es.js +1 -1
  52. package/lib/ruler/index.es.min.js +1 -1
  53. package/lib/scale/index.es.js +1 -1
  54. package/lib/scale/index.es.min.js +1 -1
  55. package/lib/throttle/index.es.js +5 -5
  56. package/lib/throttle/index.es.min.js +1 -1
  57. package/package/assemble/index.ts +3 -0
  58. package/package/index.ts +11 -1
  59. package/package/initOption/index.ts +3 -0
  60. package/package/mergeOption/index.ts +3 -0
  61. package/package.json +1 -1
  62. package/src/Canvas.ts +13 -2
  63. package/src/animation.ts +98 -98
  64. package/src/common/canvas/painter.ts +475 -475
  65. package/src/common/option.ts +30 -0
  66. package/src/common/tree/index.ts +2 -2
  67. package/src/common/type.ts +27 -0
  68. package/src/layout/TreeLayout.ts +2 -2
  69. package/src/throttle.ts +2 -2
  70. package/types/Canvas.d.ts +330 -331
  71. package/types/Matrix4.d.ts +1 -1
  72. package/types/assemble.d.ts +6 -0
  73. package/types/index.d.ts +14 -1
  74. package/types/option.d.ts +13 -0
  75. package/src/common/mergeOption.ts +0 -7
@@ -0,0 +1,42 @@
1
+ /*!
2
+ * mergeOption of VISLite JavaScript Library v1.2.0-alpha.2
3
+ * git+https://github.com/oi-contrib/VISLite.git
4
+ */
5
+ var toString = Object.prototype.toString;
6
+ function getType(value) {
7
+ if (value == null) {
8
+ return value === undefined ? '[object Undefined]' : '[object Null]';
9
+ }
10
+ return toString.call(value);
11
+ }
12
+ function isPlainObject(value) {
13
+ if (value === null || typeof value !== 'object' || getType(value) != '[object Object]') {
14
+ return false;
15
+ }
16
+ if (Object.getPrototypeOf(value) === null) {
17
+ return true;
18
+ }
19
+ var proto = value;
20
+ while (Object.getPrototypeOf(proto) !== null) {
21
+ proto = Object.getPrototypeOf(proto);
22
+ }
23
+ return Object.getPrototypeOf(value) === proto;
24
+ }
25
+
26
+ function mergeOption(oldOption, newOption) {
27
+ (function doit(oldOption, newOption) {
28
+ for (var key in newOption) {
29
+ var value = newOption[key];
30
+ if (isPlainObject(value)) {
31
+ if (!oldOption[key])
32
+ oldOption[key] = {};
33
+ doit(oldOption[key], newOption[key]);
34
+ }
35
+ else {
36
+ oldOption[key] = value;
37
+ }
38
+ }
39
+ })(oldOption, newOption);
40
+ }
41
+
42
+ export { mergeOption as default };
@@ -0,0 +1,3 @@
1
+ import { mergeOption } from "../../types/index"
2
+
3
+ export default mergeOption
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * mergeOption of VISLite JavaScript Library v1.2.0-alpha.2
3
+ * git+https://github.com/oi-contrib/VISLite.git
4
+ */
5
+ var t=Object.prototype.toString;function e(e){if(null===e||"object"!=typeof e||"[object Object]"!=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":t.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;for(var o=e;null!==Object.getPrototypeOf(o);)o=Object.getPrototypeOf(o);return Object.getPrototypeOf(e)===o}function o(t,o){!function t(o,r){for(var n in r){var c=r[n];e(c)?(o[n]||(o[n]={}),t(o[n],r[n])):o[n]=c}}(t,o)}export{o as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * move of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * move of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function move (ax, ay, d, x, y) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * move of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * move of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function t(t,r,a,e,n){var u=Math.sqrt(t*t+r*r);return[t*a/u+e,r*a/u+n]}export{t as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * rotate of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * rotate of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function rotate (cx, cy, deg, x, y) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * rotate of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * rotate of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function t(t,a,n,r,e){var o=Math.cos(n),s=Math.sin(n);return[(r-t)*o-(e-a)*s+t,(r-t)*s+(e-a)*o+a]}export{t as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ruler of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * ruler of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function ruler (maxValue, minValue, num, option) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ruler of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * ruler of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function n(n,r,t,e){if(n<r){var i=r;r=n,n=i}else if(n==r)return[n];var a=function(n){for(var r=n<100&&n>-100?10:.1,t=-1,e=n;10==r?e>=-100&&e<=100:e<=-100||e>=100;)t+=1,e*=r;if(10==r)return Math.pow(10,t);for(var i="0.",a=1;a<t;a++)i+="0";return+(i+"1")}(n-r),u=Math.ceil((n-r)*a/t),f=function(t){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}[u+t]||u+t)/a,i=Math.floor(r/e)*e,f=[];f.push(i);for(var l=1;f[f.length-1]<n;l++)f.push(i+e*l);return f},l=f(0),o=function(){for(var n=[],t=l[l.length-1]-(null==e?void 0:e.max),i=0;i<l.length;i++)i+1<l.length&&l[i+1]-t<r||n.push(l[i]-t);return n},h=function(){for(var r=[],t=l[0]-(null==e?void 0:e.min),i=0;i<l.length&&(r[i]=l[i]-t,!(n<=r[i]));i++);return r};if(e){if("max"in e&&"min"in e&&e.max>=n&&e.min<=r){var m=function(){if(l[0]>=e.min&&l[l.length-1]<=e.max)return!0;var n=o();if(n[0]>=e.min&&n[n.length-1]<=e.max)return l=n,!0;var r=h();return r[0]>=e.min&&r[n.length-1]<=e.max?(l=r,!0):void 0};if(m())return l;for(var v=1;v<100;v++){if(l=f(v),m())return l;if(l=f(-v),m())return l}}"max"in e&&e.max>=n?e.max<l[l.length-1]&&(l=o()):"min"in e&&e.min<=r&&e.min>l[0]&&(l=h())}for(var g=0;g<l.length;g++){var s=l[g]+"";/\./.test(s)&&(/9{7,}$/.test(s)?(s=s.replace(/9{7,}$/,""),l[g]=+(s.substring(0,s.length-1)+(+s[s.length-1]+1))):/0{7,}\d$/.test(s)&&(l[g]=+s.replace(/0{7,}\d$/,"")))}return l}export{n as default};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * scale of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * scale of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function scale (cx, cy, times, x, y) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * scale of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * scale of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function t(t,e,n,r,u){return[n*(r-t)+t,n*(u-e)+e]}export{t as default};
@@ -1,17 +1,17 @@
1
1
  /*!
2
- * throttle of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * throttle of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
- function mergeOption (option, defaultOption) {
6
- for (var key in option) {
7
- defaultOption[key] = option[key];
5
+ function initOption(setOption, defaultOption) {
6
+ for (var key in setOption) {
7
+ defaultOption[key] = setOption[key];
8
8
  }
9
9
  return defaultOption;
10
10
  }
11
11
 
12
12
  function throttle (callback, option) {
13
13
  if (option === void 0) { option = {}; }
14
- option = mergeOption(option, {
14
+ option = initOption(option, {
15
15
  time: 200,
16
16
  keep: false,
17
17
  opportunity: "end"
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of VISLite JavaScript Library v1.2.0-alpha.0
2
+ * throttle of VISLite JavaScript Library v1.2.0-alpha.2
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function t(t,n){void 0===n&&(n={}),n=function(t,n){for(var e in t)n[e]=t[e];return n}(n,{time:200,keep:!1,opportunity:"end"});var e,p=!1,r=!1,i=!1;return function(){var o=this;if(e=arguments,p)r=!0,i=!0;else{"end"!=n.opportunity&&t.apply(o,e),p=!0;var a=setInterval((function(){r?n.keep||t.apply(o,e):("begin"!=n.opportunity&&(i||"end"==n.opportunity)&&t.apply(o,e),p=!1,i=!1,clearInterval(a)),r=!1}),n.time)}}}export{t as default};
@@ -0,0 +1,3 @@
1
+ import assemble from "../../src/common/assemble"
2
+
3
+ export default assemble
package/package/index.ts CHANGED
@@ -26,6 +26,11 @@ import throttle from "./throttle/index"
26
26
 
27
27
  import TreeLayout from "./TreeLayout/index"
28
28
 
29
+ import initOption from "./initOption/index"
30
+ import mergeOption from "./mergeOption/index"
31
+
32
+ import assemble from "./assemble/index"
33
+
29
34
  export default {
30
35
 
31
36
  // 插值
@@ -60,7 +65,12 @@ export default {
60
65
 
61
66
  // 辅助
62
67
  throttle,
68
+ assemble,
63
69
 
64
70
  // 布局
65
- TreeLayout
71
+ TreeLayout,
72
+
73
+ // 配置项
74
+ initOption,
75
+ mergeOption
66
76
  }
@@ -0,0 +1,3 @@
1
+ import { initOption } from "../../src/common/option"
2
+
3
+ export default initOption
@@ -0,0 +1,3 @@
1
+ import { mergeOption } from "../../src/common/option"
2
+
3
+ export default mergeOption
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vislite",
3
- "version": "1.2.0-alpha.0",
3
+ "version": "1.2.0-alpha.2",
4
4
  "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
5
  "main": "./lib/index.umd.min.js",
6
6
  "typings": "./types/index.d.ts",
package/src/Canvas.ts CHANGED
@@ -2,16 +2,17 @@ import type CanvasType from '../types/Canvas'
2
2
  import type CanvasOptionType from '../types/CanvasOption'
3
3
 
4
4
  import OralCanvas from './common/canvas/index'
5
- import mergeOption from './common/mergeOption'
5
+ import { initOption } from './common/option'
6
6
 
7
7
  class Canvas extends OralCanvas implements CanvasType {
8
8
  private __canvas: HTMLCanvasElement
9
+ private __el: HTMLElement
9
10
  constructor(el: HTMLElement | null, option: CanvasOptionType = {}, width: number = 0, height: number = 0) {
10
11
  if (!el) {
11
12
  throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.")
12
13
  }
13
14
 
14
- option = mergeOption(option, {
15
+ option = initOption(option, {
15
16
  region: true,
16
17
  willReadFrequently: false
17
18
  })
@@ -61,6 +62,7 @@ class Canvas extends OralCanvas implements CanvasType {
61
62
  }, 2)
62
63
 
63
64
  this.__canvas = ViewCanvas
65
+ this.__el = el
64
66
  this.painter.scale(2, 2)
65
67
  }
66
68
 
@@ -69,6 +71,15 @@ class Canvas extends OralCanvas implements CanvasType {
69
71
  resolve(this.__canvas.toDataURL())
70
72
  })
71
73
  }
74
+
75
+ bind(eventName: string, callback: (regionName: string) => void) {
76
+ this.__el.addEventListener(eventName, (event: any) => {
77
+ this.getRegion(event.offsetX, event.offsetY).then(regionName => {
78
+ callback(regionName)
79
+ })
80
+ })
81
+ return this
82
+ }
72
83
  }
73
84
 
74
85
  export default Canvas
package/src/animation.ts CHANGED
@@ -1,99 +1,99 @@
1
- //当前正在运动的动画的tick函数堆栈
2
- let $timers: any[] = []
3
- //唯一定时器的定时间隔
4
- const $interval = 13
5
- //定时器ID
6
- let $timerId: any
7
-
8
- /**
9
- * 动画轮播
10
- * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
11
- * @param {number} duration 动画时长,可选
12
- * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
13
- *
14
- * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
15
- */
16
- export default function (doback: (deep: number) => void, duration: number = 400, callback: (deep: number) => void = () => { }): Function {
17
-
18
- const clock = {
19
- //把tick函数推入堆栈
20
- "timer": function (tick: (deep: number) => void, duration: number, callback: (deep: number) => void) {
21
- if (!tick) {
22
- throw new Error('Tick is required!')
23
- }
24
- const id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0)
25
- $timers.push({
26
- "id": id,
27
- "createTime": new Date(),
28
- "tick": tick,
29
- "duration": duration,
30
- "callback": callback
31
- });
32
- clock.start()
33
- return id
34
- },
35
-
36
- //开启唯一的定时器timerId
37
- "start": function () {
38
- if (!$timerId) {
39
- $timerId = setInterval(clock.tick, $interval)
40
- }
41
- },
42
-
43
- //被定时器调用,遍历timers堆栈
44
- "tick": function () {
45
- let createTime: Date, flag: number, tick: (deep: number) => void, callback: (deep: number) => void, timer: any, duration: number, passTime: number
46
- const timers: any[] = $timers
47
- $timers = []
48
- $timers.length = 0
49
- for (flag = 0; flag < timers.length; flag++) {
50
- //初始化数据
51
- timer = timers[flag]
52
- createTime = timer.createTime
53
- tick = timer.tick
54
- duration = timer.duration
55
- callback = timer.callback
56
-
57
- //执行
58
- passTime = (+new Date().valueOf() - createTime.valueOf()) / duration
59
- passTime = passTime > 1 ? 1 : passTime
60
- tick(passTime)
61
- if (passTime < 1 && timer.id) {
62
- //动画没有结束再添加
63
- $timers.push(timer)
64
- } else {
65
- callback(passTime)
66
- }
67
- }
68
- if ($timers.length <= 0) {
69
- clock.stop()
70
- }
71
- },
72
-
73
- //停止定时器,重置timerId=null
74
- "stop": function () {
75
- if ($timerId) {
76
- clearInterval($timerId)
77
- $timerId = null
78
- }
79
- }
80
- }
81
-
82
- const id = clock.timer(function (deep: number) {
83
- //其中deep为0-1,表示改变的程度
84
- doback(deep)
85
- }, duration, callback)
86
-
87
- // 返回一个函数
88
- // 用于在动画结束前结束动画
89
- return function () {
90
- let i: string
91
- for (i in $timers) {
92
- if ($timers[i].id == id) {
93
- $timers[i].id = void 0
94
- return
95
- }
96
- }
97
- }
98
-
1
+ //当前正在运动的动画的tick函数堆栈
2
+ let $timers: any[] = []
3
+ //唯一定时器的定时间隔
4
+ const $interval = 13
5
+ //定时器ID
6
+ let $timerId: any
7
+
8
+ /**
9
+ * 动画轮播
10
+ * @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
11
+ * @param {number} duration 动画时长,可选
12
+ * @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
13
+ *
14
+ * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
15
+ */
16
+ export default function (doback: (deep: number) => void, duration: number = 400, callback: (deep: number) => void = () => { }): Function {
17
+
18
+ const clock = {
19
+ //把tick函数推入堆栈
20
+ "timer": function (tick: (deep: number) => void, duration: number, callback: (deep: number) => void) {
21
+ if (!tick) {
22
+ throw new Error('Tick is required!')
23
+ }
24
+ const id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0)
25
+ $timers.push({
26
+ "id": id,
27
+ "createTime": new Date(),
28
+ "tick": tick,
29
+ "duration": duration,
30
+ "callback": callback
31
+ })
32
+ clock.start()
33
+ return id
34
+ },
35
+
36
+ //开启唯一的定时器timerId
37
+ "start": function () {
38
+ if (!$timerId) {
39
+ $timerId = setInterval(clock.tick, $interval)
40
+ }
41
+ },
42
+
43
+ //被定时器调用,遍历timers堆栈
44
+ "tick": function () {
45
+ let createTime: Date, flag: number, tick: (deep: number) => void, callback: (deep: number) => void, timer: any, duration: number, passTime: number
46
+ const timers: any[] = $timers
47
+ $timers = []
48
+ $timers.length = 0
49
+ for (flag = 0; flag < timers.length; flag++) {
50
+ //初始化数据
51
+ timer = timers[flag]
52
+ createTime = timer.createTime
53
+ tick = timer.tick
54
+ duration = timer.duration
55
+ callback = timer.callback
56
+
57
+ //执行
58
+ passTime = (+new Date().valueOf() - createTime.valueOf()) / duration
59
+ passTime = passTime > 1 ? 1 : passTime
60
+ tick(passTime)
61
+ if (passTime < 1 && timer.id) {
62
+ //动画没有结束再添加
63
+ $timers.push(timer)
64
+ } else {
65
+ callback(passTime)
66
+ }
67
+ }
68
+ if ($timers.length <= 0) {
69
+ clock.stop()
70
+ }
71
+ },
72
+
73
+ //停止定时器,重置timerId=null
74
+ "stop": function () {
75
+ if ($timerId) {
76
+ clearInterval($timerId)
77
+ $timerId = null
78
+ }
79
+ }
80
+ }
81
+
82
+ const id = clock.timer(function (deep: number) {
83
+ //其中deep为0-1,表示改变的程度
84
+ doback(deep)
85
+ }, duration, callback)
86
+
87
+ // 返回一个函数
88
+ // 用于在动画结束前结束动画
89
+ return function () {
90
+ let i: string
91
+ for (i in $timers) {
92
+ if ($timers[i].id == id) {
93
+ $timers[i].id = void 0
94
+ return
95
+ }
96
+ }
97
+ }
98
+
99
99
  }