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
<template>
<div id="mapDiv"></div>
</template>
<script>
// import "echarts/map/js/china";
import echarts from 'echarts'
import { chinaJson } from "@/map/china";
echarts.registerMap("china", chinaJson);
export default {
name: "maps",
data() {
return {
dataList: [],
};
},
mounted() {
this.getList();
},
methods: {
getList() {
this.$https({
method: "post",
url: "tBoardStatistic/getBoardProvincePlayTotalList",
authType: this.backToken,
})
.then((res) => {
if (res.status == 200) {
if (res.data.resultCode == 200) {
this.dataList = res.data.data;
} else {
this.dataList = [];
}
} else {
this.dataList = [];
}
this.init();
})
.catch((err) => {
this.$message.error(err.message);
this.init();
});
},
init() {
let option = {
tooltip: {
triggerOn: "click",
formatter: function (e, t, n) {
return 0.5 == e.value
? e.name + ":播放量"
: e.seriesName + "<br />" + e.name + ":" + e.value;
},
},
visualMap: [
{
dimension: 0,
right: 20,
bottom: 20,
itemWidth: 16,
itemHeight: "200px",
orient: "horizontal",
text: ["由高到低", "播放量"],
backgroundColor: "rgba(0,28,66,0.6)",
padding: [15, 10],
textStyle: {
color: "rgba(255,255,255,1)",
},
inRange: {
color: ["#9B1E23", "#E72128", "#FB8D1F", "#FFCF4E"],
},
},
],
geo: {
map: "china",
roam: !1,
scaleLimit: {
min: 1,
max: 2,
},
roam: true, //是否开启平游或缩放
scaleLimit: {
//滚轮缩放的极限控制
min: 1,
max: 2,
},
zoom: 1,
top: 100,
left: "10%",
label: {
normal: {
show: !0,
fontSize: "12",
color: "#fff",
},
},
itemStyle: {
normal: {
borderColor: "rgba(0, 0, 0, 0.2)",
},
emphasis: {
areaColor: "#f2d5ad",
shadowOffsetX: 0,
shadowOffsetY: 0,
borderWidth: 0,
},
},
regions: [
{
name: "南海诸岛",
itemStyle: {
// 隐藏地图
normal: {
opacity: 0, // 为 0 时不绘制该图形
},
},
label: {
show: false, // 隐藏文字
},
},
],
},
series: [
{
name: "播放量",
type: "map",
geoIndex: 0,
data: this.dataList,
},
],
};
let echartsDiv = this.$echarts.init(document.getElementById("mapDiv"));
echartsDiv.setOption(option);
},
},
};
</script>
<style lang="less">
#mapDiv {
width: 100%;
height: 100%;
}
</style>