pieWxEchart.ts
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// components/pieWxEchart/pieWxEchart.ts
import * as echarts from '../../ec-canvas/echarts';
function initChart(canvas: any, width: any, height: any, dpr: any) {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(chart);
var option = {
backgroundColor: "#ffffff",
tooltip: {
show: true,
trigger: 'item'
},
color: ['#46B3FD', '#FFC459', '#14C9C9'],
series: [{
type: 'pie',
avoidLabelOverlap: false,
center: ['50%', '50%'],
radius: ['40%', '60%'],
labelLine: {
length: 20,
length2: 120,
// maxSurfaceAngle: 120
},
label: {
alignTo: 'edge',
formatter: '{name|{b}} {name|{d}}%\n{time|{c}}',
// formatter: function (params:any) {
// console.log(params,'----formatter---')
// },
minMargin: 5,
edgeDistance: 10,
lineHeight: 16,
rich: {
name: {
fontSize: 12,
fontFamily: "PingFangSC-Regular",
color: "#666671"
},
time: {
fontSize: 12,
color: '#323241',
}
}
},
data: [
{ value: 400, name: '离线率' },
{ value: 400, name: '未配置' },
{ value: 600, name: '在线率' },
]
}]
};
chart.setOption(option);
return chart;
}
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
ec: {
onInit: initChart
}
}
/**
* 组件的方法列表
*/
})