@cloudbase/weda-ui 0.2.16 → 0.2.17

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 (86) hide show
  1. package/README.md +39 -170
  2. package/package.json +17 -10
  3. package/src/configs/components/chart/bar.json +711 -0
  4. package/src/configs/components/chart/line.json +666 -0
  5. package/src/configs/components/chart/pie.json +487 -0
  6. package/src/configs/components/listView.json +2 -1
  7. package/src/configs/index.js +7 -0
  8. package/src/mp/components/chart/bar/index.js +254 -0
  9. package/src/mp/components/chart/bar/index.json +6 -0
  10. package/src/mp/components/chart/bar/index.wxml +3 -0
  11. package/src/mp/components/chart/bar/index.wxss +9 -0
  12. package/src/mp/components/chart/common/config/bar.js +50 -0
  13. package/src/mp/components/chart/common/config/global.js +16 -0
  14. package/src/mp/components/chart/common/config/line.js +48 -0
  15. package/src/mp/components/chart/common/config/pie.js +36 -0
  16. package/src/mp/components/chart/common/core/eChartBar.js +262 -0
  17. package/src/mp/components/chart/common/core/eChartBase.js +371 -0
  18. package/src/mp/components/chart/common/core/eChartLine.js +228 -0
  19. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  20. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  21. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  22. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  23. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  24. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  25. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  26. package/src/mp/components/chart/line/index.js +243 -0
  27. package/src/mp/components/chart/line/index.json +6 -0
  28. package/src/mp/components/chart/line/index.wxml +3 -0
  29. package/src/mp/components/chart/line/index.wxss +9 -0
  30. package/src/mp/components/chart/pie/index.js +178 -0
  31. package/src/mp/components/chart/pie/index.json +6 -0
  32. package/src/mp/components/chart/pie/index.wxml +4 -0
  33. package/src/mp/components/chart/pie/index.wxss +9 -0
  34. package/src/mp/components/dataView/index.json +1 -1
  35. package/src/mp/components/form/radio/index.js +5 -0
  36. package/src/mp/components/form/select/index.wxml +4 -4
  37. package/src/mp/components/form/textarea/index.wxml +6 -5
  38. package/src/mp/components/form/uploader/index.js +42 -22
  39. package/src/mp/components/form/uploader/index.wxml +15 -3
  40. package/src/mp/components/form/uploaderFile/index.js +58 -30
  41. package/src/mp/components/graphicCard/index.js +26 -28
  42. package/src/mp/components/internals/listView/arrow-right-line.svg +3 -0
  43. package/src/mp/components/internals/listView/index.js +286 -0
  44. package/src/mp/components/internals/listView/index.json +4 -0
  45. package/src/mp/components/internals/listView/index.wxml +40 -0
  46. package/src/mp/components/internals/listView/index.wxss +150 -0
  47. package/src/mp/components/internals/listView/more-line.svg +3 -0
  48. package/src/mp/components/listView/index.js +17 -24
  49. package/src/mp/components/listView/index.wxml +1 -1
  50. package/src/mp/components/navLayout/index.js +3 -3
  51. package/src/mp/index.json +3 -0
  52. package/src/mp/utils/platform.js +15 -0
  53. package/src/setupTests.js +2 -1
  54. package/src/web/components/chart/bar/index.tsx +139 -0
  55. package/src/web/components/chart/common/config/bar.js +49 -0
  56. package/src/web/components/chart/common/config/global.js +16 -0
  57. package/src/web/components/chart/common/config/line.js +50 -0
  58. package/src/web/components/chart/common/config/pie.js +37 -0
  59. package/src/web/components/chart/common/core/eChartBar.js +264 -0
  60. package/src/web/components/chart/common/core/eChartBase.ts +379 -0
  61. package/src/web/components/chart/common/core/eChartLine.js +229 -0
  62. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  63. package/src/web/components/chart/common/core/type.ts +34 -0
  64. package/src/web/components/chart/common/echart.css +106 -0
  65. package/src/web/components/chart/common/echarts.ts +33 -0
  66. package/src/web/components/chart/common/useChart.tsx +69 -0
  67. package/src/web/components/chart/line/index.tsx +135 -0
  68. package/src/web/components/chart/pie/index.tsx +99 -0
  69. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
  70. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
  71. package/src/web/components/form/select/h5.tsx +3 -1
  72. package/src/web/components/form/select/time.jsx +1 -0
  73. package/src/web/components/form/uploader/uploader.h5.tsx +19 -17
  74. package/src/web/components/form/uploader/uploader.pc.tsx +13 -16
  75. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +35 -37
  76. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +15 -21
  77. package/src/web/components/graphicCard/index.css +1 -5
  78. package/src/web/components/graphicCard/index.tsx +4 -3
  79. package/src/web/components/index.js +5 -2
  80. package/src/web/utils/platform.js +1 -1
  81. package/src/web/utils/tcb.js +3 -15
  82. package/CHANGELOG.md +0 -240
  83. package/src/.DS_Store +0 -0
  84. package/src/configs/.DS_Store +0 -0
  85. package/src/mp/.gitignore +0 -10
  86. package/src/web/.DS_Store +0 -0
@@ -0,0 +1,277 @@
1
+ import WxCanvas from './wx-canvas';
2
+ import * as echarts from '../common/lib/echarts.min';
3
+
4
+ let ctx;
5
+
6
+ function compareVersion(v1, v2) {
7
+ v1 = v1.split('.');
8
+ v2 = v2.split('.');
9
+ const len = Math.max(v1.length, v2.length);
10
+
11
+ while (v1.length < len) {
12
+ v1.push('0');
13
+ }
14
+ while (v2.length < len) {
15
+ v2.push('0');
16
+ }
17
+
18
+ for (let i = 0; i < len; i++) {
19
+ const num1 = parseInt(v1[i]);
20
+ const num2 = parseInt(v2[i]);
21
+
22
+ if (num1 > num2) {
23
+ return 1;
24
+ } else if (num1 < num2) {
25
+ return -1;
26
+ }
27
+ }
28
+ return 0;
29
+ }
30
+
31
+ Component({
32
+ properties: {
33
+ canvasId: {
34
+ type: String,
35
+ value: 'ec-canvas',
36
+ },
37
+
38
+ ec: {
39
+ type: Object,
40
+ },
41
+
42
+ forceUseOldCanvas: {
43
+ type: Boolean,
44
+ value: false,
45
+ },
46
+ },
47
+
48
+ data: {
49
+ isUseNewCanvas: false,
50
+ },
51
+
52
+ ready: function () {
53
+ // Disable prograssive because drawImage doesn't support DOM as parameter
54
+ // See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
55
+ echarts.registerPreprocessor((option) => {
56
+ if (option && option.series) {
57
+ if (option.series.length > 0) {
58
+ option.series.forEach((series) => {
59
+ series.progressive = 0;
60
+ });
61
+ } else if (typeof option.series === 'object') {
62
+ option.series.progressive = 0;
63
+ }
64
+ }
65
+ });
66
+
67
+ if (!this.data.ec) {
68
+ console.warn(
69
+ '组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" ' +
70
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>'
71
+ );
72
+ return;
73
+ }
74
+
75
+ if (!this.data.ec.lazyLoad) {
76
+ this.init();
77
+ }
78
+ },
79
+
80
+ methods: {
81
+ init: function (callback) {
82
+ const version = wx.getSystemInfoSync().SDKVersion;
83
+
84
+ const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
85
+ const forceUseOldCanvas = this.data.forceUseOldCanvas;
86
+ const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
87
+ this.setData({ isUseNewCanvas });
88
+
89
+ if (forceUseOldCanvas && canUseNewCanvas) {
90
+ console.warn('开发者强制使用旧canvas,建议关闭');
91
+ }
92
+
93
+ if (isUseNewCanvas) {
94
+ // console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
95
+ // 2.9.0 可以使用 <canvas type="2d"></canvas>
96
+ this.initByNewWay(callback);
97
+ } else {
98
+ const isValid = compareVersion(version, '1.9.91') >= 0;
99
+ if (!isValid) {
100
+ console.error(
101
+ '微信基础库版本过低,需大于等于 1.9.91。' +
102
+ '参见:https://github.com/ecomfe/echarts-for-weixin' +
103
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82'
104
+ );
105
+ return;
106
+ } else {
107
+ console.warn(
108
+ '建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能'
109
+ );
110
+ this.initByOldWay(callback);
111
+ }
112
+ }
113
+ },
114
+
115
+ initByOldWay(callback) {
116
+ // 1.9.91 <= version < 2.9.0:原来的方式初始化
117
+ ctx = wx.createCanvasContext(this.data.canvasId, this);
118
+ const canvas = new WxCanvas(ctx, this.data.canvasId, false);
119
+
120
+ echarts.setCanvasCreator(() => {
121
+ return canvas;
122
+ });
123
+ // const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
124
+ const canvasDpr = 1;
125
+ var query = wx.createSelectorQuery().in(this);
126
+ query
127
+ .select('.ec-canvas')
128
+ .boundingClientRect(async (res) => {
129
+ if (typeof callback === 'function') {
130
+ this.chart = callback(canvas, res.width, res.height, canvasDpr);
131
+ } else if (
132
+ this.data.ec &&
133
+ typeof this.data.ec.onInit === 'function'
134
+ ) {
135
+ this.chart = await this.data.ec.onInit(
136
+ canvas,
137
+ res.width,
138
+ res.height,
139
+ canvasDpr
140
+ );
141
+ } else {
142
+ this.triggerEvent('init', {
143
+ canvas: canvas,
144
+ width: res.width,
145
+ height: res.height,
146
+ canvasDpr: canvasDpr, // 增加了dpr,可方便外面echarts.init
147
+ });
148
+ }
149
+ })
150
+ .exec();
151
+ },
152
+
153
+ initByNewWay(callback) {
154
+ // version >= 2.9.0:使用新的方式初始化
155
+ const query = wx.createSelectorQuery().in(this);
156
+ query
157
+ .select('.ec-canvas')
158
+ .fields({ node: true, size: true })
159
+ .exec(async (res) => {
160
+ const canvasNode = res[0].node;
161
+ this.canvasNode = canvasNode;
162
+
163
+ const canvasDpr = wx.getSystemInfoSync().pixelRatio;
164
+ const canvasWidth = res[0].width;
165
+ const canvasHeight = res[0].height;
166
+
167
+ const ctx = canvasNode.getContext('2d');
168
+
169
+ const canvas = new WxCanvas(
170
+ ctx,
171
+ this.data.canvasId,
172
+ true,
173
+ canvasNode
174
+ );
175
+ echarts.setCanvasCreator(() => {
176
+ return canvas;
177
+ });
178
+
179
+ if (typeof callback === 'function') {
180
+ this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr);
181
+ } else if (
182
+ this.data.ec &&
183
+ typeof this.data.ec.onInit === 'function'
184
+ ) {
185
+ this.chart = await this.data.ec.onInit(
186
+ canvas,
187
+ canvasWidth,
188
+ canvasHeight,
189
+ canvasDpr
190
+ );
191
+ } else {
192
+ this.triggerEvent('init', {
193
+ canvas: canvas,
194
+ width: canvasWidth,
195
+ height: canvasHeight,
196
+ dpr: canvasDpr,
197
+ });
198
+ }
199
+ });
200
+ },
201
+ canvasToTempFilePath(opt) {
202
+ if (this.data.isUseNewCanvas) {
203
+ // 新版
204
+ const query = wx.createSelectorQuery().in(this);
205
+ query
206
+ .select('.ec-canvas')
207
+ .fields({ node: true, size: true })
208
+ .exec((res) => {
209
+ const canvasNode = res[0].node;
210
+ opt.canvas = canvasNode;
211
+ wx.canvasToTempFilePath(opt);
212
+ });
213
+ } else {
214
+ // 旧的
215
+ if (!opt.canvasId) {
216
+ opt.canvasId = this.data.canvasId;
217
+ }
218
+ ctx.draw(true, () => {
219
+ wx.canvasToTempFilePath(opt, this);
220
+ });
221
+ }
222
+ },
223
+
224
+ touchStart(e) {
225
+ if (this.chart && e.touches.length > 0) {
226
+ var touch = e.touches[0];
227
+ var handler = this.chart.getZr().handler;
228
+ handler.dispatch('mousedown', {
229
+ zrX: touch.x,
230
+ zrY: touch.y,
231
+ });
232
+ handler.dispatch('mousemove', {
233
+ zrX: touch.x,
234
+ zrY: touch.y,
235
+ });
236
+ handler.processGesture(wrapTouch(e), 'start');
237
+ }
238
+ },
239
+
240
+ touchMove(e) {
241
+ if (this.chart && e.touches.length > 0) {
242
+ var touch = e.touches[0];
243
+ var handler = this.chart.getZr().handler;
244
+ handler.dispatch('mousemove', {
245
+ zrX: touch.x,
246
+ zrY: touch.y,
247
+ });
248
+ handler.processGesture(wrapTouch(e), 'change');
249
+ }
250
+ },
251
+
252
+ touchEnd(e) {
253
+ if (this.chart) {
254
+ const touch = e.changedTouches ? e.changedTouches[0] : {};
255
+ var handler = this.chart.getZr().handler;
256
+ handler.dispatch('mouseup', {
257
+ zrX: touch.x,
258
+ zrY: touch.y,
259
+ });
260
+ handler.dispatch('click', {
261
+ zrX: touch.x,
262
+ zrY: touch.y,
263
+ });
264
+ handler.processGesture(wrapTouch(e), 'end');
265
+ }
266
+ },
267
+ },
268
+ });
269
+
270
+ function wrapTouch(event) {
271
+ for (let i = 0; i < event.touches.length; ++i) {
272
+ const touch = event.touches[i];
273
+ touch.offsetX = touch.x;
274
+ touch.offsetY = touch.y;
275
+ }
276
+ return event;
277
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,4 @@
1
+ <!-- 新的:接口对齐了H5 -->
2
+ <canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
3
+ <!-- 旧的 -->
4
+ <canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
@@ -0,0 +1,4 @@
1
+ .ec-canvas {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
@@ -0,0 +1,107 @@
1
+ class WxCanvas {
2
+ constructor(ctx, canvasId, isNew, canvasNode) {
3
+ this.ctx = ctx;
4
+ this.canvasId = canvasId;
5
+ this.chart = null;
6
+ this.isNew = isNew;
7
+ if (isNew) {
8
+ this.canvasNode = canvasNode;
9
+ }
10
+ else {
11
+ this._initStyle(ctx);
12
+ }
13
+
14
+ // this._initCanvas(zrender, ctx);
15
+
16
+ this._initEvent();
17
+ }
18
+
19
+ getContext(contextType) {
20
+ if (contextType === '2d') {
21
+ return this.ctx;
22
+ }
23
+ }
24
+
25
+ // canvasToTempFilePath(opt) {
26
+ // if (!opt.canvasId) {
27
+ // opt.canvasId = this.canvasId;
28
+ // }
29
+ // return wx.canvasToTempFilePath(opt, this);
30
+ // }
31
+
32
+ setChart(chart) {
33
+ this.chart = chart;
34
+ }
35
+
36
+ attachEvent() {
37
+ // noop
38
+ }
39
+
40
+ detachEvent() {
41
+ // noop
42
+ }
43
+
44
+ _initCanvas(zrender, ctx) {
45
+ zrender.util.getContext = function () {
46
+ return ctx;
47
+ };
48
+
49
+ zrender.util.$override('measureText', function (text, font) {
50
+ ctx.font = font || '12px sans-serif';
51
+ return ctx.measureText(text);
52
+ });
53
+ }
54
+
55
+ _initStyle(ctx) {
56
+ ctx.createRadialGradient = () => {
57
+ return ctx.createCircularGradient(arguments);
58
+ };
59
+ }
60
+
61
+ _initEvent() {
62
+ this.event = {};
63
+ const eventNames = [{
64
+ wxName: 'touchStart',
65
+ ecName: 'mousedown'
66
+ }, {
67
+ wxName: 'touchMove',
68
+ ecName: 'mousemove'
69
+ }, {
70
+ wxName: 'touchEnd',
71
+ ecName: 'mouseup'
72
+ }, {
73
+ wxName: 'touchEnd',
74
+ ecName: 'click'
75
+ }];
76
+
77
+ eventNames.forEach(name => {
78
+ this.event[name.wxName] = e => {
79
+ const touch = e.touches[0];
80
+ this.chart.getZr().handler.dispatch(name.ecName, {
81
+ zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
82
+ zrY: name.wxName === 'tap' ? touch.clientY : touch.y
83
+ });
84
+ };
85
+ });
86
+ }
87
+
88
+ set width(w) {
89
+ if (this.canvasNode) this.canvasNode.width = w;
90
+ }
91
+ set height(h) {
92
+ if (this.canvasNode) this.canvasNode.height = h;
93
+ }
94
+
95
+ get width() {
96
+ if (this.canvasNode)
97
+ return this.canvasNode.width;
98
+ return 0;
99
+ }
100
+ get height() {
101
+ if (this.canvasNode)
102
+ return this.canvasNode.height;
103
+ return 0;
104
+ }
105
+ }
106
+
107
+ export default WxCanvas;
@@ -0,0 +1,243 @@
1
+ import * as echarts from '../common/lib/echarts.min';
2
+ import EchartLine from '../common/core/eChartLine';
3
+ Component({
4
+ options: {
5
+ virtualHost: true,
6
+ multipleSlots: true,
7
+ },
8
+ properties: {
9
+ id: {
10
+ type: String,
11
+ value: '',
12
+ },
13
+ className: {
14
+ type: String,
15
+ value: '',
16
+ },
17
+ style: {
18
+ type: String,
19
+ value: '',
20
+ },
21
+ chartType: {
22
+ // 线条类型
23
+ type: String,
24
+ value: 'bight',
25
+ },
26
+ title: {
27
+ // 图表标题
28
+ type: String,
29
+ },
30
+ isTitle: {
31
+ // 是否显示标题
32
+ type: Boolean,
33
+ value: false,
34
+ },
35
+ titleLocation: {
36
+ type: String,
37
+ value: 'top',
38
+ },
39
+ dataSource: {
40
+ // 数据源
41
+ type: Object,
42
+ },
43
+ filterData: {
44
+ // 数据筛选
45
+ type: Array,
46
+ value: [],
47
+ },
48
+ xField: {
49
+ // x轴字段选择
50
+ type: Object,
51
+ value: {
52
+ format: '',
53
+ type: '', // 数据源字段 类型
54
+ title: '', // 字段名中文
55
+ name: '', // 字段名英文
56
+ },
57
+ },
58
+ xStatistics: {
59
+ // x轴统计维度
60
+ type: String,
61
+ value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
62
+ },
63
+ groupKey: {
64
+ // x轴字段选择
65
+ type: Object,
66
+ value: {
67
+ format: '',
68
+ type: '', // 数据源字段 类型
69
+ title: '', // 字段名中文
70
+ name: '', // 字段名英文
71
+ },
72
+ },
73
+ groupKeyTimeSpan: {
74
+ // x轴统计维度
75
+ type: String,
76
+ value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
77
+ },
78
+ xIsCountEmpty: {
79
+ // x轴 是否统计空值
80
+ type: Boolean,
81
+ value: false,
82
+ },
83
+ yField: {
84
+ // Y轴字段,分组字段,是否分组
85
+ type: Object,
86
+ value: {
87
+ numValue: [{ key: '', operationType: '' }],
88
+ groupKey: '',
89
+ },
90
+ },
91
+ isLegend: {
92
+ // 是否显示图例
93
+ type: Boolean,
94
+ value: false,
95
+ },
96
+ legend: {
97
+ // 图例
98
+ type: String,
99
+ value: 'bottom', // 左 left 右right, 上top,下 bottom
100
+ },
101
+
102
+ // 高级属性
103
+ isXaxisName: {
104
+ // 是否显示坐标轴名称
105
+ type: Boolean,
106
+ value: true,
107
+ },
108
+ xAxisName: {
109
+ // 是否显示坐标轴名称
110
+ type: String,
111
+ value: '',
112
+ },
113
+ isXaxisAxisLabelShow: {
114
+ // 是否显示标签
115
+ type: Boolean,
116
+ value: true,
117
+ },
118
+ isXaxisAxisTickShow: {
119
+ // 显示X轴刻度线
120
+ type: Boolean,
121
+ value: true,
122
+ },
123
+ isXaxisAxisLabelRotate: {
124
+ // 文字自动倾斜
125
+ type: Boolean,
126
+ value: false,
127
+ },
128
+ isYAxisShow: {
129
+ // 是否显示 Y 轴刻度线
130
+ type: Boolean,
131
+ value: true,
132
+ },
133
+ isYAxisName: {
134
+ // 是否显示 Y坐标轴名称
135
+ type: Boolean,
136
+ value: true,
137
+ },
138
+ isYAxisSplitlineLinestyleWidth: {
139
+ // 是否显示网格线 ,yAxis.splitLine.lineStyle.width设置为0
140
+ type: Boolean,
141
+ value: true,
142
+ },
143
+ yAxisSplitlineLinestyleType: {
144
+ // 网格线线条类型 solid,dashed,dotted
145
+ type: String,
146
+ value: 'dashed',
147
+ },
148
+ yAxisName: {
149
+ // Y坐标轴名称 显示名称后需要设置居中,轴线距离属性 yAxis.nameLocation='middle' yAxis.nameGap =20
150
+ type: String,
151
+ value: '',
152
+ },
153
+ yAxisMin: {
154
+ // Y轴刻度最小值
155
+ type: Number,
156
+ value: 0,
157
+ },
158
+ yAxisMax: {
159
+ // Y轴刻度最大值, 切记如果为0时,则不设置
160
+ type: Number,
161
+ value: 0,
162
+ },
163
+ isSeriesShowSymbol: {
164
+ // 是否显示数据标签 开启后 属性 series.label.show 要同时设置为true
165
+ type: Boolean,
166
+ value: true,
167
+ },
168
+ isUnit: {
169
+ // 显示单位
170
+ type: Boolean,
171
+ value: false,
172
+ },
173
+ unit: {
174
+ // 数字显示的单位 百分比,千分比,千,万,百万,亿,十亿
175
+ type: String,
176
+ value: '%',
177
+ },
178
+ decimalDigits: {
179
+ // 小数位数
180
+ type: Number,
181
+ value: 0,
182
+ },
183
+ suffix: {
184
+ // 后缀
185
+ type: String,
186
+ value: '',
187
+ },
188
+ },
189
+ data: {
190
+ ec: {},
191
+ canvas_id: {
192
+ type: String,
193
+ value: `canvas_line_${Date.now()}_${Math.random() * 100}`,
194
+ },
195
+ },
196
+ lifetimes: {
197
+ attached() {
198
+ // 在组件实例进入页面节点树时执行
199
+ this.initData();
200
+ },
201
+ detached() {
202
+ // 在组件实例被从页面节点树移除时执行
203
+ },
204
+ },
205
+ // 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
206
+ attached() {
207
+ // 在组件实例进入页面节点树时执行
208
+ this.initData();
209
+ },
210
+ detached() {
211
+ // 在组件实例被从页面节点树移除时执行
212
+ },
213
+ observers: {
214
+ // 当参数变化时
215
+ option() {
216
+ this.initData();
217
+ },
218
+ },
219
+ methods: {
220
+ initData() {
221
+ this.setData({
222
+ ec: {
223
+ onInit: this.initChart.bind(this),
224
+ },
225
+ });
226
+ },
227
+ async initChart(canvas, width, height, dpr) {
228
+ const objEchart = echarts.init(canvas, null, {
229
+ width,
230
+ height,
231
+ devicePixelRatio: dpr,
232
+ });
233
+ canvas.setChart(objEchart);
234
+ const objEChartLine = new EchartLine();
235
+ await objEChartLine.setOptions(this.properties);
236
+ const options = await objEChartLine.getOptions();
237
+ // objEchart.clear();
238
+ console.log('设置前参数line', options);
239
+ objEchart.setOption(options);
240
+ return objEchart;
241
+ },
242
+ },
243
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "ec-canvas": "../ec-canvas/ec-canvas"
5
+ }
6
+ }
@@ -0,0 +1,3 @@
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}">
2
+ <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
3
+ </view>
@@ -0,0 +1,9 @@
1
+ /**index.wxss**/
2
+ ec-canvas {
3
+ width: 100%;
4
+ height: 100%;
5
+ }
6
+ .ec_container {
7
+ width: 100%;
8
+ height: 380px;
9
+ }