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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
  | <!-- 
 |   * @Author: daidai 
 |   * @Date: 2022-03-01 14:13:04 
 |   * @LastEditors: Please set LastEditors 
 |   * @LastEditTime: 2022-09-27 15:04:49 
 |   * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-top.vue 
 |  --> 
 |  <template> 
 |    <Echart 
 |      id="rightTop" 
 |      :options="option" 
 |      class="right_top_inner" 
 |      v-if="pageflag" 
 |      ref="charts" 
 |    /> 
 |    <Reacquire v-else @onclick="getData" style="line-height: 200px"> 
 |      重新获取 
 |    </Reacquire> 
 |  </template> 
 |    
 |  <script> 
 |  import { currentGET } from "api/modules"; 
 |  import {graphic} from "echarts" 
 |  export default { 
 |    data() { 
 |      return { 
 |        option: {}, 
 |        pageflag: false, 
 |        timer: null, 
 |      }; 
 |    }, 
 |    created() { 
 |      
 |    }, 
 |    
 |    mounted() { 
 |       this.getData(); 
 |    }, 
 |    beforeDestroy() { 
 |      this.clearData(); 
 |    }, 
 |    methods: { 
 |      clearData() { 
 |        if (this.timer) { 
 |          clearInterval(this.timer); 
 |          this.timer = null; 
 |        } 
 |      }, 
 |      getData() { 
 |        this.pageflag = true; 
 |        // this.pageflag =false 
 |        currentGET("big4").then((res) => { 
 |          if (!this.timer) { 
 |            console.log("报警次数", res); 
 |          } 
 |          if (res.success) { 
 |            this.countUserNumData = res.data; 
 |            this.$nextTick(() => { 
 |              this.init(res.data.dateList, res.data.numList, res.data.numList2), 
 |                this.switper(); 
 |            }); 
 |          } else { 
 |            this.pageflag = false; 
 |            this.$Message({ 
 |              text: res.msg, 
 |              type: "warning", 
 |            }); 
 |          } 
 |        }); 
 |      }, 
 |      //轮询 
 |      switper() { 
 |        if (this.timer) { 
 |          return; 
 |        } 
 |        let looper = (a) => { 
 |          this.getData(); 
 |        }; 
 |        this.timer = setInterval( 
 |          looper, 
 |          this.$store.state.setting.echartsAutoTime 
 |        ); 
 |        let myChart = this.$refs.charts.chart; 
 |        myChart.on("mouseover", (params) => { 
 |          this.clearData(); 
 |        }); 
 |        myChart.on("mouseout", (params) => { 
 |          this.timer = setInterval( 
 |            looper, 
 |            this.$store.state.setting.echartsAutoTime 
 |          ); 
 |        }); 
 |      }, 
 |      init(xData, yData, yData2) { 
 |        this.option = { 
 |          xAxis: { 
 |            type: "category", 
 |            data: xData, 
 |            boundaryGap: false, // 不留白,从原点开始 
 |            splitLine: { 
 |              show: true, 
 |              lineStyle: { 
 |                color: "rgba(31,99,163,.2)", 
 |              }, 
 |            }, 
 |            axisLine: { 
 |              // show:false, 
 |              lineStyle: { 
 |                color: "rgba(31,99,163,.1)", 
 |              }, 
 |            }, 
 |            axisLabel: { 
 |              color: "#7EB7FD", 
 |              fontWeight: "500", 
 |            }, 
 |          }, 
 |          yAxis: { 
 |            type: "value", 
 |            splitLine: { 
 |              show: true, 
 |              lineStyle: { 
 |                color: "rgba(31,99,163,.2)", 
 |              }, 
 |            }, 
 |            axisLine: { 
 |              lineStyle: { 
 |                color: "rgba(31,99,163,.1)", 
 |              }, 
 |            }, 
 |            axisLabel: { 
 |              color: "#7EB7FD", 
 |              fontWeight: "500", 
 |            }, 
 |          }, 
 |          tooltip: { 
 |            trigger: "axis", 
 |            backgroundColor: "rgba(0,0,0,.6)", 
 |            borderColor: "rgba(147, 235, 248, .8)", 
 |            textStyle: { 
 |              color: "#FFF", 
 |            }, 
 |          }, 
 |          grid: { 
 |            //布局 
 |            show: true, 
 |            left: "10px", 
 |            right: "30px", 
 |            bottom: "10px", 
 |            top: "28px", 
 |            containLabel: true, 
 |            borderColor: "#1F63A3", 
 |          }, 
 |          series: [ 
 |            { 
 |              data: yData, 
 |              type: "line", 
 |              smooth: true, 
 |              symbol: "none", //去除点 
 |              name: "报警1次数", 
 |              color: "rgba(252,144,16,.7)", 
 |              areaStyle: { 
 |                  //右,下,左,上 
 |                  color: new graphic.LinearGradient( 
 |                    0, 
 |                    0, 
 |                    0, 
 |                    1, 
 |                    [ 
 |                      { 
 |                        offset: 0, 
 |                        color: "rgba(252,144,16,.7)", 
 |                      }, 
 |                      { 
 |                        offset: 1, 
 |                        color: "rgba(252,144,16,.0)", 
 |                      }, 
 |                    ], 
 |                    false 
 |                  ), 
 |              }, 
 |              markPoint: { 
 |                data: [ 
 |                  { 
 |                    name: "最大值", 
 |                    type: "max", 
 |                    valueDim: "y", 
 |                    symbol: "rect", 
 |                    symbolSize: [60, 26], 
 |                    symbolOffset: [0, -20], 
 |                    itemStyle: { 
 |                      color: "rgba(0,0,0,0)", 
 |                    }, 
 |                    label: { 
 |                      color: "#FC9010", 
 |                      backgroundColor: "rgba(252,144,16,0.1)", 
 |                      borderRadius: 6, 
 |                      padding: [7, 14], 
 |                      borderWidth: 0.5, 
 |                      borderColor: "rgba(252,144,16,.5)", 
 |                      formatter: "报警1:{c}", 
 |                    }, 
 |                  }, 
 |                  { 
 |                    name: "最大值", 
 |                    type: "max", 
 |                    valueDim: "y", 
 |                    symbol: "circle", 
 |                    symbolSize: 6, 
 |                    itemStyle: { 
 |                      color: "#FC9010", 
 |                      shadowColor: "#FC9010", 
 |                      shadowBlur: 8, 
 |                    }, 
 |                    label: { 
 |                      formatter: "", 
 |                    }, 
 |                  }, 
 |                ], 
 |              }, 
 |            }, 
 |            { 
 |              data: yData2, 
 |              type: "line", 
 |              smooth: true, 
 |              symbol: "none", //去除点 
 |              name: "报警2次数", 
 |              color: "rgba(9,202,243,.7)", 
 |              areaStyle: { 
 |                  //右,下,左,上 
 |                  color: new graphic.LinearGradient( 
 |                    0, 
 |                    0, 
 |                    0, 
 |                    1, 
 |                    [ 
 |                      { 
 |                        offset: 0, 
 |                        color: "rgba(9,202,243,.7)", 
 |                      }, 
 |                      { 
 |                        offset: 1, 
 |                        color: "rgba(9,202,243,.0)", 
 |                      }, 
 |                    ], 
 |                    false 
 |                  ), 
 |              }, 
 |              markPoint: { 
 |                data: [ 
 |                  { 
 |                    name: "最大值", 
 |                    type: "max", 
 |                    valueDim: "y", 
 |                    symbol: "rect", 
 |                    symbolSize: [60, 26], 
 |                    symbolOffset: [0, -20], 
 |                    itemStyle: { 
 |                      color: "rgba(0,0,0,0)", 
 |                    }, 
 |                    label: { 
 |                      color: "#09CAF3", 
 |                      backgroundColor: "rgba(9,202,243,0.1)", 
 |    
 |                      borderRadius: 6, 
 |                      borderColor: "rgba(9,202,243,.5)", 
 |                      padding: [7, 14], 
 |                      formatter: "报警2:{c}", 
 |                      borderWidth: 0.5, 
 |                    }, 
 |                  }, 
 |                  { 
 |                    name: "最大值", 
 |                    type: "max", 
 |                    valueDim: "y", 
 |                    symbol: "circle", 
 |                    symbolSize: 6, 
 |                    itemStyle: { 
 |                      color: "#09CAF3", 
 |                      shadowColor: "#09CAF3", 
 |                      shadowBlur: 8, 
 |                    }, 
 |                    label: { 
 |                      formatter: "", 
 |                    }, 
 |                  }, 
 |                ], 
 |              }, 
 |            }, 
 |          ], 
 |        }; 
 |      }, 
 |    }, 
 |  }; 
 |  </script> 
 |  <style lang='scss' scoped> 
 |  .right_top_inner { 
 |    margin-top: -8px; 
 |  } 
 |  </style> 
 |  
  |