|
@@ -9,8 +9,9 @@ import _ from 'lodash';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
import echarts from 'echarts/lib/echarts';
|
|
|
import 'echarts/map/js/china.js';
|
|
|
-import 'echarts/map/js/province/jilin.js';
|
|
|
-import jlJson from 'echarts/map/json/province/jilin';
|
|
|
+import './js/mapjs';
|
|
|
+import * as citys from './js/datajs';
|
|
|
+import cJson from 'echarts/map/json/china';
|
|
|
import 'echarts/lib/component/title';
|
|
|
import 'echarts/lib/component/legend';
|
|
|
import 'echarts/lib/component/toolbox';
|
|
@@ -27,15 +28,18 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.init();
|
|
|
+ this.init('china');
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['query']),
|
|
|
- async init() {
|
|
|
+ async init(name) {
|
|
|
+ console.log(cJson);
|
|
|
let res = await this.query();
|
|
|
let city = {};
|
|
|
+ let jilinJson = _.get(citys, 'jilinJson');
|
|
|
+ console.log(jilinJson);
|
|
|
if (this.$checkRes(res)) {
|
|
|
- city = jlJson.features.map(i => {
|
|
|
+ city = jilinJson.features.map(i => {
|
|
|
let object = {};
|
|
|
object.name = _.get(i.properties, 'name');
|
|
|
let result = res.data.filter(f => f.place == object.name);
|
|
@@ -43,7 +47,7 @@ export default {
|
|
|
return object;
|
|
|
});
|
|
|
}
|
|
|
- let newJson = this.setPos(_.cloneDeep(jlJson));
|
|
|
+ let newJson = this.setPos(_.cloneDeep(jilinJson));
|
|
|
let option = {
|
|
|
title: {
|
|
|
text: '展会分布',
|
|
@@ -55,7 +59,7 @@ export default {
|
|
|
geo: {
|
|
|
// zoom: 1.3,
|
|
|
type: 'map',
|
|
|
- map: '吉林',
|
|
|
+ map: name, //吉林 china
|
|
|
label: {
|
|
|
show: true,
|
|
|
color: '#fff',
|
|
@@ -71,7 +75,7 @@ export default {
|
|
|
visualMap: {
|
|
|
//颜色轴,可以根据数据点的值大小,展示不同的颜色,或用来展示地图块的不同颜色
|
|
|
min: 0,
|
|
|
- max: _.maxBy(city, 'value').value,
|
|
|
+ max: 10000, //_.maxBy(city, 'value').value
|
|
|
calculable: true,
|
|
|
inRange: {
|
|
|
color: ['#8dc5f4', '#266bce'],
|
|
@@ -82,9 +86,9 @@ export default {
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
- name: '吉林省',
|
|
|
+ name: name == 'china' ? '中国' : name, //吉林省
|
|
|
type: 'map',
|
|
|
- map: 'jilin',
|
|
|
+ map: name, //jilin,china
|
|
|
emphasis: {
|
|
|
label: {
|
|
|
show: true,
|
|
@@ -94,14 +98,29 @@ export default {
|
|
|
textFixed: {
|
|
|
Alaska: [20, 120],
|
|
|
},
|
|
|
- data: city,
|
|
|
+ data: [],
|
|
|
+ // 全国地图数据:{ name: '辽宁', value: 1555 },
|
|
|
+ // { name: '黑龙江', value: 1555 },
|
|
|
+ // { name: '吉林', value: 1555 }
|
|
|
+ // 城市
|
|
|
},
|
|
|
],
|
|
|
};
|
|
|
//用$echarts是因为上面注册使用的 Vue.prototype.$echarts
|
|
|
- echarts.registerMap('jilin', newJson);
|
|
|
+ echarts.registerMap(name, name == 'china' ? cJson : jilinJson);
|
|
|
this.myChart = echarts.init(document.getElementById('chartMap'));
|
|
|
this.myChart.setOption(option);
|
|
|
+ this.myChart.hideLoading();
|
|
|
+ this.myChart.on('click', params => {
|
|
|
+ console.log(params);
|
|
|
+ let name = params.name;
|
|
|
+ let res = cJson.features.find(f => {
|
|
|
+ let o = _.get(f, 'properties');
|
|
|
+ if (o) return o.name == name;
|
|
|
+ else return false;
|
|
|
+ });
|
|
|
+ console.log(res);
|
|
|
+ });
|
|
|
},
|
|
|
setPos(data) {
|
|
|
data.features.map(i => {
|