vislite 1.1.0 → 1.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG +250 -244
  2. package/README.md +142 -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 +26 -1
  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 +26 -1
  18. package/lib/RawCanvas/index.es.min.js +2 -2
  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 +1 -1
  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/getLoopColors/index.es.js +1 -1
  30. package/lib/getLoopColors/index.es.min.js +1 -1
  31. package/lib/getWebGLContext/index.es.js +1 -1
  32. package/lib/getWebGLContext/index.es.min.js +1 -1
  33. package/lib/index.umd.js +26 -1
  34. package/lib/index.umd.min.js +2 -2
  35. package/lib/move/index.es.js +1 -1
  36. package/lib/move/index.es.min.js +1 -1
  37. package/lib/rotate/index.es.js +1 -1
  38. package/lib/rotate/index.es.min.js +1 -1
  39. package/lib/ruler/index.es.js +1 -1
  40. package/lib/ruler/index.es.min.js +1 -1
  41. package/lib/scale/index.es.js +1 -1
  42. package/lib/scale/index.es.min.js +1 -1
  43. package/lib/throttle/index.es.js +1 -1
  44. package/lib/throttle/index.es.min.js +1 -1
  45. package/miniprogram/ui-canvas/index.js +115 -115
  46. package/package/RawCanvas/index.ts +2 -2
  47. package/package.json +73 -73
  48. package/src/common/canvas/painter.ts +20 -0
  49. package/types/Canvas.d.ts +8 -0
  50. package/uni-app/ui-canvas.vue +284 -284
@@ -1,115 +1,115 @@
1
- import RawCanvas from "../../lib/RawCanvas/index.es.min.js";
2
- import drawImage from "./drawImage.js";
3
-
4
- let dpr = wx.getSystemInfoSync().pixelRatio;
5
-
6
- Component({
7
- properties: {
8
- width: {
9
- type: Number,
10
- default: 300
11
- },
12
- height: {
13
- type: Number,
14
- default: 150
15
- },
16
- region: {
17
- type: Boolean,
18
- default: true
19
- }
20
- },
21
- data: {
22
- help: {}
23
- },
24
- lifetimes: {
25
- ready() {
26
-
27
- }
28
- },
29
- methods: {
30
- fetch() {
31
- return new Promise((resolve, reject) => {
32
-
33
- let getCanvasContext = (idName, doback) => {
34
- if (idName != 'region' || this.data.region) {
35
- const query = wx.createSelectorQuery().in(this);
36
- query.select('#' + idName)
37
- .fields({ node: true, size: true })
38
- .exec((res) => {
39
- const canvas = res[0].node;
40
- const ctx = canvas.getContext('2d');
41
-
42
- canvas.width = res[0].width * (idName == "region" ? 1 : dpr);
43
- canvas.height = res[0].height * (idName == "region" ? 1 : dpr);
44
-
45
- if (idName != "region") {
46
- ctx.scale(dpr, dpr);
47
- }
48
-
49
- doback(ctx, idName != 'region' ? canvas : null);
50
- });
51
- } else {
52
- doback(null);
53
- }
54
- };
55
-
56
- getCanvasContext("painter", (painter, panvas) => {
57
- getCanvasContext("region", region => {
58
- this.data.help.instance = new RawCanvas({
59
- getContext() {
60
- return painter;
61
- }
62
- }, this.data.region ? {
63
- getContext() {
64
- return region;
65
- }
66
- } : null);
67
-
68
- this.data.help.instance.toDataURL = () => {
69
- return new Promise((resolveUrl) => {
70
- if (panvas.toDataURL) {
71
- resolveUrl(panvas.toDataURL());
72
- } else {
73
- wx.canvasToTempFilePath({
74
- canvasId: "painter",
75
- success: function (e) {
76
- resolveUrl(e.tempFilePath);
77
- },
78
- fail: function (e) {
79
- console.log(e)
80
- }
81
- }, this);
82
- }
83
- });
84
- };
85
-
86
- this.data.help.instance.drawImage = drawImage(
87
- this.data.help.instance,
88
- this.data.help.instance.drawImage,
89
- panvas
90
- );
91
-
92
- resolve(this.data.help.instance);
93
- });
94
- });
95
-
96
- });
97
- },
98
- doit(event) {
99
- let x = event.touches[0].x;
100
- let y = event.touches[0].y;
101
-
102
- this.data.help.instance.getRegion(x, y).then((regionName) => {
103
- this.triggerEvent('dotouchstart', {
104
- name: regionName,
105
- x: x,
106
- y: y
107
- })
108
- });
109
- },
110
- doitstart(event) {
111
- this.doit(event);
112
- }
113
- }
114
-
115
- });
1
+ import RawCanvas from "../../lib/RawCanvas/index.es.min.js";
2
+ import drawImage from "./drawImage.js";
3
+
4
+ let dpr = wx.getSystemInfoSync().pixelRatio;
5
+
6
+ Component({
7
+ properties: {
8
+ width: {
9
+ type: Number,
10
+ default: 300
11
+ },
12
+ height: {
13
+ type: Number,
14
+ default: 150
15
+ },
16
+ region: {
17
+ type: Boolean,
18
+ default: true
19
+ }
20
+ },
21
+ data: {
22
+ help: {}
23
+ },
24
+ lifetimes: {
25
+ ready() {
26
+
27
+ }
28
+ },
29
+ methods: {
30
+ fetch() {
31
+ return new Promise((resolve, reject) => {
32
+
33
+ let getCanvasContext = (idName, doback) => {
34
+ if (idName != 'region' || this.data.region) {
35
+ const query = wx.createSelectorQuery().in(this);
36
+ query.select('#' + idName)
37
+ .fields({ node: true, size: true })
38
+ .exec((res) => {
39
+ const canvas = res[0].node;
40
+ const ctx = canvas.getContext('2d');
41
+
42
+ canvas.width = res[0].width * (idName == "region" ? 1 : dpr);
43
+ canvas.height = res[0].height * (idName == "region" ? 1 : dpr);
44
+
45
+ if (idName != "region") {
46
+ ctx.scale(dpr, dpr);
47
+ }
48
+
49
+ doback(ctx, idName != 'region' ? canvas : null);
50
+ });
51
+ } else {
52
+ doback(null);
53
+ }
54
+ };
55
+
56
+ getCanvasContext("painter", (painter, panvas) => {
57
+ getCanvasContext("region", region => {
58
+ this.data.help.instance = new RawCanvas({
59
+ getContext() {
60
+ return painter;
61
+ }
62
+ }, this.data.region ? {
63
+ getContext() {
64
+ return region;
65
+ }
66
+ } : null);
67
+
68
+ this.data.help.instance.toDataURL = () => {
69
+ return new Promise((resolveUrl) => {
70
+ if (panvas.toDataURL) {
71
+ resolveUrl(panvas.toDataURL());
72
+ } else {
73
+ wx.canvasToTempFilePath({
74
+ canvasId: "painter",
75
+ success: function (e) {
76
+ resolveUrl(e.tempFilePath);
77
+ },
78
+ fail: function (e) {
79
+ console.log(e)
80
+ }
81
+ }, this);
82
+ }
83
+ });
84
+ };
85
+
86
+ this.data.help.instance.drawImage = drawImage(
87
+ this.data.help.instance,
88
+ this.data.help.instance.drawImage,
89
+ panvas
90
+ );
91
+
92
+ resolve(this.data.help.instance);
93
+ });
94
+ });
95
+
96
+ });
97
+ },
98
+ doit(event) {
99
+ let x = event.touches[0].x;
100
+ let y = event.touches[0].y;
101
+
102
+ this.data.help.instance.getRegion(x, y).then((regionName) => {
103
+ this.triggerEvent('dotouchstart', {
104
+ name: regionName,
105
+ x: x,
106
+ y: y
107
+ })
108
+ });
109
+ },
110
+ doitstart(event) {
111
+ this.doit(event);
112
+ }
113
+ }
114
+
115
+ });
@@ -1,3 +1,3 @@
1
- import RawCanvas from "../../src/common/canvas/index"
2
-
1
+ import RawCanvas from "../../src/common/canvas/index"
2
+
3
3
  export default RawCanvas
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
- {
2
- "name": "vislite",
3
- "version": "1.1.0",
4
- "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
- "main": "./lib/index.umd.min.js",
6
- "typings": "./types/index.d.ts",
7
- "unpkg": "./lib/index.umd.min.js",
8
- "jsdelivr":"./lib/index.umd.min.js",
9
- "sideEffects": false,
10
- "scripts": {
11
- "init": "npm install && devby --copy ./node_modules/pageby/dist/pageby.min.js ./docs/js/min/pageby.min.js",
12
- "dev": "webpack serve --config ./build/webpack.config.js",
13
- "build": "devby --delete ./lib && node ./build/pkg.js",
14
- "test": "karma start ./build/karma.config.js",
15
- "lint": "eslint src/**/*.ts --fix"
16
- },
17
- "miniprogram": ".",
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/oi-contrib/VISLite.git"
21
- },
22
- "keywords": [
23
- "svg",
24
- "webgl",
25
- "typescript",
26
- "canvas",
27
- "vue",
28
- "uniapp",
29
- "miniprogram",
30
- "image2d",
31
- "image3d",
32
- "oi-contrib",
33
- "vislite",
34
- "d3",
35
- "zxl20070701",
36
- "three",
37
- "echarts",
38
- "datav",
39
- "webgpu",
40
- "layout",
41
- "algorithm"
42
- ],
43
- "author": {
44
- "name": "zxl20070701",
45
- "url": "https://zxl20070701.github.io/notebook/home.html"
46
- },
47
- "license": "MIT",
48
- "bugs": {
49
- "url": "https://github.com/oi-contrib/VISLite/issues"
50
- },
51
- "homepage": "https://oi-contrib.github.io/VISLite",
52
- "devDependencies": {
53
- "@rollup/plugin-typescript": "^11.1.0",
54
- "@types/jasmine": "^4.3.1",
55
- "@typescript-eslint/eslint-plugin": "^6.14.0",
56
- "@typescript-eslint/parser": "^6.14.0",
57
- "devby": "^0.4.6",
58
- "eslint": "^8.56.0",
59
- "karma": "^6.3.10",
60
- "karma-chrome-launcher": "^3.1.0",
61
- "karma-jasmine": "^4.0.1",
62
- "karma-webpack": "^5.0.0",
63
- "pageby": "^0.1.0",
64
- "rollup": "^3.20.6",
65
- "terser": "^5.17.1",
66
- "ts-loader": "^9.2.8",
67
- "tslib": "^2.5.0",
68
- "typescript": "^4.6.2",
69
- "webpack": "^5.70.0",
70
- "webpack-cli": "^4.9.2",
71
- "webpack-dev-server": "^4.7.4"
72
- }
73
- }
1
+ {
2
+ "name": "vislite",
3
+ "version": "1.2.0-alpha.0",
4
+ "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
+ "main": "./lib/index.umd.min.js",
6
+ "typings": "./types/index.d.ts",
7
+ "unpkg": "./lib/index.umd.min.js",
8
+ "jsdelivr":"./lib/index.umd.min.js",
9
+ "sideEffects": false,
10
+ "scripts": {
11
+ "init": "npm install && devby --copy ./node_modules/pageby/dist/pageby.min.js ./docs/js/min/pageby.min.js",
12
+ "dev": "webpack serve --config ./build/webpack.config.js",
13
+ "build": "devby --delete ./lib && node ./build/pkg.js",
14
+ "test": "karma start ./build/karma.config.js",
15
+ "lint": "eslint src/**/*.ts --fix"
16
+ },
17
+ "miniprogram": ".",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/oi-contrib/VISLite.git"
21
+ },
22
+ "keywords": [
23
+ "svg",
24
+ "webgl",
25
+ "typescript",
26
+ "canvas",
27
+ "vue",
28
+ "uniapp",
29
+ "miniprogram",
30
+ "image2d",
31
+ "image3d",
32
+ "oi-contrib",
33
+ "vislite",
34
+ "d3",
35
+ "zxl20070701",
36
+ "three",
37
+ "echarts",
38
+ "datav",
39
+ "webgpu",
40
+ "layout",
41
+ "algorithm"
42
+ ],
43
+ "author": {
44
+ "name": "zxl20070701",
45
+ "url": "https://zxl20070701.github.io/notebook/home.html"
46
+ },
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/oi-contrib/VISLite/issues"
50
+ },
51
+ "homepage": "https://oi-contrib.github.io/VISLite",
52
+ "devDependencies": {
53
+ "@rollup/plugin-typescript": "^11.1.0",
54
+ "@types/jasmine": "^4.3.1",
55
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
56
+ "@typescript-eslint/parser": "^6.14.0",
57
+ "devby": "^0.4.6",
58
+ "eslint": "^8.56.0",
59
+ "karma": "^6.3.10",
60
+ "karma-chrome-launcher": "^3.1.0",
61
+ "karma-jasmine": "^4.0.1",
62
+ "karma-webpack": "^5.0.0",
63
+ "pageby": "^0.1.0",
64
+ "rollup": "^3.20.6",
65
+ "terser": "^5.17.1",
66
+ "ts-loader": "^9.2.8",
67
+ "tslib": "^2.5.0",
68
+ "typescript": "^4.6.2",
69
+ "webpack": "^5.70.0",
70
+ "webpack-cli": "^4.9.2",
71
+ "webpack-dev-server": "^4.7.4"
72
+ }
73
+ }
@@ -451,6 +451,26 @@ class Painter {
451
451
 
452
452
  })
453
453
  }
454
+
455
+ // 扩展绘制方法
456
+ install(methods: {
457
+ [key: string]: Function
458
+ }) {
459
+ for (let key in methods) {
460
+
461
+ if (key in this) {
462
+ throw new Error("VISLite Canvas:Method already exists and cannot be overwritten.")
463
+ } else {
464
+ this[key] = (...args: any) => {
465
+ let value = methods[key].apply(this, args)
466
+ if (value != void 0) return value
467
+ return this
468
+ }
469
+ }
470
+
471
+ }
472
+ return this
473
+ }
454
474
  }
455
475
 
456
476
  export default Painter
package/types/Canvas.d.ts CHANGED
@@ -320,4 +320,12 @@ export default interface CanvasType {
320
320
  * @param h
321
321
  */
322
322
  drawImage(img: CanvasImageSource | string, x: number, y: number, w: number, h: number, isUniapp?: boolean): Promise<any>
323
+
324
+ /**
325
+ * 扩展绘制方法
326
+ * @param methods 扩展的方法列表
327
+ */
328
+ install(methods: {
329
+ [key: string]: Function
330
+ }): this
323
331
  }