独墅湖高教创新区危化品智慧管控平台(新危化品)
马宇豪
2025-04-22 91f2640c8919e7cbe41c8c437e4f7fd60345e062
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
<template>
  <div class="charts-container">
    <div id="preWarning"></div>
  </div>
</template>
<script setup>
import * as echarts from 'echarts';
import {onMounted} from "vue";
import {getCompanyMessage, getDailywarningCount} from "@/api/monitor/screenCharts";
import {ElMessage} from "element-plus";
 
onMounted(()=>{
  getList()
 
})
 
 
const getList = async () => {
  const res = await getDailywarningCount()
  if(res.code == 200){
    if(res.data && Array.isArray(res.data) && res.data.length>0){
      initChart(res.data)
    }else{
      initChart([])
    }
  }else{
    ElMessage.warning(res.message)
  }
}
 
const initChart =(data)=>{
  var chartDom = document.getElementById('preWarning');
  var myChart = echarts.init(chartDom);
  var option;
 
  option = {
    title: [
      {
        text: '近30天预警信息趋势',
        left: '0',
        top: '2%',
        textStyle: {
          fontSize: 12,
          color: 'rgba(255,255,255,.6)',
          fontWeight: 'normal'
        }
      }
    ],
    xAxis: {
      type: 'category',
      data: data.map(i=>i.day) || [],
      axisLabel:{
        color: '#fff'
      },
      axisTick: {
        show: false
      }
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle:{
          color: 'rgba(255,255,255,.1)',
          type: 'dashed'
        }
      },
      axisLabel:{
        color: 'rgba(255,255,255,.6)'
      }
    },
    grid: [
      {
        top: '15%',
        right: '2%',
        bottom: '10%'
      }
    ],
    series: [
      {
        data: data.map(i=>i.count) || [],
        type: 'line',
        label:{
          show: true,
          color: '#fff',
          textBorderColor: 'transparent',
          fontSize: 8
        },
        // showSymbol: false,
        lineStyle:{
          color: '#54d5ff'
        },
        itemStyle:{
          color: '#54d5ff',
        }
      }
    ]
  };
 
  option && myChart.setOption(option);
}
 
</script>
 
<style lang="postcss" scoped>
.charts-container{
  width: 100%;
  height: 100%;
}
 
#preWarning{
  width: 100%;
  height: 100%;
}
</style>