|
@@ -1,222 +0,0 @@
|
1
|
|
-<template>
|
2
|
|
- <div class="chart-box">
|
3
|
|
- <div :id="id" class="chart map-chart" />
|
4
|
|
- <!-- <div v-if="hasTech" class="tech-zone" /> -->
|
5
|
|
- </div>
|
6
|
|
-</template>
|
7
|
|
-
|
8
|
|
-<script>
|
9
|
|
-import * as echarts from 'echarts'
|
10
|
|
-import { luoheJson } from "@/util/luoheJson";
|
11
|
|
-export default {
|
12
|
|
- props: {
|
13
|
|
- id: { type: String, required: true },
|
14
|
|
- hasTech: { type: Boolean, default: true },
|
15
|
|
- tooltip: { type: Function },
|
16
|
|
- callback: { type: Function },
|
17
|
|
- labelFormat: { type: Function },
|
18
|
|
- mapData: { type: Object },
|
19
|
|
- mouseOverHandler: { type: Function },
|
20
|
|
- mouseOutHandler: { type: Function },
|
21
|
|
- showVisualMap: { type: Boolean, default: false },
|
22
|
|
- unit: { type: String, default: ''} // visiualMap的单位
|
23
|
|
- },
|
24
|
|
- data() {
|
25
|
|
- return {
|
26
|
|
- option: {
|
27
|
|
- color: ["#27FFFE"],
|
28
|
|
- visualMap: {
|
29
|
|
- show: this.showVisualMap,
|
30
|
|
- type:'continuous',
|
31
|
|
- left: '0%',
|
32
|
|
- bottom: '0%',
|
33
|
|
- calculable: false,
|
34
|
|
- textStyle: {
|
35
|
|
- color: "white",
|
36
|
|
- },
|
37
|
|
- min: 0,
|
38
|
|
- inRange: {
|
39
|
|
- color: ["#27FFFE", "#38D0FF", "#0D6FC4", "#0102FF"],
|
40
|
|
- },
|
41
|
|
- },
|
42
|
|
- geo: [
|
43
|
|
- {
|
44
|
|
- map: "qinghai",
|
45
|
|
- itemStyle: {
|
46
|
|
- shadowColor: "rgba(56,105,177,1)",
|
47
|
|
- shadowOffsetY: 12,
|
48
|
|
- shadowBlur: 1,
|
49
|
|
- },
|
50
|
|
- regions: [{
|
51
|
|
- name: '西宁经济技术开发区',
|
52
|
|
- itemStyle: {
|
53
|
|
- shadowOffsetY: 0
|
54
|
|
- }
|
55
|
|
- }],
|
56
|
|
- zoom: 1.2,
|
57
|
|
- },
|
58
|
|
- {
|
59
|
|
- map: "qinghai",
|
60
|
|
- itemStyle: {
|
61
|
|
- shadowColor: "rgba(35,49,122,0.7)",
|
62
|
|
- shadowOffsetY: 20,
|
63
|
|
- shadowBlur: 1,
|
64
|
|
- },
|
65
|
|
- regions: [{
|
66
|
|
- name: '西宁经济技术开发区',
|
67
|
|
- itemStyle: {
|
68
|
|
- shadowOffsetY: 0
|
69
|
|
- }
|
70
|
|
- }],
|
71
|
|
- zoom: 1.2,
|
72
|
|
- },
|
73
|
|
- ],
|
74
|
|
- tooltip: {
|
75
|
|
- formatter: this.tooltip,
|
76
|
|
- position: "inside",
|
77
|
|
- backgroundColor: "transparent",
|
78
|
|
- },
|
79
|
|
- series: [
|
80
|
|
- {
|
81
|
|
- name: "map",
|
82
|
|
- type: "map",
|
83
|
|
- zoom: 1.2,
|
84
|
|
- mapType: "qinghai",
|
85
|
|
- itemStyle: {
|
86
|
|
- borderColor: "#41BBE9",
|
87
|
|
- borderWidth: 1,
|
88
|
|
- },
|
89
|
|
- emphasis: {
|
90
|
|
- label: false,
|
91
|
|
- itemStyle: {
|
92
|
|
- shadowColor: "rgba(60,212,247,0.7)",
|
93
|
|
- shadowOffsetY: 5,
|
94
|
|
- shadowOffsetX: 5,
|
95
|
|
- shadowBlur: 5,
|
96
|
|
- },
|
97
|
|
- },
|
98
|
|
- data: [],
|
99
|
|
- },
|
100
|
|
- ],
|
101
|
|
- },
|
102
|
|
- };
|
103
|
|
- },
|
104
|
|
- watch: {
|
105
|
|
- mapData: function (newV) {
|
106
|
|
- const option = this.option;
|
107
|
|
- const areas = option.series[0].data;
|
108
|
|
- if (this.labelFormat) {
|
109
|
|
- areas.map((item) => (item.label = this.labelFormat()));
|
110
|
|
- }
|
111
|
|
- if (this.showVisualMap) {
|
112
|
|
- option.visualMap.max = Object.keys(newV).reduce((max, item) => {
|
113
|
|
- if (newV[item] > max) {
|
114
|
|
- return newV[item];
|
115
|
|
- }
|
116
|
|
- return max;
|
117
|
|
- }, 0);
|
118
|
|
- option.visualMap.text = [`${option.visualMap.max}(${this.unit})`, ""];
|
119
|
|
- areas.map((item) => (item.value = newV[item.code]));
|
120
|
|
- }
|
121
|
|
- this.chart.setOption(option);
|
122
|
|
- },
|
123
|
|
- },
|
124
|
|
- mounted() {
|
125
|
|
- const luoheJson = luoheJson;
|
126
|
|
- echarts.registerMap("luohe", luoheJson);
|
127
|
|
- const areas = this.option.series[0].data;
|
128
|
|
- const colors1 = [
|
129
|
|
- "#08335B",
|
130
|
|
- "#17579D",
|
131
|
|
- "#16388E",
|
132
|
|
- "#1890CA",
|
133
|
|
- "#1A5BA7",
|
134
|
|
- "#1986CC",
|
135
|
|
- "#1A89CE",
|
136
|
|
- "#53EFFB",
|
137
|
|
- "#52EBFA",
|
138
|
|
- ];
|
139
|
|
- const colors2 = [
|
140
|
|
- "#073459",
|
141
|
|
- "#0C4271",
|
142
|
|
- "#093D71",
|
143
|
|
- "#1787D1",
|
144
|
|
- "#0C416F",
|
145
|
|
- "#1350AB",
|
146
|
|
- "#17A0CD",
|
147
|
|
- "#45B5E9",
|
148
|
|
- "#47B9EB",
|
149
|
|
- ];
|
150
|
|
- qingHaiJson.features.map((item, idx) => {
|
151
|
|
- const areaColor = {
|
152
|
|
- type: "linear",
|
153
|
|
- x: 0,
|
154
|
|
- y: 0,
|
155
|
|
- x2: 0,
|
156
|
|
- y2: 1,
|
157
|
|
- colorStops: [
|
158
|
|
- {
|
159
|
|
- offset: 0,
|
160
|
|
- color: colors1[idx],
|
161
|
|
- },
|
162
|
|
- {
|
163
|
|
- offset: 1,
|
164
|
|
- color: colors2[idx],
|
165
|
|
- },
|
166
|
|
- ],
|
167
|
|
- };
|
168
|
|
- areas.push({
|
169
|
|
- code: item.properties.adcode,
|
170
|
|
- name: item.properties.name,
|
171
|
|
- itemStyle: {
|
172
|
|
- areaColor: areaColor,
|
173
|
|
- },
|
174
|
|
- emphasis: {
|
175
|
|
- itemStyle: {
|
176
|
|
- areaColor: this.showVisualMap ? "#08335B" : areaColor,
|
177
|
|
- borderColor: "rgba(77,212,247,0.7)",
|
178
|
|
- borderWidth: 5,
|
179
|
|
- },
|
180
|
|
- },
|
181
|
|
- });
|
182
|
|
- });
|
183
|
|
-
|
184
|
|
- var chart = echarts.init(document.getElementById(`${this.id}`));
|
185
|
|
- chart.setOption(this.option);
|
186
|
|
- if (this.mouseOverHandler) {
|
187
|
|
- chart.on("mouseover", "series.map", this.mouseOverHandler);
|
188
|
|
- }
|
189
|
|
- if (this.mouseOutHandler) {
|
190
|
|
- chart.on("mouseout", "series.map", this.mouseOutHandler);
|
191
|
|
- }
|
192
|
|
- this.chart = chart;
|
193
|
|
- if (this.callback) {
|
194
|
|
- this.callback(chart, qingHaiJson.features);
|
195
|
|
- }
|
196
|
|
- },
|
197
|
|
-};
|
198
|
|
-</script>
|
199
|
|
-
|
200
|
|
-<style lang="less" scoped>
|
201
|
|
-.chart-box {
|
202
|
|
- position: relative;
|
203
|
|
-}
|
204
|
|
-.chart {
|
205
|
|
- width: 100%;
|
206
|
|
- height: 100%;
|
207
|
|
-}
|
208
|
|
-.map-chart {
|
209
|
|
- z-index: 9;
|
210
|
|
-}
|
211
|
|
-.tech-zone {
|
212
|
|
- position: absolute;
|
213
|
|
- background: #161963;
|
214
|
|
- border: 2px dashed #4CD2F2;
|
215
|
|
- z-index: 0;
|
216
|
|
-}
|
217
|
|
-.map-tooltip {
|
218
|
|
- padding: 10px 20px;
|
219
|
|
- background: url("../../static/img/u231.png");
|
220
|
|
- background-size: 100% 100%;
|
221
|
|
-}
|
222
|
|
-</style>
|