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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
| <template>
| <div ref="ball" :style="{width: size + 'px', height: size + 'px', marginLeft: '10px'}"></div>
| </template>
|
| <script>
| import echarts from "echarts";
| import echartsLiquidfill from "echarts-liquidfill";
|
| export default {
| name: "EchartsLiquidFill",
| props: {
| title: {
| type: String,
| defalut: ""
| },
| value: {
| type: Number,
| defalut: 0
| },
| size: {
| type: Number,
| defalut: 100
| }
| },
| computed: {
| fillColor() {
| if (this.PollData.Thresholds.length > 0) {
| for (let i = 0; i < this.PollData.Thresholds.length; i++) {
| if (this.value <= this.PollData.Thresholds[i].Value) {
| return this.PollData.Thresholds[i].Color;
| }
| }
| }
|
| if (this.value <= 60) {
| return "#13ce66"
| } else if (this.value > 60 && this.value <= 80) {
| return "#FF9C4A"
| } else if (this.value > 80 && this.value <= 95) {
| return "#f53d3d"
| } else {
| return "#5d0000"
| }
| }
| },
| mounted() {
| this.initChart()
| },
| watch: {
| value: function (newVal, oldVal) {
| if (newVal !== oldVal) {
| this.initChart()
| }
| }
| },
| methods: {
| initChart() {
| let options = {
| title: {
| // 标题
| text: this.title,
| textStyle: {
| // 标题的样式
| color: "#222", // 字体颜色
| fontFamily: "Microsoft YaHei", // 字体
| fontSize: 14,
| fontWeight: "800",
| align: "center", // 文字的水平方式
| baseline: "middle",
| position: "inside",
| verticalAlign: "middle" // 文字的垂直方式
| },
| left: "center", // 定位
| top: "14%"
| },
|
| grid: {
| left: 50,
| },
| series: [
| {
| type: "liquidFill",
| radius: "95%",
| waveAnimation: true,
| data: [
| {
| value: this.value / 100,
| direction: "left",
| itemStyle: {
| normal: {
| color: this.fillColor
| }
| }
| }
| ],
| outline: {
| // show: true , //是否显示轮廓 布尔值
| borderDistance: 1, // 外部轮廓与图表的距离 数字
| itemStyle: {
| borderColor: this.fillColor, // 边框的颜色
| borderWidth: 3, // 边框的宽度
| shadowBlur: 1, //外部轮廓的阴影范围 一旦设置了内外都有阴影
| shadowColor: '#fff' //外部轮廓的阴影颜色
| }
| },
| itemStyle: {
| opacity: 0.9, // 波浪的透明度
| shadowBlur: 0 // 波浪的阴影范围
| },
| backgroundStyle: {
| color: "#fff" // 图表的背景颜色
| },
| label: {
| // 数据展示样式
| show: true,
| color: "#000",
| insideColor: "#fff",
| fontSize: 14,
| fontWeight: 400,
| align: "center",
| baseline: "middle",
| position: "inside",
| normal: {
| formatter: (this.value).toFixed(2) + '%',
| textStyle: {
| fontSize: 14,
| fontWeight: 400,
| color: "#000",
| }
| }
| }
|
| }
| ]
| }
| let chart = echarts.init(this.$refs.ball);
| chart.setOption(options);
| }
| }
| };
| </script>
|
|