@10yun/cv-mobile-ui 0.5.63 → 0.5.65
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/other/uCharts-uniapp/index.js +2 -0
- package/other/uCharts-uniapp/package.json +42 -0
- package/other/{qiun-data-charts/js_sdk → uCharts-uniapp}/u-charts/config-echarts.js +421 -421
- package/other/{qiun-data-charts → uCharts-uniapp/u-charts}/license.md +201 -201
- package/other/uCharts-uniapp/u-charts/package.json +19 -0
- package/other/{qiun-data-charts/readme.md → uCharts-uniapp/u-charts/readme-npm.md} +57 -63
- package/other/{qiun-data-charts/js_sdk → uCharts-uniapp}/u-charts/readme.md +4 -4
- package/other/{qiun-data-charts/js_sdk → uCharts-uniapp}/u-charts/u-charts.js +7661 -7661
- package/other/{qiun-data-charts/js_sdk → uCharts-uniapp}/u-charts/u-charts.min.js +1 -1
- package/package.json +1 -1
- package/ui-cv/components/cv-filter-hm/cv-filter-hm.vue +134 -167
- package/uview-plus/components/u-search/u-search.vue +10 -8
- package/other/qiun-data-charts/changelog.md +0 -320
- package/other/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue +0 -1618
- package/other/qiun-data-charts/components/qiun-error/qiun-error.vue +0 -46
- package/other/qiun-data-charts/components/qiun-loading/loading1.vue +0 -162
- package/other/qiun-data-charts/components/qiun-loading/loading2.vue +0 -170
- package/other/qiun-data-charts/components/qiun-loading/loading3.vue +0 -173
- package/other/qiun-data-charts/components/qiun-loading/loading4.vue +0 -222
- package/other/qiun-data-charts/components/qiun-loading/loading5.vue +0 -229
- package/other/qiun-data-charts/components/qiun-loading/qiun-loading.vue +0 -36
- package/other/qiun-data-charts/js_sdk2/app-echarts.min.js +0 -23
- package/other/qiun-data-charts/js_sdk2/h5-echarts.min.js +0 -23
- package/other/qiun-data-charts/package.json +0 -81
- package/other/qiun-data-charts/static/app-plus/echarts.min.js +0 -23
- package/other/qiun-data-charts/static/h5/echarts.min.js +0 -23
- package/other/qiun-data-charts_2.5.0-20230101_example/App.vue +0 -20
- package/other/qiun-data-charts_2.5.0-20230101_example/common/uni-icons.css +0 -542
- package/other/qiun-data-charts_2.5.0-20230101_example/common/uni.css +0 -246
- package/other/qiun-data-charts_2.5.0-20230101_example/components/qiun-title-bar/qiun-title-bar.vue +0 -51
- package/other/qiun-data-charts_2.5.0-20230101_example/components/test-charts/test-charts.vue +0 -48
- package/other/qiun-data-charts_2.5.0-20230101_example/main.js +0 -13
- package/other/qiun-data-charts_2.5.0-20230101_example/manifest.json +0 -75
- package/other/qiun-data-charts_2.5.0-20230101_example/mockdata/demodata.json +0 -448
- package/other/qiun-data-charts_2.5.0-20230101_example/mockdata/mapdata.json +0 -1
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/canvas/canvas.vue +0 -142
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/echarts/echarts.vue +0 -228
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/format-e/format-e.vue +0 -113
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/format-u/format-u.vue +0 -110
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/index/index.vue +0 -58
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/layout/layout.vue +0 -174
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/other/other.vue +0 -233
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/tab/tab.vue +0 -115
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/ucharts/ucharts.vue +0 -339
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/unicloud/unicloud.vue +0 -117
- package/other/qiun-data-charts_2.5.0-20230101_example/pages/updata/updata.vue +0 -212
- package/other/qiun-data-charts_2.5.0-20230101_example/pages.json +0 -79
- package/other/qiun-data-charts_2.5.0-20230101_example/static/logo.png +0 -0
- package/other/qiun-data-charts_2.5.0-20230101_example/uni.scss +0 -76
- package/other/qiun-data-charts_2.5.0-20230101_example/uniCloud-aliyun/database/db_init.json +0 -455
- package/other/qiun-data-charts_2.5.0-20230101_example/uniCloud-aliyun/database/qiun-charts-demo.schema.json +0 -76
- package/other/u-charts/config.js +0 -503
- package/other/u-charts/data.json +0 -1143
- package/other/u-charts/demodata.json +0 -267
- package/other/u-charts/mapdata.json +0 -41
- package/other/u-charts/u-charts.js +0 -5687
- package/other/u-charts/u-charts.min.js +0 -1
- package/other/u-charts/u-charts.vue +0 -466
- /package/other/{qiun-data-charts/js_sdk → uCharts-uniapp}/u-charts/config-ucharts.js +0 -0
|
@@ -1,1618 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* qiun-data-charts 秋云高性能跨全端图表组件
|
|
3
|
-
* Copyright (c) 2021 QIUN® 秋云 https://www.ucharts.cn All rights reserved.
|
|
4
|
-
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
5
|
-
* 复制使用请保留本段注释,感谢支持开源!
|
|
6
|
-
* 为方便更多开发者使用,如有更好的建议请提交码云 Pull Requests !
|
|
7
|
-
*
|
|
8
|
-
* uCharts®官方网站
|
|
9
|
-
* https://www.uCharts.cn
|
|
10
|
-
*
|
|
11
|
-
* 开源地址:
|
|
12
|
-
* https://gitee.com/uCharts/uCharts
|
|
13
|
-
*
|
|
14
|
-
* uni-app插件市场地址:
|
|
15
|
-
* http://ext.dcloud.net.cn/plugin?id=271
|
|
16
|
-
*
|
|
17
|
-
-->
|
|
18
|
-
<template>
|
|
19
|
-
<view class="chartsview" :id="'ChartBoxId'+cid">
|
|
20
|
-
<view v-if="mixinDatacomLoading">
|
|
21
|
-
<!-- 自定义加载状态,请改这里 -->
|
|
22
|
-
<qiun-loading :loadingType="loadingType" />
|
|
23
|
-
</view>
|
|
24
|
-
<view v-if="mixinDatacomErrorMessage && errorShow" @tap="reloading">
|
|
25
|
-
<!-- 自定义错误提示,请改这里 -->
|
|
26
|
-
<qiun-error :errorMessage="errorMessage" />
|
|
27
|
-
</view>
|
|
28
|
-
<!-- APP和H5采用renderjs渲染图表 -->
|
|
29
|
-
<!-- #ifdef APP-VUE || H5 -->
|
|
30
|
-
<block v-if="echarts">
|
|
31
|
-
<view
|
|
32
|
-
:style="{ background: background }"
|
|
33
|
-
style="width: 100%;height: 100%;"
|
|
34
|
-
:data-directory="directory"
|
|
35
|
-
:id="'EC'+cid"
|
|
36
|
-
:prop="echartsOpts"
|
|
37
|
-
:change:prop="rdcharts.ecinit"
|
|
38
|
-
:resize="echartsResize"
|
|
39
|
-
:change:resize="rdcharts.ecresize"
|
|
40
|
-
v-show="showchart"
|
|
41
|
-
/>
|
|
42
|
-
</block>
|
|
43
|
-
<block v-else>
|
|
44
|
-
<view
|
|
45
|
-
v-on:tap="rdcharts.tap"
|
|
46
|
-
v-on:mousemove="rdcharts.mouseMove"
|
|
47
|
-
v-on:mousedown="rdcharts.mouseDown"
|
|
48
|
-
v-on:mouseup="rdcharts.mouseUp"
|
|
49
|
-
v-on:touchstart="rdcharts.touchStart"
|
|
50
|
-
v-on:touchmove="rdcharts.touchMove"
|
|
51
|
-
v-on:touchend="rdcharts.touchEnd"
|
|
52
|
-
:id="'UC'+cid"
|
|
53
|
-
:prop="uchartsOpts"
|
|
54
|
-
:change:prop="rdcharts.ucinit"
|
|
55
|
-
>
|
|
56
|
-
<canvas
|
|
57
|
-
:id="cid"
|
|
58
|
-
:canvasId="cid"
|
|
59
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
60
|
-
:disable-scroll="disableScroll"
|
|
61
|
-
@error="_error"
|
|
62
|
-
v-show="showchart"
|
|
63
|
-
/>
|
|
64
|
-
</view>
|
|
65
|
-
</block>
|
|
66
|
-
<!-- #endif -->
|
|
67
|
-
<!-- 支付宝小程序 -->
|
|
68
|
-
<!-- #ifdef MP-ALIPAY -->
|
|
69
|
-
<block v-if="ontouch">
|
|
70
|
-
<canvas
|
|
71
|
-
:id="cid"
|
|
72
|
-
:canvasId="cid"
|
|
73
|
-
:width="cWidth * pixel"
|
|
74
|
-
:height="cHeight * pixel"
|
|
75
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
76
|
-
:disable-scroll="disScroll"
|
|
77
|
-
@tap="_tap"
|
|
78
|
-
@touchstart="_touchStart"
|
|
79
|
-
@touchmove="_touchMove"
|
|
80
|
-
@touchend="_touchEnd"
|
|
81
|
-
@error="_error"
|
|
82
|
-
v-show="showchart"
|
|
83
|
-
/>
|
|
84
|
-
</block>
|
|
85
|
-
<block v-if="!ontouch">
|
|
86
|
-
<canvas
|
|
87
|
-
:id="cid"
|
|
88
|
-
:canvasId="cid"
|
|
89
|
-
:width="cWidth * pixel"
|
|
90
|
-
:height="cHeight * pixel"
|
|
91
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
92
|
-
:disable-scroll="disScroll"
|
|
93
|
-
@tap="_tap"
|
|
94
|
-
@error="_error"
|
|
95
|
-
v-show="showchart"
|
|
96
|
-
/>
|
|
97
|
-
</block>
|
|
98
|
-
<!-- #endif -->
|
|
99
|
-
<!-- 其他小程序通过vue渲染图表 -->
|
|
100
|
-
<!-- #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-TOUTIAO || MP-KUAISHOU || MP-LARK || MP-JD || MP-360 -->
|
|
101
|
-
<block v-if="type2d">
|
|
102
|
-
<view v-if="ontouch" @tap="_tap">
|
|
103
|
-
<canvas
|
|
104
|
-
:id="cid"
|
|
105
|
-
:canvasId="cid"
|
|
106
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
107
|
-
type="2d"
|
|
108
|
-
:disable-scroll="disScroll"
|
|
109
|
-
@touchstart="_touchStart"
|
|
110
|
-
@touchmove="_touchMove"
|
|
111
|
-
@touchend="_touchEnd"
|
|
112
|
-
@error="_error"
|
|
113
|
-
v-show="showchart"
|
|
114
|
-
/>
|
|
115
|
-
</view>
|
|
116
|
-
<view v-if="!ontouch" @tap="_tap">
|
|
117
|
-
<canvas
|
|
118
|
-
:id="cid"
|
|
119
|
-
:canvasId="cid"
|
|
120
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
121
|
-
type="2d"
|
|
122
|
-
:disable-scroll="disScroll"
|
|
123
|
-
@error="_error"
|
|
124
|
-
v-show="showchart"
|
|
125
|
-
/>
|
|
126
|
-
</view>
|
|
127
|
-
</block>
|
|
128
|
-
<block v-if="!type2d">
|
|
129
|
-
<view v-if="ontouch" @tap="_tap">
|
|
130
|
-
<canvas
|
|
131
|
-
:id="cid"
|
|
132
|
-
:canvasId="cid"
|
|
133
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
134
|
-
@touchstart="_touchStart"
|
|
135
|
-
@touchmove="_touchMove"
|
|
136
|
-
@touchend="_touchEnd"
|
|
137
|
-
:disable-scroll="disScroll"
|
|
138
|
-
@error="_error"
|
|
139
|
-
v-if="showchart"
|
|
140
|
-
/>
|
|
141
|
-
</view>
|
|
142
|
-
<view v-if="!ontouch" >
|
|
143
|
-
<canvas
|
|
144
|
-
:id="cid"
|
|
145
|
-
:canvasId="cid"
|
|
146
|
-
:style="{ width: cWidth + 'px', height: cHeight + 'px', background: background }"
|
|
147
|
-
:disable-scroll="disScroll"
|
|
148
|
-
@tap="_tap"
|
|
149
|
-
@error="_error"
|
|
150
|
-
v-if="showchart"
|
|
151
|
-
/>
|
|
152
|
-
</view>
|
|
153
|
-
</block>
|
|
154
|
-
<!-- #endif -->
|
|
155
|
-
</view>
|
|
156
|
-
</template>
|
|
157
|
-
|
|
158
|
-
<script>
|
|
159
|
-
import uCharts from '../../js_sdk/u-charts/u-charts.js';
|
|
160
|
-
import cfu from '../../js_sdk/u-charts/config-ucharts.js';
|
|
161
|
-
// #ifdef APP-VUE || H5
|
|
162
|
-
import cfe from '../../js_sdk/u-charts/config-echarts.js';
|
|
163
|
-
// #endif
|
|
164
|
-
|
|
165
|
-
function deepCloneAssign(origin = {}, ...args) {
|
|
166
|
-
for (let i in args) {
|
|
167
|
-
for (let key in args[i]) {
|
|
168
|
-
if (args[i].hasOwnProperty(key)) {
|
|
169
|
-
origin[key] = args[i][key] && typeof args[i][key] === 'object' ? deepCloneAssign(Array.isArray(args[i][key]) ? [] : {}, origin[key], args[i][key]) : args[i][key];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return origin;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function formatterAssign(args,formatter) {
|
|
177
|
-
for (let key in args) {
|
|
178
|
-
if(args.hasOwnProperty(key) && args[key] !== null && typeof args[key] === 'object'){
|
|
179
|
-
formatterAssign(args[key],formatter)
|
|
180
|
-
}else if(key === 'format' && typeof args[key] === 'string'){
|
|
181
|
-
args['formatter'] = formatter[args[key]] ? formatter[args[key]] : undefined;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return args;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// 时间转换函数,为了匹配uniClinetDB读取出的时间与categories不同
|
|
188
|
-
function getFormatDate(date) {
|
|
189
|
-
var seperator = "-";
|
|
190
|
-
var year = date.getFullYear();
|
|
191
|
-
var month = date.getMonth() + 1;
|
|
192
|
-
var strDate = date.getDate();
|
|
193
|
-
if (month >= 1 && month <= 9) {
|
|
194
|
-
month = "0" + month;
|
|
195
|
-
}
|
|
196
|
-
if (strDate >= 0 && strDate <= 9) {
|
|
197
|
-
strDate = "0" + strDate;
|
|
198
|
-
}
|
|
199
|
-
var currentdate = year + seperator + month + seperator + strDate;
|
|
200
|
-
return currentdate;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var lastMoveTime = null;
|
|
204
|
-
/**
|
|
205
|
-
* 防抖
|
|
206
|
-
*
|
|
207
|
-
* @param { Function } fn 要执行的方法
|
|
208
|
-
* @param { Number } wait 防抖多少毫秒
|
|
209
|
-
*
|
|
210
|
-
* 在 vue 中使用(注意:不能使用箭头函数,否则this指向不对,并且不能再次封装如:
|
|
211
|
-
* move(){ // 错误调用方式
|
|
212
|
-
* debounce(function () {
|
|
213
|
-
* console.log(this.title);
|
|
214
|
-
* }, 1000)});
|
|
215
|
-
* 应该直接使用:// 正确调用方式
|
|
216
|
-
* move: debounce(function () {
|
|
217
|
-
* console.log(this.title);
|
|
218
|
-
* }, 1000)
|
|
219
|
-
*/
|
|
220
|
-
function debounce(fn, wait) {
|
|
221
|
-
let timer = false;
|
|
222
|
-
return function() {
|
|
223
|
-
clearTimeout(timer);
|
|
224
|
-
timer && clearTimeout(timer);
|
|
225
|
-
timer = setTimeout(() => {
|
|
226
|
-
timer = false;
|
|
227
|
-
fn.apply(this, arguments); // 把参数传进去
|
|
228
|
-
}, wait);
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export default {
|
|
233
|
-
name: 'qiun-data-charts',
|
|
234
|
-
mixins: [uniCloud.mixinDatacom],
|
|
235
|
-
props: {
|
|
236
|
-
type: {
|
|
237
|
-
type: String,
|
|
238
|
-
default: null
|
|
239
|
-
},
|
|
240
|
-
canvasId: {
|
|
241
|
-
type: String,
|
|
242
|
-
default: 'uchartsid'
|
|
243
|
-
},
|
|
244
|
-
canvas2d: {
|
|
245
|
-
type: Boolean,
|
|
246
|
-
default: false
|
|
247
|
-
},
|
|
248
|
-
background: {
|
|
249
|
-
type: String,
|
|
250
|
-
default: 'rgba(0,0,0,0)'
|
|
251
|
-
},
|
|
252
|
-
animation: {
|
|
253
|
-
type: Boolean,
|
|
254
|
-
default: true
|
|
255
|
-
},
|
|
256
|
-
chartData: {
|
|
257
|
-
type: Object,
|
|
258
|
-
default() {
|
|
259
|
-
return {
|
|
260
|
-
categories: [],
|
|
261
|
-
series: []
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
opts: {
|
|
266
|
-
type: Object,
|
|
267
|
-
default() {
|
|
268
|
-
return {};
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
eopts: {
|
|
272
|
-
type: Object,
|
|
273
|
-
default() {
|
|
274
|
-
return {};
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
loadingType: {
|
|
278
|
-
type: Number,
|
|
279
|
-
default: 2
|
|
280
|
-
},
|
|
281
|
-
errorShow: {
|
|
282
|
-
type: Boolean,
|
|
283
|
-
default: true
|
|
284
|
-
},
|
|
285
|
-
errorReload: {
|
|
286
|
-
type: Boolean,
|
|
287
|
-
default: true
|
|
288
|
-
},
|
|
289
|
-
errorMessage: {
|
|
290
|
-
type: String,
|
|
291
|
-
default: null
|
|
292
|
-
},
|
|
293
|
-
inScrollView: {
|
|
294
|
-
type: Boolean,
|
|
295
|
-
default: false
|
|
296
|
-
},
|
|
297
|
-
reshow: {
|
|
298
|
-
type: Boolean,
|
|
299
|
-
default: false
|
|
300
|
-
},
|
|
301
|
-
reload: {
|
|
302
|
-
type: Boolean,
|
|
303
|
-
default: false
|
|
304
|
-
},
|
|
305
|
-
disableScroll: {
|
|
306
|
-
type: Boolean,
|
|
307
|
-
default: false
|
|
308
|
-
},
|
|
309
|
-
optsWatch: {
|
|
310
|
-
type: Boolean,
|
|
311
|
-
default: true
|
|
312
|
-
},
|
|
313
|
-
onzoom: {
|
|
314
|
-
type: Boolean,
|
|
315
|
-
default: false
|
|
316
|
-
},
|
|
317
|
-
ontap: {
|
|
318
|
-
type: Boolean,
|
|
319
|
-
default: true
|
|
320
|
-
},
|
|
321
|
-
ontouch: {
|
|
322
|
-
type: Boolean,
|
|
323
|
-
default: false
|
|
324
|
-
},
|
|
325
|
-
onmouse: {
|
|
326
|
-
type: Boolean,
|
|
327
|
-
default: true
|
|
328
|
-
},
|
|
329
|
-
onmovetip: {
|
|
330
|
-
type: Boolean,
|
|
331
|
-
default: false
|
|
332
|
-
},
|
|
333
|
-
echartsH5: {
|
|
334
|
-
type: Boolean,
|
|
335
|
-
default: false
|
|
336
|
-
},
|
|
337
|
-
echartsApp: {
|
|
338
|
-
type: Boolean,
|
|
339
|
-
default: false
|
|
340
|
-
},
|
|
341
|
-
tooltipShow: {
|
|
342
|
-
type: Boolean,
|
|
343
|
-
default: true
|
|
344
|
-
},
|
|
345
|
-
tooltipFormat: {
|
|
346
|
-
type: String,
|
|
347
|
-
default: undefined
|
|
348
|
-
},
|
|
349
|
-
tooltipCustom: {
|
|
350
|
-
type: Object,
|
|
351
|
-
default: undefined
|
|
352
|
-
},
|
|
353
|
-
startDate: {
|
|
354
|
-
type: String,
|
|
355
|
-
default: undefined
|
|
356
|
-
},
|
|
357
|
-
endDate: {
|
|
358
|
-
type: String,
|
|
359
|
-
default: undefined
|
|
360
|
-
},
|
|
361
|
-
textEnum: {
|
|
362
|
-
type: Array,
|
|
363
|
-
default () {
|
|
364
|
-
return []
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
groupEnum: {
|
|
368
|
-
type: Array,
|
|
369
|
-
default () {
|
|
370
|
-
return []
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
pageScrollTop: {
|
|
374
|
-
type: Number,
|
|
375
|
-
default: 0
|
|
376
|
-
},
|
|
377
|
-
directory: {
|
|
378
|
-
type: String,
|
|
379
|
-
default: '/'
|
|
380
|
-
},
|
|
381
|
-
tapLegend: {
|
|
382
|
-
type: Boolean,
|
|
383
|
-
default: true
|
|
384
|
-
},
|
|
385
|
-
menus: {
|
|
386
|
-
type: Array,
|
|
387
|
-
default () {
|
|
388
|
-
return []
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
data() {
|
|
393
|
-
return {
|
|
394
|
-
cid: 'uchartsid',
|
|
395
|
-
inWx: false,
|
|
396
|
-
inAli: false,
|
|
397
|
-
inTt: false,
|
|
398
|
-
inBd: false,
|
|
399
|
-
inH5: false,
|
|
400
|
-
inApp: false,
|
|
401
|
-
inWin: false,
|
|
402
|
-
type2d: true,
|
|
403
|
-
disScroll: false,
|
|
404
|
-
openmouse: false,
|
|
405
|
-
pixel: 1,
|
|
406
|
-
cWidth: 375,
|
|
407
|
-
cHeight: 250,
|
|
408
|
-
showchart: false,
|
|
409
|
-
echarts: false,
|
|
410
|
-
echartsResize:{
|
|
411
|
-
state:false
|
|
412
|
-
},
|
|
413
|
-
uchartsOpts: {},
|
|
414
|
-
echartsOpts: {},
|
|
415
|
-
drawData:{},
|
|
416
|
-
lastDrawTime:null,
|
|
417
|
-
};
|
|
418
|
-
},
|
|
419
|
-
created(){
|
|
420
|
-
this.cid = this.canvasId
|
|
421
|
-
if (this.canvasId == 'uchartsid' || this.canvasId == '') {
|
|
422
|
-
let t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
|
423
|
-
let len = t.length
|
|
424
|
-
let id = ''
|
|
425
|
-
for (let i = 0; i < 32; i++) {
|
|
426
|
-
id += t.charAt(Math.floor(Math.random() * len))
|
|
427
|
-
}
|
|
428
|
-
this.cid = id
|
|
429
|
-
}
|
|
430
|
-
const systemInfo = uni.getSystemInfoSync()
|
|
431
|
-
if(systemInfo.platform === 'windows' || systemInfo.platform === 'mac'){
|
|
432
|
-
this.inWin = true;
|
|
433
|
-
}
|
|
434
|
-
// #ifdef MP-WEIXIN
|
|
435
|
-
this.inWx = true;
|
|
436
|
-
if (this.canvas2d === false || systemInfo.platform === 'windows' || systemInfo.platform === 'mac') {
|
|
437
|
-
this.type2d = false;
|
|
438
|
-
}else{
|
|
439
|
-
this.type2d = true;
|
|
440
|
-
this.pixel = systemInfo.pixelRatio;
|
|
441
|
-
}
|
|
442
|
-
// #endif
|
|
443
|
-
//非微信小程序端强制关闭canvas2d模式
|
|
444
|
-
// #ifndef MP-WEIXIN
|
|
445
|
-
this.type2d = false;
|
|
446
|
-
// #endif
|
|
447
|
-
// #ifdef MP-TOUTIAO || MP-LARK || MP-ALIPAY
|
|
448
|
-
this.type2d = this.canvas2d;
|
|
449
|
-
// #endif
|
|
450
|
-
// #ifdef MP-ALIPAY
|
|
451
|
-
this.inAli = true;
|
|
452
|
-
this.pixel = systemInfo.pixelRatio;
|
|
453
|
-
// #endif
|
|
454
|
-
// #ifdef MP-BAIDU
|
|
455
|
-
this.inBd = true;
|
|
456
|
-
// #endif
|
|
457
|
-
// #ifdef MP-TOUTIAO
|
|
458
|
-
this.inTt = true;
|
|
459
|
-
// #endif
|
|
460
|
-
this.disScroll = this.disableScroll;
|
|
461
|
-
},
|
|
462
|
-
mounted() {
|
|
463
|
-
// #ifdef APP-VUE
|
|
464
|
-
this.inApp = true;
|
|
465
|
-
if (this.echartsApp === true) {
|
|
466
|
-
this.echarts = true;
|
|
467
|
-
this.openmouse = false;
|
|
468
|
-
}
|
|
469
|
-
// #endif
|
|
470
|
-
// #ifdef APP-NVUE
|
|
471
|
-
this.inApp = true;
|
|
472
|
-
this.mixinDatacomLoading = false
|
|
473
|
-
this.mixinDatacomErrorMessage = "暂不支持NVUE"
|
|
474
|
-
// #endif
|
|
475
|
-
// #ifdef H5
|
|
476
|
-
this.inH5 = true;
|
|
477
|
-
if(this.inWin === true){
|
|
478
|
-
this.openmouse = this.onmouse;
|
|
479
|
-
}
|
|
480
|
-
if (this.echartsH5 === true) {
|
|
481
|
-
this.echarts = true;
|
|
482
|
-
}
|
|
483
|
-
// #endif
|
|
484
|
-
this.$nextTick(()=>{
|
|
485
|
-
this.beforeInit();
|
|
486
|
-
})
|
|
487
|
-
// #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || APP-VUE
|
|
488
|
-
const time = this.inH5 ? 500 : 200;
|
|
489
|
-
const _this = this;
|
|
490
|
-
uni.onWindowResize(
|
|
491
|
-
debounce(function(res) {
|
|
492
|
-
if (_this.mixinDatacomLoading == true) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
let errmsg = _this.mixinDatacomErrorMessage;
|
|
496
|
-
if (errmsg !== null && errmsg !== 'null' && errmsg !== '') {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
if (_this.echarts) {
|
|
500
|
-
_this.echartsResize.state = !_this.echartsResize.state;
|
|
501
|
-
} else {
|
|
502
|
-
_this.resizeHandler();
|
|
503
|
-
}
|
|
504
|
-
}, time)
|
|
505
|
-
);
|
|
506
|
-
// #endif
|
|
507
|
-
},
|
|
508
|
-
destroyed(){
|
|
509
|
-
if(this.echarts === true){
|
|
510
|
-
delete cfe.option[this.cid]
|
|
511
|
-
delete cfe.instance[this.cid]
|
|
512
|
-
}else{
|
|
513
|
-
delete cfu.option[this.cid]
|
|
514
|
-
delete cfu.instance[this.cid]
|
|
515
|
-
}
|
|
516
|
-
// #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
|
|
517
|
-
uni.offWindowResize(()=>{})
|
|
518
|
-
// #endif
|
|
519
|
-
},
|
|
520
|
-
watch: {
|
|
521
|
-
chartDataProps: {
|
|
522
|
-
handler(val, oldval) {
|
|
523
|
-
if (typeof val === 'object') {
|
|
524
|
-
if (JSON.stringify(val) !== JSON.stringify(oldval)) {
|
|
525
|
-
this._clearChart();
|
|
526
|
-
if (val.series && val.series.length > 0) {
|
|
527
|
-
this.beforeInit();
|
|
528
|
-
}else{
|
|
529
|
-
this.mixinDatacomLoading = true;
|
|
530
|
-
this.showchart = false;
|
|
531
|
-
this.mixinDatacomErrorMessage = null;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
} else {
|
|
535
|
-
this.mixinDatacomLoading = false;
|
|
536
|
-
this._clearChart();
|
|
537
|
-
this.showchart = false;
|
|
538
|
-
this.mixinDatacomErrorMessage = '参数错误:chartData数据类型错误';
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
immediate: false,
|
|
542
|
-
deep: true
|
|
543
|
-
},
|
|
544
|
-
localdata:{
|
|
545
|
-
handler(val, oldval) {
|
|
546
|
-
if (JSON.stringify(val) !== JSON.stringify(oldval)) {
|
|
547
|
-
if (val.length > 0) {
|
|
548
|
-
this.beforeInit();
|
|
549
|
-
}else{
|
|
550
|
-
this.mixinDatacomLoading = true;
|
|
551
|
-
this._clearChart();
|
|
552
|
-
this.showchart = false;
|
|
553
|
-
this.mixinDatacomErrorMessage = null;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
immediate: false,
|
|
558
|
-
deep: true
|
|
559
|
-
},
|
|
560
|
-
optsProps: {
|
|
561
|
-
handler(val, oldval) {
|
|
562
|
-
if (typeof val === 'object') {
|
|
563
|
-
if (JSON.stringify(val) !== JSON.stringify(oldval) && this.echarts === false && this.optsWatch == true) {
|
|
564
|
-
this.checkData(this.drawData);
|
|
565
|
-
}
|
|
566
|
-
} else {
|
|
567
|
-
this.mixinDatacomLoading = false;
|
|
568
|
-
this._clearChart();
|
|
569
|
-
this.showchart = false;
|
|
570
|
-
this.mixinDatacomErrorMessage = '参数错误:opts数据类型错误';
|
|
571
|
-
}
|
|
572
|
-
},
|
|
573
|
-
immediate: false,
|
|
574
|
-
deep: true
|
|
575
|
-
},
|
|
576
|
-
eoptsProps: {
|
|
577
|
-
handler(val, oldval) {
|
|
578
|
-
if (typeof val === 'object') {
|
|
579
|
-
if (JSON.stringify(val) !== JSON.stringify(oldval) && this.echarts === true) {
|
|
580
|
-
this.checkData(this.drawData);
|
|
581
|
-
}
|
|
582
|
-
} else {
|
|
583
|
-
this.mixinDatacomLoading = false;
|
|
584
|
-
this.showchart = false;
|
|
585
|
-
this.mixinDatacomErrorMessage = '参数错误:eopts数据类型错误';
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
immediate: false,
|
|
589
|
-
deep: true
|
|
590
|
-
},
|
|
591
|
-
reshow(val, oldval) {
|
|
592
|
-
if (val === true && this.mixinDatacomLoading === false) {
|
|
593
|
-
setTimeout(() => {
|
|
594
|
-
this.mixinDatacomErrorMessage = null;
|
|
595
|
-
this.echartsResize.state = !this.echartsResize.state;
|
|
596
|
-
this.checkData(this.drawData);
|
|
597
|
-
}, 200);
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
reload(val, oldval) {
|
|
601
|
-
if (val === true) {
|
|
602
|
-
this.showchart = false;
|
|
603
|
-
this.mixinDatacomErrorMessage = null;
|
|
604
|
-
this.reloading();
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
|
-
mixinDatacomErrorMessage(val, oldval) {
|
|
608
|
-
if (val) {
|
|
609
|
-
this.emitMsg({name: 'error', params: {type:"error", errorShow: this.errorShow, msg: val, id: this.cid}});
|
|
610
|
-
if(this.errorShow){
|
|
611
|
-
console.log('[秋云图表组件]' + val);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
errorMessage(val, oldval) {
|
|
616
|
-
if (val && this.errorShow && val !== null && val !== 'null' && val !== '') {
|
|
617
|
-
this.showchart = false;
|
|
618
|
-
this.mixinDatacomLoading = false;
|
|
619
|
-
this.mixinDatacomErrorMessage = val;
|
|
620
|
-
} else {
|
|
621
|
-
this.showchart = false;
|
|
622
|
-
this.mixinDatacomErrorMessage = null;
|
|
623
|
-
this.reloading();
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
},
|
|
627
|
-
computed: {
|
|
628
|
-
optsProps() {
|
|
629
|
-
return JSON.parse(JSON.stringify(this.opts));
|
|
630
|
-
},
|
|
631
|
-
eoptsProps() {
|
|
632
|
-
return JSON.parse(JSON.stringify(this.eopts));
|
|
633
|
-
},
|
|
634
|
-
chartDataProps() {
|
|
635
|
-
return JSON.parse(JSON.stringify(this.chartData));
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
methods: {
|
|
639
|
-
beforeInit(){
|
|
640
|
-
this.mixinDatacomErrorMessage = null;
|
|
641
|
-
if (typeof this.chartData === 'object' && this.chartData != null && this.chartData.series !== undefined && this.chartData.series.length > 0) {
|
|
642
|
-
//拷贝一下chartData,为了opts变更后统一数据来源
|
|
643
|
-
this.drawData = deepCloneAssign({}, this.chartData);
|
|
644
|
-
this.mixinDatacomLoading = false;
|
|
645
|
-
this.showchart = true;
|
|
646
|
-
this.checkData(this.chartData);
|
|
647
|
-
}else if(this.localdata.length>0){
|
|
648
|
-
this.mixinDatacomLoading = false;
|
|
649
|
-
this.showchart = true;
|
|
650
|
-
this.localdataInit(this.localdata);
|
|
651
|
-
}else if(this.collection !== ''){
|
|
652
|
-
this.mixinDatacomLoading = false;
|
|
653
|
-
this.getCloudData();
|
|
654
|
-
}else{
|
|
655
|
-
this.mixinDatacomLoading = true;
|
|
656
|
-
}
|
|
657
|
-
},
|
|
658
|
-
localdataInit(resdata){
|
|
659
|
-
//替换enum类型为正确的描述
|
|
660
|
-
if(this.groupEnum.length>0){
|
|
661
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
662
|
-
for (let j = 0; j < this.groupEnum.length; j++) {
|
|
663
|
-
if(resdata[i].group === this.groupEnum[j].value){
|
|
664
|
-
resdata[i].group = this.groupEnum[j].text
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
if(this.textEnum.length>0){
|
|
670
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
671
|
-
for (let j = 0; j < this.textEnum.length; j++) {
|
|
672
|
-
if(resdata[i].text === this.textEnum[j].value){
|
|
673
|
-
resdata[i].text = this.textEnum[j].text
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
let needCategories = false;
|
|
679
|
-
let tmpData = {categories:[], series:[]}
|
|
680
|
-
let tmpcategories = []
|
|
681
|
-
let tmpseries = [];
|
|
682
|
-
//拼接categories
|
|
683
|
-
if(this.echarts === true){
|
|
684
|
-
needCategories = cfe.categories.includes(this.type)
|
|
685
|
-
}else{
|
|
686
|
-
needCategories = cfu.categories.includes(this.type)
|
|
687
|
-
}
|
|
688
|
-
if(needCategories === true){
|
|
689
|
-
//如果props中的chartData带有categories,则优先使用chartData的categories
|
|
690
|
-
if(this.chartData && this.chartData.categories && this.chartData.categories.length>0){
|
|
691
|
-
tmpcategories = this.chartData.categories
|
|
692
|
-
}else{
|
|
693
|
-
//如果是日期类型的数据,不管是本地数据还是云数据,都按起止日期自动拼接categories
|
|
694
|
-
if(this.startDate && this.endDate){
|
|
695
|
-
let idate = new Date(this.startDate)
|
|
696
|
-
let edate = new Date(this.endDate)
|
|
697
|
-
while (idate <= edate) {
|
|
698
|
-
tmpcategories.push(getFormatDate(idate))
|
|
699
|
-
idate = idate.setDate(idate.getDate() + 1)
|
|
700
|
-
idate = new Date(idate)
|
|
701
|
-
}
|
|
702
|
-
//否则从结果中去重并拼接categories
|
|
703
|
-
}else{
|
|
704
|
-
let tempckey = {};
|
|
705
|
-
resdata.map(function(item, index) {
|
|
706
|
-
if (item.text != undefined && !tempckey[item.text]) {
|
|
707
|
-
tmpcategories.push(item.text)
|
|
708
|
-
tempckey[item.text] = true
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
tmpData.categories = tmpcategories
|
|
714
|
-
}
|
|
715
|
-
//拼接series
|
|
716
|
-
let tempskey = {};
|
|
717
|
-
resdata.map(function(item, index) {
|
|
718
|
-
if (item.group != undefined && !tempskey[item.group]) {
|
|
719
|
-
tmpseries.push({ name: item.group, data: [] });
|
|
720
|
-
tempskey[item.group] = true;
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
//如果没有获取到分组名称(可能是带categories的数据,也可能是不带的饼图类)
|
|
724
|
-
if (tmpseries.length == 0) {
|
|
725
|
-
tmpseries = [{ name: '默认分组', data: [] }];
|
|
726
|
-
//如果是需要categories的图表类型
|
|
727
|
-
if(needCategories === true){
|
|
728
|
-
for (let j = 0; j < tmpcategories.length; j++) {
|
|
729
|
-
let seriesdata = 0;
|
|
730
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
731
|
-
if (resdata[i].text == tmpcategories[j]) {
|
|
732
|
-
seriesdata = resdata[i].value;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
tmpseries[0].data.push(seriesdata);
|
|
736
|
-
}
|
|
737
|
-
//如果是饼图类的图表类型
|
|
738
|
-
}else{
|
|
739
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
740
|
-
tmpseries[0].data.push({"name": resdata[i].text,"value": resdata[i].value});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
//如果有分组名
|
|
744
|
-
} else {
|
|
745
|
-
for (let k = 0; k < tmpseries.length; k++) {
|
|
746
|
-
//如果有categories
|
|
747
|
-
if (tmpcategories.length > 0) {
|
|
748
|
-
for (let j = 0; j < tmpcategories.length; j++) {
|
|
749
|
-
let seriesdata = 0;
|
|
750
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
751
|
-
if (tmpseries[k].name == resdata[i].group && resdata[i].text == tmpcategories[j]) {
|
|
752
|
-
seriesdata = resdata[i].value;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
tmpseries[k].data.push(seriesdata);
|
|
756
|
-
}
|
|
757
|
-
//如果传了group而没有传text,即没有categories(正常情况下这种数据是不符合数据要求规范的)
|
|
758
|
-
} else {
|
|
759
|
-
for (let i = 0; i < resdata.length; i++) {
|
|
760
|
-
if (tmpseries[k].name == resdata[i].group) {
|
|
761
|
-
tmpseries[k].data.push(resdata[i].value);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
tmpData.series = tmpseries
|
|
768
|
-
//拷贝一下chartData,为了opts变更后统一数据来源
|
|
769
|
-
this.drawData = deepCloneAssign({}, tmpData);
|
|
770
|
-
this.checkData(tmpData)
|
|
771
|
-
},
|
|
772
|
-
reloading() {
|
|
773
|
-
if(this.errorReload === false){
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
this.showchart = false;
|
|
777
|
-
this.mixinDatacomErrorMessage = null;
|
|
778
|
-
if (this.collection !== '') {
|
|
779
|
-
this.mixinDatacomLoading = false;
|
|
780
|
-
this.onMixinDatacomPropsChange(true);
|
|
781
|
-
} else {
|
|
782
|
-
this.beforeInit();
|
|
783
|
-
}
|
|
784
|
-
},
|
|
785
|
-
checkData(anyData) {
|
|
786
|
-
let cid = this.cid
|
|
787
|
-
//复位opts或eopts
|
|
788
|
-
if(this.echarts === true){
|
|
789
|
-
cfe.option[cid] = deepCloneAssign({}, this.eopts);
|
|
790
|
-
cfe.option[cid].id = cid;
|
|
791
|
-
cfe.option[cid].type = this.type;
|
|
792
|
-
}else{
|
|
793
|
-
if (this.type && cfu.type.includes(this.type)) {
|
|
794
|
-
cfu.option[cid] = deepCloneAssign({}, cfu[this.type], this.opts);
|
|
795
|
-
cfu.option[cid].canvasId = cid;
|
|
796
|
-
} else {
|
|
797
|
-
this.mixinDatacomLoading = false;
|
|
798
|
-
this.showchart = false;
|
|
799
|
-
this.mixinDatacomErrorMessage = '参数错误:props参数中type类型不正确';
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
//挂载categories和series
|
|
803
|
-
let newData = deepCloneAssign({}, anyData);
|
|
804
|
-
if (newData.series !== undefined && newData.series.length > 0) {
|
|
805
|
-
this.mixinDatacomErrorMessage = null;
|
|
806
|
-
if (this.echarts === true) {
|
|
807
|
-
cfe.option[cid].chartData = newData;
|
|
808
|
-
this.$nextTick(()=>{
|
|
809
|
-
this.init()
|
|
810
|
-
})
|
|
811
|
-
}else{
|
|
812
|
-
cfu.option[cid].categories = newData.categories;
|
|
813
|
-
cfu.option[cid].series = newData.series;
|
|
814
|
-
this.$nextTick(()=>{
|
|
815
|
-
this.init()
|
|
816
|
-
})
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
resizeHandler() {
|
|
821
|
-
//渲染防抖
|
|
822
|
-
let currTime = Date.now();
|
|
823
|
-
let lastDrawTime = this.lastDrawTime?this.lastDrawTime:currTime-3000;
|
|
824
|
-
let duration = currTime - lastDrawTime;
|
|
825
|
-
if (duration < 1000) return;
|
|
826
|
-
let chartdom = uni
|
|
827
|
-
.createSelectorQuery()
|
|
828
|
-
// #ifndef MP-ALIPAY
|
|
829
|
-
.in(this)
|
|
830
|
-
// #endif
|
|
831
|
-
.select('#ChartBoxId'+this.cid)
|
|
832
|
-
.boundingClientRect(data => {
|
|
833
|
-
this.showchart = true;
|
|
834
|
-
if (data.width > 0 && data.height > 0) {
|
|
835
|
-
if (data.width !== this.cWidth || data.height !== this.cHeight) {
|
|
836
|
-
this.checkData(this.drawData)
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
})
|
|
840
|
-
.exec();
|
|
841
|
-
},
|
|
842
|
-
getCloudData() {
|
|
843
|
-
if (this.mixinDatacomLoading == true) {
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
this.mixinDatacomLoading = true;
|
|
847
|
-
this.mixinDatacomGet()
|
|
848
|
-
.then(res => {
|
|
849
|
-
this.mixinDatacomResData = res.result.data;
|
|
850
|
-
this.localdataInit(this.mixinDatacomResData);
|
|
851
|
-
})
|
|
852
|
-
.catch(err => {
|
|
853
|
-
this.mixinDatacomLoading = false;
|
|
854
|
-
this.showchart = false;
|
|
855
|
-
this.mixinDatacomErrorMessage = '请求错误:' + err;
|
|
856
|
-
});
|
|
857
|
-
},
|
|
858
|
-
onMixinDatacomPropsChange(needReset, changed) {
|
|
859
|
-
if (needReset == true && this.collection !== '') {
|
|
860
|
-
this.showchart = false;
|
|
861
|
-
this.mixinDatacomErrorMessage = null;
|
|
862
|
-
this._clearChart();
|
|
863
|
-
this.getCloudData();
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
_clearChart() {
|
|
867
|
-
let cid = this.cid
|
|
868
|
-
if (this.echarts !== true && cfu.option[cid] && cfu.option[cid].context) {
|
|
869
|
-
const ctx = cfu.option[cid].context;
|
|
870
|
-
if(typeof ctx === "object" && !!!cfu.option[cid].update){
|
|
871
|
-
ctx.clearRect(0, 0, this.cWidth*this.pixel, this.cHeight*this.pixel);
|
|
872
|
-
ctx.draw();
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
},
|
|
876
|
-
init() {
|
|
877
|
-
let cid = this.cid
|
|
878
|
-
let chartdom = uni
|
|
879
|
-
.createSelectorQuery()
|
|
880
|
-
// #ifndef MP-ALIPAY
|
|
881
|
-
.in(this)
|
|
882
|
-
// #endif
|
|
883
|
-
.select('#ChartBoxId'+cid)
|
|
884
|
-
.boundingClientRect(data => {
|
|
885
|
-
if (data.width > 0 && data.height > 0) {
|
|
886
|
-
this.mixinDatacomLoading = false;
|
|
887
|
-
this.showchart = true;
|
|
888
|
-
this.lastDrawTime = Date.now();
|
|
889
|
-
this.cWidth = data.width;
|
|
890
|
-
this.cHeight = data.height;
|
|
891
|
-
if(this.echarts !== true){
|
|
892
|
-
cfu.option[cid].background = this.background == 'rgba(0,0,0,0)' ? '#FFFFFF' : this.background;
|
|
893
|
-
cfu.option[cid].canvas2d = this.type2d;
|
|
894
|
-
cfu.option[cid].pixelRatio = this.pixel;
|
|
895
|
-
cfu.option[cid].animation = this.animation;
|
|
896
|
-
cfu.option[cid].width = data.width * this.pixel;
|
|
897
|
-
cfu.option[cid].height = data.height * this.pixel;
|
|
898
|
-
cfu.option[cid].onzoom = this.onzoom;
|
|
899
|
-
cfu.option[cid].ontap = this.ontap;
|
|
900
|
-
cfu.option[cid].ontouch = this.ontouch;
|
|
901
|
-
cfu.option[cid].onmouse = this.openmouse;
|
|
902
|
-
cfu.option[cid].onmovetip = this.onmovetip;
|
|
903
|
-
cfu.option[cid].tooltipShow = this.tooltipShow;
|
|
904
|
-
cfu.option[cid].tooltipFormat = this.tooltipFormat;
|
|
905
|
-
cfu.option[cid].tooltipCustom = this.tooltipCustom;
|
|
906
|
-
cfu.option[cid].inScrollView = this.inScrollView;
|
|
907
|
-
cfu.option[cid].lastDrawTime = this.lastDrawTime;
|
|
908
|
-
cfu.option[cid].tapLegend = this.tapLegend;
|
|
909
|
-
}
|
|
910
|
-
//如果是H5或者App端,采用renderjs渲染图表
|
|
911
|
-
if (this.inH5 || this.inApp) {
|
|
912
|
-
if (this.echarts == true) {
|
|
913
|
-
cfe.option[cid].ontap = this.ontap;
|
|
914
|
-
cfe.option[cid].onmouse = this.openmouse;
|
|
915
|
-
cfe.option[cid].tooltipShow = this.tooltipShow;
|
|
916
|
-
cfe.option[cid].tooltipFormat = this.tooltipFormat;
|
|
917
|
-
cfe.option[cid].tooltipCustom = this.tooltipCustom;
|
|
918
|
-
cfe.option[cid].lastDrawTime = this.lastDrawTime;
|
|
919
|
-
this.echartsOpts = deepCloneAssign({}, cfe.option[cid]);
|
|
920
|
-
} else {
|
|
921
|
-
cfu.option[cid].rotateLock = cfu.option[cid].rotate;
|
|
922
|
-
this.uchartsOpts = deepCloneAssign({}, cfu.option[cid]);
|
|
923
|
-
}
|
|
924
|
-
//如果是小程序端,采用uCharts渲染
|
|
925
|
-
} else {
|
|
926
|
-
cfu.option[cid] = formatterAssign(cfu.option[cid],cfu.formatter)
|
|
927
|
-
this.mixinDatacomErrorMessage = null;
|
|
928
|
-
this.mixinDatacomLoading = false;
|
|
929
|
-
this.showchart = true;
|
|
930
|
-
this.$nextTick(()=>{
|
|
931
|
-
if (this.type2d === true) {
|
|
932
|
-
const query = uni.createSelectorQuery().in(this)
|
|
933
|
-
query
|
|
934
|
-
.select('#' + cid)
|
|
935
|
-
.fields({ node: true, size: true })
|
|
936
|
-
.exec(res => {
|
|
937
|
-
if (res[0]) {
|
|
938
|
-
const canvas = res[0].node;
|
|
939
|
-
const ctx = canvas.getContext('2d');
|
|
940
|
-
cfu.option[cid].context = ctx;
|
|
941
|
-
cfu.option[cid].rotateLock = cfu.option[cid].rotate;
|
|
942
|
-
if(cfu.instance[cid] && cfu.option[cid] && cfu.option[cid].update === true){
|
|
943
|
-
this._updataUChart(cid)
|
|
944
|
-
}else{
|
|
945
|
-
canvas.width = data.width * this.pixel;
|
|
946
|
-
canvas.height = data.height * this.pixel;
|
|
947
|
-
canvas._width = data.width * this.pixel;
|
|
948
|
-
canvas._height = data.height * this.pixel;
|
|
949
|
-
setTimeout(()=>{
|
|
950
|
-
cfu.option[cid].context.restore();
|
|
951
|
-
cfu.option[cid].context.save();
|
|
952
|
-
this._newChart(cid)
|
|
953
|
-
},100)
|
|
954
|
-
}
|
|
955
|
-
} else {
|
|
956
|
-
this.showchart = false;
|
|
957
|
-
this.mixinDatacomErrorMessage = '参数错误:开启2d模式后,未获取到dom节点,canvas-id:' + cid;
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
} else {
|
|
961
|
-
if(this.inAli){
|
|
962
|
-
cfu.option[cid].rotateLock = cfu.option[cid].rotate;
|
|
963
|
-
}
|
|
964
|
-
cfu.option[cid].context = uni.createCanvasContext(cid, this);
|
|
965
|
-
if(cfu.instance[cid] && cfu.option[cid] && cfu.option[cid].update === true){
|
|
966
|
-
this._updataUChart(cid)
|
|
967
|
-
}else{
|
|
968
|
-
setTimeout(()=>{
|
|
969
|
-
cfu.option[cid].context.restore();
|
|
970
|
-
cfu.option[cid].context.save();
|
|
971
|
-
this._newChart(cid)
|
|
972
|
-
},100)
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
})
|
|
976
|
-
}
|
|
977
|
-
} else {
|
|
978
|
-
this.mixinDatacomLoading = false;
|
|
979
|
-
this.showchart = false;
|
|
980
|
-
if (this.reshow == true) {
|
|
981
|
-
this.mixinDatacomErrorMessage = '布局错误:未获取到父元素宽高尺寸!canvas-id:' + cid;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
})
|
|
985
|
-
.exec();
|
|
986
|
-
},
|
|
987
|
-
saveImage(){
|
|
988
|
-
uni.canvasToTempFilePath({
|
|
989
|
-
canvasId: this.cid,
|
|
990
|
-
success: res=>{
|
|
991
|
-
//#ifdef H5
|
|
992
|
-
var a = document.createElement("a");
|
|
993
|
-
a.href = res.tempFilePath;
|
|
994
|
-
a.download = this.cid;
|
|
995
|
-
a.target = '_blank'
|
|
996
|
-
a.click();
|
|
997
|
-
//#endif
|
|
998
|
-
//#ifndef H5
|
|
999
|
-
uni.saveImageToPhotosAlbum({
|
|
1000
|
-
filePath: res.tempFilePath,
|
|
1001
|
-
success: function () {
|
|
1002
|
-
uni.showToast({
|
|
1003
|
-
title: '保存成功',
|
|
1004
|
-
duration: 2000
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
//#endif
|
|
1009
|
-
}
|
|
1010
|
-
},this);
|
|
1011
|
-
},
|
|
1012
|
-
getImage(){
|
|
1013
|
-
if(this.type2d == false){
|
|
1014
|
-
uni.canvasToTempFilePath({
|
|
1015
|
-
canvasId: this.cid,
|
|
1016
|
-
success: res=>{
|
|
1017
|
-
this.emitMsg({name: 'getImage', params: {type:"getImage", base64: res.tempFilePath}});
|
|
1018
|
-
}
|
|
1019
|
-
},this);
|
|
1020
|
-
}else{
|
|
1021
|
-
const query = uni.createSelectorQuery().in(this)
|
|
1022
|
-
query
|
|
1023
|
-
.select('#' + this.cid)
|
|
1024
|
-
.fields({ node: true, size: true })
|
|
1025
|
-
.exec(res => {
|
|
1026
|
-
if (res[0]) {
|
|
1027
|
-
const canvas = res[0].node;
|
|
1028
|
-
this.emitMsg({name: 'getImage', params: {type:"getImage", base64: canvas.toDataURL('image/png')}});
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
},
|
|
1033
|
-
// #ifndef APP-VUE || H5
|
|
1034
|
-
_newChart(cid) {
|
|
1035
|
-
if (this.mixinDatacomLoading == true) {
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
this.showchart = true;
|
|
1039
|
-
cfu.instance[cid] = new uCharts(cfu.option[cid]);
|
|
1040
|
-
cfu.instance[cid].addEventListener('renderComplete', () => {
|
|
1041
|
-
this.emitMsg({name: 'complete', params: {type:"complete", complete: true, id: cid, opts: cfu.instance[cid].opts}});
|
|
1042
|
-
cfu.instance[cid].delEventListener('renderComplete')
|
|
1043
|
-
});
|
|
1044
|
-
cfu.instance[cid].addEventListener('scrollLeft', () => {
|
|
1045
|
-
this.emitMsg({name: 'scrollLeft', params: {type:"scrollLeft", scrollLeft: true, id: cid, opts: cfu.instance[cid].opts}});
|
|
1046
|
-
});
|
|
1047
|
-
cfu.instance[cid].addEventListener('scrollRight', () => {
|
|
1048
|
-
this.emitMsg({name: 'scrollRight', params: {type:"scrollRight", scrollRight: true, id: cid, opts: cfu.instance[cid].opts}});
|
|
1049
|
-
});
|
|
1050
|
-
},
|
|
1051
|
-
_updataUChart(cid) {
|
|
1052
|
-
cfu.instance[cid].updateData(cfu.option[cid])
|
|
1053
|
-
},
|
|
1054
|
-
_tooltipDefault(item, category, index, opts) {
|
|
1055
|
-
if (category) {
|
|
1056
|
-
let data = item.data
|
|
1057
|
-
if(typeof item.data === "object"){
|
|
1058
|
-
data = item.data.value
|
|
1059
|
-
}
|
|
1060
|
-
return category + ' ' + item.name + ':' + data;
|
|
1061
|
-
} else {
|
|
1062
|
-
if (item.properties && item.properties.name) {
|
|
1063
|
-
return item.properties.name;
|
|
1064
|
-
} else {
|
|
1065
|
-
return item.name + ':' + item.data;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
_showTooltip(e) {
|
|
1070
|
-
let cid = this.cid
|
|
1071
|
-
let tc = cfu.option[cid].tooltipCustom
|
|
1072
|
-
if (tc && tc !== undefined && tc !== null) {
|
|
1073
|
-
let offset = undefined;
|
|
1074
|
-
if (tc.x >= 0 && tc.y >= 0) {
|
|
1075
|
-
offset = { x: tc.x, y: tc.y + 10 };
|
|
1076
|
-
}
|
|
1077
|
-
cfu.instance[cid].showToolTip(e, {
|
|
1078
|
-
index: tc.index,
|
|
1079
|
-
offset: offset,
|
|
1080
|
-
textList: tc.textList,
|
|
1081
|
-
formatter: (item, category, index, opts) => {
|
|
1082
|
-
if (typeof cfu.option[cid].tooltipFormat === 'string' && cfu.formatter[cfu.option[cid].tooltipFormat]) {
|
|
1083
|
-
return cfu.formatter[cfu.option[cid].tooltipFormat](item, category, index, opts);
|
|
1084
|
-
} else {
|
|
1085
|
-
return this._tooltipDefault(item, category, index, opts);
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
} else {
|
|
1090
|
-
cfu.instance[cid].showToolTip(e, {
|
|
1091
|
-
formatter: (item, category, index, opts) => {
|
|
1092
|
-
if (typeof cfu.option[cid].tooltipFormat === 'string' && cfu.formatter[cfu.option[cid].tooltipFormat]) {
|
|
1093
|
-
return cfu.formatter[cfu.option[cid].tooltipFormat](item, category, index, opts);
|
|
1094
|
-
} else {
|
|
1095
|
-
return this._tooltipDefault(item, category, index, opts);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
},
|
|
1101
|
-
_tap(e,move) {
|
|
1102
|
-
let cid = this.cid
|
|
1103
|
-
let currentIndex = null;
|
|
1104
|
-
let legendIndex = null;
|
|
1105
|
-
if (this.inScrollView === true || this.inAli) {
|
|
1106
|
-
let chartdom = uni
|
|
1107
|
-
.createSelectorQuery()
|
|
1108
|
-
// #ifndef MP-ALIPAY
|
|
1109
|
-
.in(this)
|
|
1110
|
-
.select('#ChartBoxId'+cid)
|
|
1111
|
-
// #endif
|
|
1112
|
-
// #ifdef MP-ALIPAY
|
|
1113
|
-
.select('#'+this.cid)
|
|
1114
|
-
// #endif
|
|
1115
|
-
.boundingClientRect(data => {
|
|
1116
|
-
e.changedTouches=[];
|
|
1117
|
-
if (this.inAli) {
|
|
1118
|
-
e.changedTouches.unshift({ x: e.detail.clientX - data.left, y: e.detail.clientY - data.top});
|
|
1119
|
-
}else{
|
|
1120
|
-
e.changedTouches.unshift({ x: e.detail.x - data.left, y: e.detail.y - data.top - this.pageScrollTop});
|
|
1121
|
-
}
|
|
1122
|
-
if(move){
|
|
1123
|
-
if (this.tooltipShow === true) {
|
|
1124
|
-
this._showTooltip(e);
|
|
1125
|
-
}
|
|
1126
|
-
}else{
|
|
1127
|
-
currentIndex = cfu.instance[cid].getCurrentDataIndex(e);
|
|
1128
|
-
legendIndex = cfu.instance[cid].getLegendDataIndex(e);
|
|
1129
|
-
if(this.tapLegend === true){
|
|
1130
|
-
cfu.instance[cid].touchLegend(e);
|
|
1131
|
-
}
|
|
1132
|
-
if (this.tooltipShow === true) {
|
|
1133
|
-
this._showTooltip(e);
|
|
1134
|
-
}
|
|
1135
|
-
this.emitMsg({name: 'getIndex', params: { type:"getIndex", event:{ x: e.detail.x - data.left, y: e.detail.y - data.top }, currentIndex: currentIndex, legendIndex: legendIndex, id: cid, opts: cfu.instance[cid].opts}});
|
|
1136
|
-
}
|
|
1137
|
-
})
|
|
1138
|
-
.exec();
|
|
1139
|
-
} else {
|
|
1140
|
-
if(move){
|
|
1141
|
-
if (this.tooltipShow === true) {
|
|
1142
|
-
this._showTooltip(e);
|
|
1143
|
-
}
|
|
1144
|
-
}else{
|
|
1145
|
-
e.changedTouches=[];
|
|
1146
|
-
e.changedTouches.unshift({ x: e.detail.x - e.currentTarget.offsetLeft, y: e.detail.y - e.currentTarget.offsetTop });
|
|
1147
|
-
currentIndex = cfu.instance[cid].getCurrentDataIndex(e);
|
|
1148
|
-
legendIndex = cfu.instance[cid].getLegendDataIndex(e);
|
|
1149
|
-
if(this.tapLegend === true){
|
|
1150
|
-
cfu.instance[cid].touchLegend(e);
|
|
1151
|
-
}
|
|
1152
|
-
if (this.tooltipShow === true) {
|
|
1153
|
-
this._showTooltip(e);
|
|
1154
|
-
}
|
|
1155
|
-
this.emitMsg({name: 'getIndex', params: {type:"getIndex", event:{ x: e.detail.x, y: e.detail.y - e.currentTarget.offsetTop }, currentIndex: currentIndex, legendIndex: legendIndex, id: cid, opts: cfu.instance[cid].opts}});
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
},
|
|
1159
|
-
_touchStart(e) {
|
|
1160
|
-
let cid = this.cid
|
|
1161
|
-
lastMoveTime=Date.now();
|
|
1162
|
-
if(cfu.option[cid].enableScroll === true && e.touches.length == 1){
|
|
1163
|
-
cfu.instance[cid].scrollStart(e);
|
|
1164
|
-
}
|
|
1165
|
-
this.emitMsg({name:'getTouchStart', params:{type:"touchStart", event:e.changedTouches[0], id:cid, opts: cfu.instance[cid].opts}});
|
|
1166
|
-
},
|
|
1167
|
-
_touchMove(e) {
|
|
1168
|
-
let cid = this.cid
|
|
1169
|
-
let currMoveTime = Date.now();
|
|
1170
|
-
let duration = currMoveTime - lastMoveTime;
|
|
1171
|
-
let touchMoveLimit = cfu.option[cid].touchMoveLimit || 24;
|
|
1172
|
-
if (duration < Math.floor(1000 / touchMoveLimit)) return;//每秒60帧
|
|
1173
|
-
lastMoveTime = currMoveTime;
|
|
1174
|
-
if(cfu.option[cid].enableScroll === true && e.changedTouches.length == 1){
|
|
1175
|
-
cfu.instance[cid].scroll(e);
|
|
1176
|
-
}
|
|
1177
|
-
if(this.ontap === true && cfu.option[cid].enableScroll === false && this.onmovetip === true){
|
|
1178
|
-
this._tap(e,true)
|
|
1179
|
-
}
|
|
1180
|
-
if(this.ontouch === true && cfu.option[cid].enableScroll === true && this.onzoom === true && e.changedTouches.length == 2){
|
|
1181
|
-
cfu.instance[cid].dobuleZoom(e);
|
|
1182
|
-
}
|
|
1183
|
-
this.emitMsg({name: 'getTouchMove', params: {type:"touchMove", event:e.changedTouches[0], id: cid, opts: cfu.instance[cid].opts}});
|
|
1184
|
-
},
|
|
1185
|
-
_touchEnd(e) {
|
|
1186
|
-
let cid = this.cid
|
|
1187
|
-
if(cfu.option[cid].enableScroll === true && e.touches.length == 0){
|
|
1188
|
-
cfu.instance[cid].scrollEnd(e);
|
|
1189
|
-
}
|
|
1190
|
-
this.emitMsg({name:'getTouchEnd', params:{type:"touchEnd", event:e.changedTouches[0], id:cid, opts: cfu.instance[cid].opts}});
|
|
1191
|
-
if(this.ontap === true && cfu.option[cid].enableScroll === false && this.onmovetip === true){
|
|
1192
|
-
this._tap(e,true)
|
|
1193
|
-
}
|
|
1194
|
-
},
|
|
1195
|
-
// #endif
|
|
1196
|
-
_error(e) {
|
|
1197
|
-
this.mixinDatacomErrorMessage = e.detail.errMsg;
|
|
1198
|
-
},
|
|
1199
|
-
emitMsg(msg) {
|
|
1200
|
-
this.$emit(msg.name, msg.params);
|
|
1201
|
-
},
|
|
1202
|
-
getRenderType() {
|
|
1203
|
-
//防止如果开启echarts且父元素为v-if的情况renderjs监听不到prop变化的问题
|
|
1204
|
-
if(this.echarts===true && this.mixinDatacomLoading===false){
|
|
1205
|
-
this.beforeInit()
|
|
1206
|
-
}
|
|
1207
|
-
},
|
|
1208
|
-
toJSON(){
|
|
1209
|
-
return this
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
|
-
</script>
|
|
1214
|
-
|
|
1215
|
-
<!-- #ifdef APP-VUE || H5 -->
|
|
1216
|
-
<script module="rdcharts" lang="renderjs">
|
|
1217
|
-
import uChartsRD from '../../js_sdk/u-charts/u-charts.js';
|
|
1218
|
-
import cfu from '../../js_sdk/u-charts/config-ucharts.js';
|
|
1219
|
-
import cfe from '../../js_sdk/u-charts/config-echarts.js';
|
|
1220
|
-
|
|
1221
|
-
var that = {};
|
|
1222
|
-
var rootdom = null;
|
|
1223
|
-
|
|
1224
|
-
function rddeepCloneAssign(origin = {}, ...args) {
|
|
1225
|
-
for (let i in args) {
|
|
1226
|
-
for (let key in args[i]) {
|
|
1227
|
-
if (args[i].hasOwnProperty(key)) {
|
|
1228
|
-
origin[key] = args[i][key] && typeof args[i][key] === 'object' ? rddeepCloneAssign(Array.isArray(args[i][key]) ? [] : {}, origin[key], args[i][key]) : args[i][key];
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
return origin;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
function rdformatterAssign(args,formatter) {
|
|
1236
|
-
for (let key in args) {
|
|
1237
|
-
if(args.hasOwnProperty(key) && args[key] !== null && typeof args[key] === 'object'){
|
|
1238
|
-
rdformatterAssign(args[key],formatter)
|
|
1239
|
-
}else if(key === 'format' && typeof args[key] === 'string'){
|
|
1240
|
-
args['formatter'] = formatter[args[key]] ? formatter[args[key]] : undefined;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
return args;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
export default {
|
|
1247
|
-
data() {
|
|
1248
|
-
return {
|
|
1249
|
-
rid:null
|
|
1250
|
-
}
|
|
1251
|
-
},
|
|
1252
|
-
mounted() {
|
|
1253
|
-
rootdom = {top:0,left:0}
|
|
1254
|
-
// #ifdef H5
|
|
1255
|
-
let dm = document.querySelectorAll('uni-main')[0]
|
|
1256
|
-
if(dm === undefined){
|
|
1257
|
-
dm = document.querySelectorAll('uni-page-wrapper')[0]
|
|
1258
|
-
}
|
|
1259
|
-
rootdom = {top:dm.offsetTop,left:dm.offsetLeft}
|
|
1260
|
-
// #endif
|
|
1261
|
-
setTimeout(()=>{
|
|
1262
|
-
if(this.rid === null){
|
|
1263
|
-
this.$ownerInstance && this.$ownerInstance.callMethod('getRenderType')
|
|
1264
|
-
}
|
|
1265
|
-
},200)
|
|
1266
|
-
},
|
|
1267
|
-
destroyed(){
|
|
1268
|
-
delete cfu.option[this.rid]
|
|
1269
|
-
delete cfu.instance[this.rid]
|
|
1270
|
-
delete cfe.option[this.rid]
|
|
1271
|
-
delete cfe.instance[this.rid]
|
|
1272
|
-
},
|
|
1273
|
-
methods: {
|
|
1274
|
-
//==============以下是ECharts的方法====================
|
|
1275
|
-
ecinit(newVal, oldVal, owner, instance){
|
|
1276
|
-
let cid = JSON.stringify(newVal.id)
|
|
1277
|
-
this.rid = cid
|
|
1278
|
-
that[cid] = this.$ownerInstance || instance
|
|
1279
|
-
let eopts = JSON.parse(JSON.stringify(newVal))
|
|
1280
|
-
let type = eopts.type;
|
|
1281
|
-
//载入并覆盖默认配置
|
|
1282
|
-
if (type && cfe.type.includes(type)) {
|
|
1283
|
-
cfe.option[cid] = rddeepCloneAssign({}, cfe[type], eopts);
|
|
1284
|
-
}else{
|
|
1285
|
-
cfe.option[cid] = rddeepCloneAssign({}, eopts);
|
|
1286
|
-
}
|
|
1287
|
-
let newData = eopts.chartData;
|
|
1288
|
-
if(newData){
|
|
1289
|
-
//挂载categories和series
|
|
1290
|
-
if(cfe.option[cid].xAxis && cfe.option[cid].xAxis.type && cfe.option[cid].xAxis.type === 'category'){
|
|
1291
|
-
cfe.option[cid].xAxis.data = newData.categories
|
|
1292
|
-
}
|
|
1293
|
-
if(cfe.option[cid].yAxis && cfe.option[cid].yAxis.type && cfe.option[cid].yAxis.type === 'category'){
|
|
1294
|
-
cfe.option[cid].yAxis.data = newData.categories
|
|
1295
|
-
}
|
|
1296
|
-
cfe.option[cid].series = []
|
|
1297
|
-
for (var i = 0; i < newData.series.length; i++) {
|
|
1298
|
-
cfe.option[cid].seriesTemplate = cfe.option[cid].seriesTemplate ? cfe.option[cid].seriesTemplate : {}
|
|
1299
|
-
let Template = rddeepCloneAssign({},cfe.option[cid].seriesTemplate,newData.series[i])
|
|
1300
|
-
cfe.option[cid].series.push(Template)
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
if (typeof window.echarts === 'object') {
|
|
1305
|
-
this.newEChart()
|
|
1306
|
-
}else{
|
|
1307
|
-
const script = document.createElement('script')
|
|
1308
|
-
// #ifdef APP-VUE
|
|
1309
|
-
script.src = './uni_modules/qiun-data-charts/static/app-plus/echarts.min.js'
|
|
1310
|
-
// #endif
|
|
1311
|
-
// #ifdef H5
|
|
1312
|
-
const rooturl = window.location.origin
|
|
1313
|
-
const directory = instance.getDataset().directory
|
|
1314
|
-
script.src = rooturl + directory + 'uni_modules/qiun-data-charts/static/h5/echarts.min.js'
|
|
1315
|
-
// #endif
|
|
1316
|
-
script.onload = this.newEChart
|
|
1317
|
-
document.head.appendChild(script)
|
|
1318
|
-
}
|
|
1319
|
-
},
|
|
1320
|
-
ecresize(newVal, oldVal, owner, instance){
|
|
1321
|
-
if(cfe.instance[this.rid]){
|
|
1322
|
-
cfe.instance[this.rid].resize()
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
newEChart(){
|
|
1326
|
-
let cid = this.rid
|
|
1327
|
-
if(cfe.instance[cid] === undefined){
|
|
1328
|
-
cfe.instance[cid] = echarts.init(that[cid].$el.children[0])
|
|
1329
|
-
//ontap开启后才触发click事件
|
|
1330
|
-
if(cfe.option[cid].ontap === true){
|
|
1331
|
-
cfe.instance[cid].on('click', resdata => {
|
|
1332
|
-
let event = JSON.parse(JSON.stringify({
|
|
1333
|
-
x:resdata.event.offsetX,y:resdata.event.offsetY
|
|
1334
|
-
}))
|
|
1335
|
-
that[cid].callMethod('emitMsg',{name:"getIndex", params:{type:"getIndex", event:event, currentIndex:resdata.dataIndex, value:resdata.data, seriesName: resdata.seriesName,id:cid}})
|
|
1336
|
-
})
|
|
1337
|
-
// 增加ECharts的highlight消息,实现按下移动返回索引功能。add by onefish 创建于 2021-12-11 09:50
|
|
1338
|
-
cfe.instance[cid].on('highlight', resdata => {
|
|
1339
|
-
that[cid].callMethod('emitMsg',{name:"getHighlight", params:{type:"highlight", res:resdata, id:cid}})
|
|
1340
|
-
})
|
|
1341
|
-
}
|
|
1342
|
-
this.updataEChart(cid,cfe.option[cid])
|
|
1343
|
-
}else{
|
|
1344
|
-
this.updataEChart(cid,cfe.option[cid])
|
|
1345
|
-
}
|
|
1346
|
-
},
|
|
1347
|
-
updataEChart(cid,option){
|
|
1348
|
-
//替换option内format属性为formatter的预定义方法
|
|
1349
|
-
option = rdformatterAssign(option,cfe.formatter)
|
|
1350
|
-
if(option.tooltip){
|
|
1351
|
-
option.tooltip.show = option.tooltipShow?true:false;
|
|
1352
|
-
option.tooltip.position = this.tooltipPosition()
|
|
1353
|
-
//tooltipFormat方法,替换组件的tooltipFormat为config-echarts.js内对应的方法
|
|
1354
|
-
if (typeof option.tooltipFormat === 'string' && cfe.formatter[option.tooltipFormat]) {
|
|
1355
|
-
option.tooltip.formatter = option.tooltip.formatter ? option.tooltip.formatter : cfe.formatter[option.tooltipFormat]
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
// 颜色渐变添加的方法
|
|
1359
|
-
if (option.series) {
|
|
1360
|
-
for (let i in option.series) {
|
|
1361
|
-
let linearGradient = option.series[i].linearGradient
|
|
1362
|
-
if (linearGradient) {
|
|
1363
|
-
option.series[i].color = new echarts.graphic.LinearGradient(linearGradient[0],linearGradient[1],linearGradient[2],linearGradient[3],linearGradient[4])
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
cfe.instance[cid].setOption(option, option.notMerge)
|
|
1368
|
-
cfe.instance[cid].on('finished', function(){
|
|
1369
|
-
that[cid].callMethod('emitMsg',{name:"complete",params:{type:"complete",complete:true,id:cid}})
|
|
1370
|
-
if(cfe.instance[cid]){
|
|
1371
|
-
cfe.instance[cid].off('finished')
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
|
|
1375
|
-
//修复init初始化实例获取宽高不正确问题
|
|
1376
|
-
if(
|
|
1377
|
-
typeof that[cid].$el.children[0].clientWidth != 'undefined' &&
|
|
1378
|
-
(
|
|
1379
|
-
Math.abs( that[cid].$el.children[0].clientWidth - cfe.instance[cid].getWidth() )>3 ||
|
|
1380
|
-
Math.abs( that[cid].$el.children[0].clientHeight - cfe.instance[cid].getHeight() )>3
|
|
1381
|
-
)
|
|
1382
|
-
){this.ecresize();}
|
|
1383
|
-
},
|
|
1384
|
-
tooltipPosition(){
|
|
1385
|
-
return (point, params, dom, rect, size) => {
|
|
1386
|
-
let x = point[0]
|
|
1387
|
-
let y = point[1]
|
|
1388
|
-
let viewWidth = size.viewSize[0]
|
|
1389
|
-
let viewHeight = size.viewSize[1]
|
|
1390
|
-
let boxWidth = size.contentSize[0]
|
|
1391
|
-
let boxHeight = size.contentSize[1]
|
|
1392
|
-
let posX = x + 30
|
|
1393
|
-
let posY = y + 30
|
|
1394
|
-
if (posX + boxWidth > viewWidth) {
|
|
1395
|
-
posX = x - boxWidth - 30
|
|
1396
|
-
}
|
|
1397
|
-
if (posY + boxHeight > viewHeight) {
|
|
1398
|
-
posY = y - boxHeight - 30
|
|
1399
|
-
}
|
|
1400
|
-
return [posX, posY]
|
|
1401
|
-
}
|
|
1402
|
-
},
|
|
1403
|
-
//==============以下是uCharts的方法====================
|
|
1404
|
-
ucinit(newVal, oldVal, owner, instance){
|
|
1405
|
-
if(JSON.stringify(newVal) == JSON.stringify(oldVal)){
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
if(!newVal.canvasId){
|
|
1409
|
-
return;
|
|
1410
|
-
}
|
|
1411
|
-
let cid = JSON.parse(JSON.stringify(newVal.canvasId))
|
|
1412
|
-
this.rid = cid
|
|
1413
|
-
that[cid] = this.$ownerInstance || instance
|
|
1414
|
-
cfu.option[cid] = JSON.parse(JSON.stringify(newVal))
|
|
1415
|
-
cfu.option[cid] = rdformatterAssign(cfu.option[cid],cfu.formatter)
|
|
1416
|
-
let canvasdom = document.getElementById(cid)
|
|
1417
|
-
if(canvasdom && canvasdom.children[0]){
|
|
1418
|
-
cfu.option[cid].context = canvasdom.children[0].getContext("2d")
|
|
1419
|
-
if(cfu.instance[cid] && cfu.option[cid] && cfu.option[cid].update === true){
|
|
1420
|
-
this.updataUChart()
|
|
1421
|
-
}else{
|
|
1422
|
-
setTimeout(()=>{
|
|
1423
|
-
cfu.option[cid].context.restore();
|
|
1424
|
-
cfu.option[cid].context.save();
|
|
1425
|
-
this.newUChart()
|
|
1426
|
-
},100)
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
},
|
|
1430
|
-
newUChart() {
|
|
1431
|
-
let cid = this.rid
|
|
1432
|
-
cfu.instance[cid] = new uChartsRD(cfu.option[cid])
|
|
1433
|
-
cfu.instance[cid].addEventListener('renderComplete', () => {
|
|
1434
|
-
that[cid].callMethod('emitMsg',{name:"complete",params:{type:"complete",complete:true,id:cid, opts: cfu.instance[cid].opts}})
|
|
1435
|
-
cfu.instance[cid].delEventListener('renderComplete')
|
|
1436
|
-
});
|
|
1437
|
-
cfu.instance[cid].addEventListener('scrollLeft', () => {
|
|
1438
|
-
that[cid].callMethod('emitMsg',{name:"scrollLeft",params:{type:"scrollLeft",scrollLeft:true,id:cid, opts: cfu.instance[cid].opts}})
|
|
1439
|
-
});
|
|
1440
|
-
cfu.instance[cid].addEventListener('scrollRight', () => {
|
|
1441
|
-
that[cid].callMethod('emitMsg',{name:"scrollRight",params:{type:"scrollRight",scrollRight:true,id:cid, opts: cfu.instance[cid].opts}})
|
|
1442
|
-
});
|
|
1443
|
-
},
|
|
1444
|
-
updataUChart() {
|
|
1445
|
-
let cid = this.rid
|
|
1446
|
-
cfu.instance[cid].updateData(cfu.option[cid])
|
|
1447
|
-
},
|
|
1448
|
-
tooltipDefault(item, category, index, opts) {
|
|
1449
|
-
if (category) {
|
|
1450
|
-
let data = item.data
|
|
1451
|
-
if(typeof item.data === "object"){
|
|
1452
|
-
data = item.data.value
|
|
1453
|
-
}
|
|
1454
|
-
return category + ' ' + item.name + ':' + data;
|
|
1455
|
-
} else {
|
|
1456
|
-
if (item.properties && item.properties.name) {
|
|
1457
|
-
return item.properties.name ;
|
|
1458
|
-
} else {
|
|
1459
|
-
return item.name + ':' + item.data;
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
},
|
|
1463
|
-
showTooltip(e,cid) {
|
|
1464
|
-
let tc = cfu.option[cid].tooltipCustom
|
|
1465
|
-
if (tc && tc !== undefined && tc !== null) {
|
|
1466
|
-
let offset = undefined;
|
|
1467
|
-
if (tc.x >= 0 && tc.y >= 0) {
|
|
1468
|
-
offset = { x: tc.x, y: tc.y + 10 };
|
|
1469
|
-
}
|
|
1470
|
-
cfu.instance[cid].showToolTip(e, {
|
|
1471
|
-
index: tc.index,
|
|
1472
|
-
offset: offset,
|
|
1473
|
-
textList: tc.textList,
|
|
1474
|
-
formatter: (item, category, index, opts) => {
|
|
1475
|
-
if (typeof cfu.option[cid].tooltipFormat === 'string' && cfu.formatter[cfu.option[cid].tooltipFormat]) {
|
|
1476
|
-
return cfu.formatter[cfu.option[cid].tooltipFormat](item, category, index, opts);
|
|
1477
|
-
} else {
|
|
1478
|
-
return this.tooltipDefault(item, category, index, opts);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
});
|
|
1482
|
-
} else {
|
|
1483
|
-
cfu.instance[cid].showToolTip(e, {
|
|
1484
|
-
formatter: (item, category, index, opts) => {
|
|
1485
|
-
if (typeof cfu.option[cid].tooltipFormat === 'string' && cfu.formatter[cfu.option[cid].tooltipFormat]) {
|
|
1486
|
-
return cfu.formatter[cfu.option[cid].tooltipFormat](item, category, index, opts);
|
|
1487
|
-
} else {
|
|
1488
|
-
return this.tooltipDefault(item, category, index, opts);
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
},
|
|
1494
|
-
tap(e) {
|
|
1495
|
-
let cid = this.rid
|
|
1496
|
-
let ontap = cfu.option[cid].ontap
|
|
1497
|
-
let tooltipShow = cfu.option[cid].tooltipShow
|
|
1498
|
-
let tapLegend = cfu.option[cid].tapLegend
|
|
1499
|
-
if(ontap == false) return;
|
|
1500
|
-
let currentIndex=null
|
|
1501
|
-
let legendIndex=null
|
|
1502
|
-
let rchartdom = document.getElementById('UC'+cid).getBoundingClientRect()
|
|
1503
|
-
let tmpe = {}
|
|
1504
|
-
if(e.detail.x){//tap或者click的事件
|
|
1505
|
-
tmpe = { x: e.detail.x - rchartdom.left, y:e.detail.y - rchartdom.top + rootdom.top}
|
|
1506
|
-
}else{//mouse的事件
|
|
1507
|
-
tmpe = { x: e.clientX - rchartdom.left, y:e.clientY - rchartdom.top + rootdom.top}
|
|
1508
|
-
}
|
|
1509
|
-
e.changedTouches = [];
|
|
1510
|
-
e.changedTouches.unshift(tmpe)
|
|
1511
|
-
currentIndex=cfu.instance[cid].getCurrentDataIndex(e)
|
|
1512
|
-
legendIndex=cfu.instance[cid].getLegendDataIndex(e)
|
|
1513
|
-
if(tapLegend === true){
|
|
1514
|
-
cfu.instance[cid].touchLegend(e);
|
|
1515
|
-
}
|
|
1516
|
-
if(tooltipShow==true){
|
|
1517
|
-
this.showTooltip(e,cid)
|
|
1518
|
-
}
|
|
1519
|
-
that[cid].callMethod('emitMsg',{name:"getIndex",params:{type:"getIndex",event:tmpe,currentIndex:currentIndex,legendIndex:legendIndex,id:cid, opts: cfu.instance[cid].opts}})
|
|
1520
|
-
},
|
|
1521
|
-
touchStart(e) {
|
|
1522
|
-
let cid = this.rid
|
|
1523
|
-
let ontouch = cfu.option[cid].ontouch
|
|
1524
|
-
if(ontouch == false) return;
|
|
1525
|
-
if(cfu.option[cid].enableScroll === true && e.touches.length == 1){
|
|
1526
|
-
cfu.instance[cid].scrollStart(e);
|
|
1527
|
-
}
|
|
1528
|
-
that[cid].callMethod('emitMsg',{name:"getTouchStart",params:{type:"touchStart",event:e.changedTouches[0],id:cid, opts: cfu.instance[cid].opts}})
|
|
1529
|
-
},
|
|
1530
|
-
touchMove(e) {
|
|
1531
|
-
let cid = this.rid
|
|
1532
|
-
let ontouch = cfu.option[cid].ontouch
|
|
1533
|
-
if(ontouch == false) return;
|
|
1534
|
-
if(cfu.option[cid].enableScroll === true && e.changedTouches.length == 1){
|
|
1535
|
-
cfu.instance[cid].scroll(e);
|
|
1536
|
-
}
|
|
1537
|
-
if(cfu.option[cid].ontap === true && cfu.option[cid].enableScroll === false && cfu.option[cid].onmovetip === true){
|
|
1538
|
-
let rchartdom = document.getElementById('UC'+cid).getBoundingClientRect()
|
|
1539
|
-
let tmpe = { x: e.changedTouches[0].clientX - rchartdom.left, y:e.changedTouches[0].clientY - rchartdom.top + rootdom.top}
|
|
1540
|
-
e.changedTouches.unshift(tmpe)
|
|
1541
|
-
if(cfu.option[cid].tooltipShow === true){
|
|
1542
|
-
this.showTooltip(e,cid)
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
if(ontouch === true && cfu.option[cid].enableScroll === true && cfu.option[cid].onzoom === true && e.changedTouches.length == 2){
|
|
1546
|
-
cfu.instance[cid].dobuleZoom(e);
|
|
1547
|
-
}
|
|
1548
|
-
that[cid].callMethod('emitMsg',{name:"getTouchMove",params:{type:"touchMove",event:e.changedTouches[0],id:cid, opts: cfu.instance[cid].opts}})
|
|
1549
|
-
},
|
|
1550
|
-
touchEnd(e) {
|
|
1551
|
-
let cid = this.rid
|
|
1552
|
-
let ontouch = cfu.option[cid].ontouch
|
|
1553
|
-
if(ontouch == false) return;
|
|
1554
|
-
if(cfu.option[cid].enableScroll === true && e.touches.length == 0){
|
|
1555
|
-
cfu.instance[cid].scrollEnd(e);
|
|
1556
|
-
}
|
|
1557
|
-
that[cid].callMethod('emitMsg',{name:"getTouchEnd",params:{type:"touchEnd",event:e.changedTouches[0],id:cid, opts: cfu.instance[cid].opts}})
|
|
1558
|
-
},
|
|
1559
|
-
mouseDown(e) {
|
|
1560
|
-
let cid = this.rid
|
|
1561
|
-
let onmouse = cfu.option[cid].onmouse
|
|
1562
|
-
if(onmouse == false) return;
|
|
1563
|
-
let rchartdom = document.getElementById('UC'+cid).getBoundingClientRect()
|
|
1564
|
-
let tmpe = {}
|
|
1565
|
-
tmpe = { x: e.clientX - rchartdom.left, y:e.clientY - rchartdom.top + rootdom.top}
|
|
1566
|
-
e.changedTouches = [];
|
|
1567
|
-
e.changedTouches.unshift(tmpe)
|
|
1568
|
-
cfu.instance[cid].scrollStart(e)
|
|
1569
|
-
cfu.option[cid].mousedown=true;
|
|
1570
|
-
that[cid].callMethod('emitMsg',{name:"getTouchStart",params:{type:"mouseDown",event:tmpe,id:cid, opts: cfu.instance[cid].opts}})
|
|
1571
|
-
},
|
|
1572
|
-
mouseMove(e) {
|
|
1573
|
-
let cid = this.rid
|
|
1574
|
-
let onmouse = cfu.option[cid].onmouse
|
|
1575
|
-
let tooltipShow = cfu.option[cid].tooltipShow
|
|
1576
|
-
if(onmouse == false) return;
|
|
1577
|
-
let rchartdom = document.getElementById('UC'+cid).getBoundingClientRect()
|
|
1578
|
-
let tmpe = {}
|
|
1579
|
-
tmpe = { x: e.clientX - rchartdom.left, y:e.clientY - rchartdom.top + rootdom.top}
|
|
1580
|
-
e.changedTouches = [];
|
|
1581
|
-
e.changedTouches.unshift(tmpe)
|
|
1582
|
-
if(cfu.option[cid].mousedown){
|
|
1583
|
-
cfu.instance[cid].scroll(e)
|
|
1584
|
-
that[cid].callMethod('emitMsg',{name:"getTouchMove",params:{type:"mouseMove",event:tmpe,id:cid, opts: cfu.instance[cid].opts}})
|
|
1585
|
-
}else if(cfu.instance[cid]){
|
|
1586
|
-
if(tooltipShow==true){
|
|
1587
|
-
this.showTooltip(e,cid)
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
},
|
|
1591
|
-
mouseUp(e) {
|
|
1592
|
-
let cid = this.rid
|
|
1593
|
-
let onmouse = cfu.option[cid].onmouse
|
|
1594
|
-
if(onmouse == false) return;
|
|
1595
|
-
let rchartdom = document.getElementById('UC'+cid).getBoundingClientRect()
|
|
1596
|
-
let tmpe = {}
|
|
1597
|
-
tmpe = { x: e.clientX - rchartdom.left, y:e.clientY - rchartdom.top + rootdom.top}
|
|
1598
|
-
e.changedTouches = [];
|
|
1599
|
-
e.changedTouches.unshift(tmpe)
|
|
1600
|
-
cfu.instance[cid].scrollEnd(e)
|
|
1601
|
-
cfu.option[cid].mousedown=false;
|
|
1602
|
-
that[cid].callMethod('emitMsg',{name:"getTouchEnd",params:{type:"mouseUp",event:tmpe,id:cid, opts: cfu.instance[cid].opts}})
|
|
1603
|
-
},
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
</script>
|
|
1607
|
-
<!-- #endif -->
|
|
1608
|
-
|
|
1609
|
-
<style scoped>
|
|
1610
|
-
.chartsview {
|
|
1611
|
-
width: 100%;
|
|
1612
|
-
height: 100%;
|
|
1613
|
-
display: flex;
|
|
1614
|
-
flex: 1;
|
|
1615
|
-
justify-content: center;
|
|
1616
|
-
align-items: center;
|
|
1617
|
-
}
|
|
1618
|
-
</style>
|