Skip to content

Commit e2232a9

Browse files
committed
调试中国散点图
1 parent 70a3108 commit e2232a9

File tree

4 files changed

+92
-50
lines changed

4 files changed

+92
-50
lines changed

src/components/MainPage/BlogIndex.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
});
338338
});
339339
}
340-
}
340+
},
341341
}
342342
</script>
343343

src/components/MainPage/analytics.vue

Lines changed: 89 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@
2525
<div class="block">
2626
<div class="line-chart" id="line-chart"></div>
2727
</div>
28+
<div class="block">
29+
<div class="map-chart" id="map"></div>
30+
</div>
2831
<div class="block">
2932
<!-- <div class="block-name">分日报表</div>-->
3033
<div class="list">
3134
<div class="list-head">
3235
<div class="list-td">访问时间</div>
3336
<div class="list-td align">访问位置</div>
34-
<div class="list-td align">访问来源</div>
37+
<!-- <div class="list-td align">访问来源</div>-->
3538
<div class="list-td align">访问浏览器</div>
3639
</div>
3740
<div :class="i%2==0 ? 'list-tr single' : 'list-tr'" v-for="(item,i) in visitListData">
3841
<div class="list-td">{{ item.time }}</div>
3942
<div class="list-td align">{{ item.location }}</div>
40-
<div class="list-td align">{{ item.fromUrl }}</div>
43+
<!-- <div class="list-td align">{{ item.fromUrl }}</div>-->
4144
<div class="list-td align">{{ item.browser }}</div>
4245
</div>
4346
<div class="list-item"></div>
@@ -104,6 +107,7 @@
104107

105108
<script>
106109
import Store from "../../store";
110+
import china from '../../static/map/china.json'
107111
108112
export default {
109113
name: "analytics",
@@ -112,7 +116,8 @@ export default {
112116
todayVisit: 0,
113117
yesterdayVisit: 0,
114118
allVisitNum: 0,
115-
weekVisit:0,
119+
weekVisit: 0,
120+
// 折线图数据
116121
lineChartOption: {
117122
// title: {text: '数据趋势'},
118123
tooltip: {
@@ -131,53 +136,23 @@ export default {
131136
bottom: '20px' // 图表距离容器下方边距
132137
}
133138
},
134-
mapChartOption: {},
135139
visitListData: [],
136-
mapOption : {
140+
// 地图参数
141+
mapOption: {
137142
tooltip: {
138143
show: false
139144
},
140145
geo: {
141146
map: "china",
142-
roam: false,// 一定要关闭拖拽
143-
zoom: 1.23,
147+
roam: true,// 一定要关闭拖拽
144148
center: [105, 36], // 调整地图位置
145-
label: {
146-
normal: {
147-
show: false, //关闭省份名展示
148-
fontSize: "10",
149-
color: "rgba(0,0,0,0.7)"
150-
},
151-
emphasis: {
152-
show: false
153-
}
154-
},
155-
itemStyle: {
156-
normal: {
157-
areaColor: "#0d0059",
158-
borderColor: "#389dff",
159-
borderWidth: 1, //设置外层边框
160-
shadowBlur: 5,
161-
shadowOffsetY: 8,
162-
shadowOffsetX: 0,
163-
shadowColor: "#01012a"
164-
},
165-
emphasis: {
166-
areaColor: "#184cff",
167-
shadowOffsetX: 0,
168-
shadowOffsetY: 0,
169-
shadowBlur: 5,
170-
borderWidth: 0,
171-
shadowColor: "rgba(0, 0, 0, 0.5)"
172-
}
173-
}
174149
},
175150
series: [
176151
{
177152
type: "map",
178153
map: "china",
179154
roam: false,
180-
zoom: 1.23,
155+
zoom: 1.7,
181156
center: [105, 36],
182157
// geoIndex: 1,
183158
// aspectScale: 0.75, //长宽比
@@ -195,19 +170,81 @@ export default {
195170
},
196171
itemStyle: {
197172
normal: {
198-
areaColor: "#0d0059",
173+
areaColor: "white",
199174
borderColor: "#389dff",
200175
borderWidth: 0.5
201176
},
202177
emphasis: {
203-
areaColor: "#17008d",
178+
areaColor: "#cfcddb",
204179
shadowOffsetX: 0,
205180
shadowOffsetY: 0,
206181
shadowBlur: 5,
207-
borderWidth: 0,
208-
shadowColor: "rgba(0, 0, 0, 0.5)"
182+
borderWidth: 0
183+
}
184+
}},
185+
{
186+
type: 'effectScatter',
187+
coordinateSystem: 'geo',
188+
data: [
189+
{
190+
"name": "大庆",
191+
"value": [
192+
125.03,
193+
46.58,
194+
279
195+
]
196+
},
197+
{
198+
"name": "武汉",
199+
"value": [
200+
114.31,
201+
30.52,
202+
273
203+
]
204+
},
205+
{
206+
"name": "合肥",
207+
"value": [
208+
117.27,
209+
31.86,
210+
229
211+
]
212+
},
213+
{
214+
"name": "菏泽",
215+
"value": [
216+
115.480656,
217+
35.23375,
218+
194
219+
]
220+
},
221+
{
222+
"name": "廊坊",
223+
"value": [
224+
116.7,
225+
39.53,
226+
193
227+
]
228+
},
229+
{
230+
"name": "衢州",
231+
"value": [
232+
118.88,
233+
28.97,
234+
177
235+
]
209236
}
210-
}
237+
],
238+
symbolSize: 5,
239+
label: {
240+
formatter: '{b}',
241+
position: 'right',
242+
show: true
243+
},
244+
itemStyle: {
245+
shadowBlur: 10,
246+
shadowColor: '#333'
247+
},
211248
}
212249
]
213250
}
@@ -253,16 +290,17 @@ export default {
253290
data.forEach(function (item) {
254291
if (JSON.stringify(item.location) == '[]') item.location = '银河系';
255292
if (!item.browser) item.browser = "secret";
256-
item.ip = (item.ip).replace('::ffff:', '');
293+
if (!item.fromUrl) item.fromUrl = '直接访问';
257294
});
258295
that.visitListData = data;
259296
}
260297
});
261298
},
262299
// 渲染地图
263-
setMap:function (){
264-
let map,that=this;
265-
map = that.$echarts.init(document.getElementById('line-chart'));
300+
setMap: function () {
301+
let map, that = this;
302+
map = that.$echarts.init(document.getElementById('map'));
303+
that.$echarts.registerMap('china', china);
266304
map.setOption(that.mapOption);
267305
}
268306
},
@@ -271,7 +309,7 @@ export default {
271309
272310
this.setLineChart();
273311
this.setVisitList();
274-
// this.setMap();
312+
this.setMap();
275313
}
276314
}
277315
</script>
@@ -311,6 +349,10 @@ export default {
311349
height: 300px;
312350
}
313351
352+
.map-chart{
353+
height: 400px;
354+
}
355+
314356
.list-head {
315357
color: #8590a6;
316358
.myflex(center);

src/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue';
2-
import router from './router';
32
import App from './App.vue';
3+
import router from './router';
44
import './static/css/base.less';
55
import CommonFunction from './util/util';
66
import './static/iconfont/iconfont.css';
@@ -19,7 +19,6 @@ new Vue({
1919
render:function (h) {
2020
return h(App);
2121
},
22-
2322
store,
2423
router:router
2524
}).$mount('#app');

src/static/map/china.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)