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
142
143
144
145
146
| <template>
| <div class="echarts-wrapper">
| <div class="echarts-content" ref="chart"></div>
| <div class="echarts-text-wrapper">
| <div class="color-strip" :style="{'backgroundColor':resColor}"></div>
| <div class="echarts-text">
| 熔丝告警
| </div>
| </div>
| </div>
| </template>
|
| <script>
| import * as echarts from "echarts";
|
| export default {
| name: "AcInput",
| chart: "",
| chartData: "",
| props: {
| acColor: {
| type:String,
| default: "#813a74"
| },
| resColor: {
| type:String,
| default: "#ff649d"
| },
| },
| data() {
| return {}
| },
| methods: {
| setOption(opt) {
| this.$options.chart.setOption(opt);
| },
| setData(value) {
| let acColor = this.acColor;
| let resColor = this.resColor;
| let option = {
| title: {
| text: value+'%',
| x: 'center',
| y: 'center',
| textStyle: {
| color: "#fff",
| fontSize: 40,
| }
| },
| series: [
| {
| name: "",
| type: 'gauge',
| radius: '90%',
| startAngle: 180.5,
| endAngle: -0.5,
| min: 0,
| max: 100,
| title: {
| show: false
| },
| detail: {
| show: false
| },
| axisLine: {
| show: true,
| lineStyle: {
| width: 40,
| color: [
| [
| value / 100, acColor
| ],
| [
| 1, resColor
| ]
| ]
| }
| },
| axisTick: {
| show: false,
| },
| splitLine: {
| show: false,
| },
| axisLabel: {
| show: false
| },
| pointer: {
| show: false,
| },
| itemStyle: {
| normal: {
| color: '#FF0000',
| }
| },
| data: [{
| value: value,
| name: '年售电量情况'
| }]
| }
| ]
| };
|
| // 设置配置项
| this.setOption(option);
| },
| resize() {
| this.setData(this.$options.chartData);
| this.$options.chart.resize();
| }
| },
| mounted() {
| // 基于准备好的dom,初始化echarts实例
| this.$options.chart = echarts.init(this.$refs.chart);
| let value = 10;
| this.setData(value);
|
| window.addEventListener('resize', this.resize);
| },
| destroyed() {
| window.removeEventListener('resize', this.resize);
| }
| }
| </script>
|
| <style scoped>
| .echarts-text-wrapper {
| position: absolute;
| top: 56%;
| left: 22.5%;
| width: 55%;
| text-align: center;
| }
| .color-strip {
| height: 4px;
| }
| .echarts-text {
| display: inline-block;
| margin-top: 8px;
| padding: 8px 32px;
| background-color: #083880;
| border: 1px solid #01b1e0;
| border-radius: 16px;
|
| }
| </style>
|
|