瀏覽代碼

热力图

duwendi 1 年之前
父節點
當前提交
e92864eef3
共有 3 個文件被更改,包括 281 次插入0 次删除
  1. 274 0
      src/pages/index/components/hot_map.vue
  2. 2 0
      src/pages/index/layouts/indexLayout.vue
  3. 5 0
      src/router/index.js

+ 274 - 0
src/pages/index/components/hot_map.vue

@@ -0,0 +1,274 @@
1
+<template>
2
+  <div class="middle-map">
3
+    <div class="top">
4
+      <div class="title">停车热度时空分布</div>
5
+    </div>
6
+    <div class="bottom" id="map"></div>
7
+  </div>
8
+</template>
9
+
10
+<script>
11
+import * as echarts from 'echarts'
12
+import * as geoJson from '../../../util/411100.json'
13
+
14
+export default {
15
+  data() {
16
+    return {
17
+      dqIndex: -1,
18
+      timer: null,
19
+      option: {
20
+        visualMap: {
21
+          show: true,
22
+          type: "continuous",
23
+          left: "0%",
24
+          bottom: "0%",
25
+          calculable: false,
26
+          textStyle: {
27
+            color: "white",
28
+          },
29
+          text: ["(%)"],
30
+          min: 0,
31
+          max: 100,
32
+          inRange: {
33
+            color: ["#4FC9FB","#36ADFC","#1788D1","#0E6BAE","#1871A2","#0D4D7D"],
34
+          },
35
+        },
36
+        geo: {
37
+          map: "luohe",
38
+          // aspectScale: 1,
39
+          roam: false,
40
+          itemStyle: {
41
+            normal: {
42
+              borderColor: "#2ab8ff",
43
+              borderWidth: 2.5,
44
+              areaColor: "#12235c",
45
+            },
46
+            emphasis: {
47
+              areaColor: "#2AB8FF",
48
+              shadowColor: "rgba(42,184,255, 0.7)",
49
+              shadowOffsetY: 5,
50
+              shadowOffsetX: 5,
51
+              shadowBlur: 5,
52
+            },
53
+          },
54
+        },
55
+        tooltip: {
56
+          confine: true,
57
+          formatter: this.mapTooltip,
58
+          position: "inside",
59
+          backgroundColor: "transparent",
60
+        },
61
+        series: [
62
+          {
63
+            type: "map",
64
+            // roam: true,
65
+            label: {
66
+              normal: {
67
+                textStyle: {
68
+                  color: "#fff",
69
+                },
70
+              },
71
+              emphasis: {
72
+                show: false,
73
+                textStyle: {
74
+                  color: "#fff",
75
+                },
76
+              },
77
+            },
78
+            itemStyle: {
79
+              normal: {
80
+                borderColor: "#76bef5",
81
+                borderWidth: 1.5,
82
+                areaColor: "#4282de",
83
+              },
84
+              emphasis: {
85
+                areaColor: "#ff4800",
86
+                borderWidth: 0,
87
+                color: "green",
88
+              },
89
+            },
90
+            roam: false,
91
+            map: "luohe", //使用
92
+            data: [],
93
+          },
94
+        ],
95
+      },
96
+      curData: {},
97
+      dataSource: null,
98
+      totalAll: '0',
99
+    };
100
+  },
101
+  watch: {
102
+    dqIndex: function (newV) {
103
+      this.queryDq(newV);
104
+    },
105
+  },
106
+  methods: {
107
+    setIntervalMap(chart) {
108
+      this.timer = setInterval(() => {
109
+        chart.dispatchAction({
110
+          type: "showTip",
111
+          seriesIndex: 0,
112
+          dataIndex: this.dqIndex + 1,
113
+        });
114
+        this.dqIndex++;
115
+        if (this.dqIndex > 4) {
116
+          this.dqIndex = -1;
117
+        }
118
+      }, 3000);
119
+    },
120
+    mapTooltip(data) {
121
+      return `<div class="map-tooltip">
122
+        <div class="map-tooltip-name">${data.name}:<span class="map-tooltip-value">${data.value}%</span></div>
123
+      </div>`;
124
+    },
125
+  },
126
+  mounted() {
127
+    let arr = []
128
+    let dataSoure = {
129
+      '411102': {quyuName: '源汇区', zb: 40},
130
+      '411103': {quyuName: '郾城区', zb: 60},
131
+      '411104': {quyuName: '召陵区', zb: 40},
132
+      '411121': {quyuName: '舞阳县', zb: 50},
133
+      '411122': {quyuName: '临颍县', zb: 30}}
134
+    for (const key in dataSoure) {
135
+      if (key !== '411100') {
136
+        arr.push({
137
+          name: dataSoure[key].quyuName,
138
+          value: Number(dataSoure[key].zb),
139
+        });
140
+      }
141
+    }
142
+    let chart = echarts.init(document.getElementById("map"));
143
+    echarts.registerMap("luohe", geoJson);
144
+    this.option.series[0].data = arr;
145
+    chart.setOption(this.option);
146
+    this.dqIndex = -1;
147
+    this.setIntervalMap(chart);
148
+    //鼠标移入静止播放
149
+    chart.on("mouseover", (e) => {
150
+      clearInterval(this.timer);
151
+      chart.dispatchAction({
152
+        type: "showTip",
153
+        seriesIndex: 0,
154
+        dataIndex: e.dataIndex,
155
+      });
156
+    });
157
+    chart.on("mouseout", (e) => {
158
+      clearInterval(this.timer);
159
+      //鼠标移出后先把上次的高亮取消
160
+      chart.dispatchAction({
161
+        type: "downplay",
162
+        seriesIndex: 0,
163
+        dataIndex: e.dataIndex,
164
+      });
165
+      this.setIntervalMap(chart);
166
+    });
167
+  },
168
+};
169
+</script>
170
+
171
+<style lang="less" scoped>
172
+.middle-map {
173
+  width: 100%;
174
+  height: 100%;
175
+  .top {
176
+    height: 10%;
177
+    // padding: 50px 50px 0 50px;
178
+    display: flex;
179
+    flex-direction: column;
180
+    justify-content: space-between;
181
+    font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
182
+    .total-detail {
183
+      display: flex;
184
+      margin-top: 10px;
185
+      align-items: center;
186
+      justify-content: center;
187
+      .total-value {
188
+        font-size: 41px;
189
+      }
190
+      .total-unit {
191
+        margin-left: 20px;
192
+        font-size: 20px;
193
+      }
194
+    }
195
+    .title {
196
+      font-weight: 650;
197
+      font-style: normal;
198
+      color: #ffffff;
199
+      font-size: 18px;
200
+    }
201
+    .dq {
202
+      font-weight: 650;
203
+      color: #ffcc00;
204
+      font-size: 24px;
205
+      text-align: center;
206
+    }
207
+    .num-container {
208
+      height: 180px;
209
+      margin-top: 20px;
210
+      display: flex;
211
+      justify-content: space-between;
212
+      width: 100%;
213
+      padding: 0 20px;
214
+      .num-item {
215
+        display: flex;
216
+        flex-direction: column;
217
+        justify-content: space-around;
218
+        // width: 28%;
219
+        .label-box {
220
+          display: flex;
221
+          align-items: center;
222
+          // justify-content: space-between;
223
+          .label {
224
+            font-weight: 650;
225
+            color: #ffcc00;
226
+            font-size: 28px;
227
+          }
228
+          .rate {
229
+            margin-left: 30px;
230
+            font-weight: 650;
231
+            color: #ffcc00;
232
+            font-size: 18px;
233
+          }
234
+        }
235
+        .num-box {
236
+          display: flex;
237
+          justify-content: space-between;
238
+          justify-content: left;
239
+          font-family: "Arial-BoldMT", "Arial Bold", "Arial";
240
+          font-weight: 700;
241
+          .money {
242
+            color: #fff;
243
+            font-size: 22px;
244
+            .num {
245
+              color: #ffcc00;
246
+            }
247
+          }
248
+          .rate {
249
+            color: #008000;
250
+            font-size: 32px;
251
+          }
252
+        }
253
+      }
254
+    }
255
+  }
256
+  .bottom {
257
+    height: 90%;
258
+    width: 100%;
259
+  }
260
+  /deep/.map-tooltip {
261
+    font-size: 18px;
262
+    padding: 10px 20px;
263
+    background: url("../../../../static/img/u231.png");
264
+    background-size: 100% 100%;
265
+    .map-tooltip-name {
266
+      color: #00e4ff;
267
+    }
268
+    .map-tooltip-value {
269
+      color: white;
270
+      margin-left: 20px;
271
+    }
272
+  }
273
+}
274
+</style>

+ 2 - 0
src/pages/index/layouts/indexLayout.vue

@@ -38,6 +38,8 @@ export default {
38 38
       menu: [
39 39
         {name: 'demo1', url: '/demo1'},
40 40
         {name: 'demo2', url: '/demo2'},
41
+        {name: 'bmap', url: '/bmap'},
42
+        {name: 'hot_map', url: '/hot_map'},
41 43
         {name: '静态资源', url: '/static_resource'},
42 44
         {name: '记录查询', url: '/record_query'},
43 45
         {name: '停车运行监管', url: '/park_monitor'},

+ 5 - 0
src/router/index.js

@@ -25,6 +25,11 @@ export default new Router({
25 25
           path: "/demo2",
26 26
           component: () => import("../pages/index/components/demo2.vue")
27 27
         },
28
+        {
29
+          name: "hot_map",
30
+          path: "/hot_map",
31
+          component: () => import("../pages/index/components/hot_map.vue")
32
+        },
28 33
         {
29 34
           name: "static_resource",
30 35
           path: "/static_resource",