基于廊坊系统为基础,国防科技大学系统演示Demo
surprise
2024-04-28 c310c155e3e91e6b285b3fb3519a3ef7c6690d66
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
<template>
  <div class="visit-count" ref="chart"></div>
</template>
 
<script>
import * as echarts from "echarts"
import { countByMajor } from "@/api/screen.js"
export default {
  data() {
    return {
      option: {},
    }
  },
  mounted() {
    this.initChart()
  },
  methods: {
    async initChart() {
      let data = [
 
      ]
      const res = await countByMajor()
      let xAxis = []
      let yAxis = []
      if (res.code == 200) {
        var obj = res.result;
        data = res.result.map(item => {
          xAxis.push(item.m2)
          yAxis.push(item.sizes)
        })
      }
      let option = {
        grid: {
          // 让图表占满容器
          top: "12%",
          left: "15%",
          right: "10%",
          bottom: "15%",
        },
        tooltip: {
          show: true,
          formatter: function (data) {
            var val = obj.filter(res=>{
              if(data.value == res.sizes){
                return res
              }
            })
            if(val.length>0){
              var num = val[0].m3
              if(num=="平方千米"){
                num= " km²";
              }else  if(num=="平方米"){
                num= " m²";
              }else  if(num=="千米"){
                num= " km";
              }
               return  val[0].m2+":<br/>"+val[0].sizes+ num;
            }else{
              return data;
            }
          },
        },
        xAxis: {
          data: xAxis,
          axisLabel: {
            show: true,
            color: "#ffff",
          
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "rgba(95, 180, 237, 0.32)",
            },
          },
        },
        yAxis: {
          axisLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            color: "#ffff",
          },
          // 分割线
          splitLine: {
            lineStyle: {
              color: "#5d7289",
              width: 1,
              type: "dashed",
            },
          },
        },
        series: [
          {
            // 顶部圆片
            type: "pictorialBar",
            animation: false,
            itemStyle: {
              color: "rgba(115, 240, 252, 1)",
            },
            symbolRepeat: false,
            symbolSize: [15, 8],
            symbolMargin: 1,
            z: 10,
            data: data,
            symbolPosition: "end",
            symbolOffset: [0, -4],
          },
          {
            // 底部圆片
            type: "pictorialBar",
            animation: false,
 
            itemStyle: {
              color: "rgba(50, 96, 225, 0.8)",
            },
            symbolRepeat: false,
            symbolSize: [15, 8],
            symbolMargin: 1,
            z: 10,
            data: data,
            symbolPosition: "start",
            symbolOffset: [0, 3],
          },
          {
            barWidth: 15,
            animation: false,
 
            type: "bar",
            label: {
              show: true,
              position: "top",
              textStyle: {
                color: "#ffff",
              },
            },
            itemStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                { offset: 1, color: "rgba(82, 180, 249, 0.35)" },
                { offset: 0, color: "rgba(82, 180, 249, 1)" },
              ]),
            },
            data: yAxis,
          },
        ],
      }
 
      const chart = echarts.init(this.$refs.chart)
 
      chart.setOption(option)
      window.addEventListener("resize", function () {
        chart.resize()
      })
    },
  },
}
</script>
 
<style lang="less" scoped>
.visit-count {
  width: 100%;
  height: calc(100% - 30px);
}
</style>