Commit 990a9c4f authored by 何鹏程's avatar 何鹏程

修改地图相关

parent e9a69d19
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
</template> </template>
<script> <script>
let Echarts = require('echarts/lib/echarts'); import * as echarts from 'echarts';
let wuhan = require('@/assets/map/wuhan.json'); import wuhan from '@/assets/map/wuhan.json'
// let china = require('echarts/map/json/china');
export default { export default {
data() { data() {
return { return {
...@@ -68,9 +68,8 @@ export default { ...@@ -68,9 +68,8 @@ export default {
}, },
methods: { methods: {
init() { init() {
Echarts.registerMap('wuhan', wuhan) echarts.registerMap('wuhan', wuhan)
// Echarts.registerMap('china', china) const myChart = echarts.init(this.$refs.chart);
this.chart = Echarts.init(this.$refs.chart);
let option = { let option = {
title: { title: {
text: '武汉市地图', text: '武汉市地图',
...@@ -81,10 +80,6 @@ export default { ...@@ -81,10 +80,6 @@ export default {
right: '90px', right: '90px',
bottom: '109px' bottom: '109px'
}, },
// tooltip: {
// trigger: 'item',
// formatter: '{b}<br/>{c} (p / km2)'
// },
visualMap: { visualMap: {
type: 'piecewise', type: 'piecewise',
min: 100, min: 100,
...@@ -108,10 +103,10 @@ export default { ...@@ -108,10 +103,10 @@ export default {
color: '#386FFF', color: '#386FFF',
fontSize: 29, fontSize: 29,
}, },
inRange: {
symbol: [],
color: ['#1A347A', '#24449C', '#2B52BD', '#3361DE', '#386FFF'] color: ['#1A347A', '#24449C', '#2B52BD', '#3361DE', '#386FFF']
} // inRange: {
// // symbol: [],
// }
}, },
series: [ series: [
{ {
...@@ -132,6 +127,15 @@ export default { ...@@ -132,6 +127,15 @@ export default {
backgroundColor: '#00FFFC', backgroundColor: '#00FFFC',
}, },
}, },
select: {
label: {
show: false
},
itemStyle: {
areaColor: '#00FFFC',
backgroundColor: '#00FFFC',
},
},
itemStyle: { itemStyle: {
borderWidth: 2, borderWidth: 2,
borderColor: '#000D4A' borderColor: '#000D4A'
...@@ -142,8 +146,9 @@ export default { ...@@ -142,8 +146,9 @@ export default {
} }
] ]
} }
this.chart.setOption(option); // this.chart.setOption(option);
this.chart.on('click', (params) => { myChart.setOption(option);
myChart.on('click', (params) => {
this.selectData = params.data this.selectData = params.data
}); });
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</template> </template>
<script> <script>
let Echarts = require('echarts/lib/echarts'); import * as echarts from 'echarts';
export default { export default {
data() { data() {
return { return {
...@@ -38,7 +38,8 @@ export default { ...@@ -38,7 +38,8 @@ export default {
}, },
methods: { methods: {
init() { init() {
this.chart = Echarts.init(this.$refs.chart); const myChart = this.chart || echarts.init(this.$refs.chart);
// this.chart = echarts.init(this.$refs.chart);
let option = { let option = {
tooltip: { tooltip: {
trigger: 'item' trigger: 'item'
...@@ -104,7 +105,8 @@ export default { ...@@ -104,7 +105,8 @@ export default {
} }
] ]
}; };
this.chart.setOption(option); myChart.setOption(option);
this.chart = myChart
} }
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="main"> <div class="main">
<div <div
class="chart" class="chart"
:id="idKey" ref="chart"
> >
</div> </div>
</div> </div>
...@@ -16,10 +16,6 @@ export default { ...@@ -16,10 +16,6 @@ export default {
type: Array, type: Array,
default: [] default: []
}, },
idKey: {
type: String,
default: 'chart'
},
title: { title: {
type: String, type: String,
default: '' default: ''
...@@ -46,7 +42,7 @@ export default { ...@@ -46,7 +42,7 @@ export default {
}, },
methods: { methods: {
init() { init() {
var myChart = echarts.init(document.getElementById(this.idKey)); const myChart = this.chart || echarts.init(this.$refs.chart);
const data = this.dataList.map(item => { const data = this.dataList.map(item => {
return [item.name, item.value] return [item.name, item.value]
}) })
...@@ -114,7 +110,8 @@ export default { ...@@ -114,7 +110,8 @@ export default {
}] }]
}; };
option && myChart.setOption(option); myChart.setOption(option);
this.chart = myChart
} }
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="main"> <div class="main">
<div <div
class="chart" class="chart"
:id="idKey" ref="chart"
> >
</div> </div>
</div> </div>
...@@ -19,10 +19,6 @@ export default { ...@@ -19,10 +19,6 @@ export default {
colorList: { colorList: {
type: Array, type: Array,
default: [] default: []
},
idKey: {
type: String,
default: 'chart'
} }
}, },
watch: { watch: {
...@@ -42,7 +38,7 @@ export default { ...@@ -42,7 +38,7 @@ export default {
}, },
methods: { methods: {
init() { init() {
var myChart = echarts.init(document.getElementById(this.idKey)); const myChart = this.chart || echarts.init(this.$refs.chart);
let option = { let option = {
tooltip: { tooltip: {
trigger: 'item' trigger: 'item'
...@@ -63,7 +59,6 @@ export default { ...@@ -63,7 +59,6 @@ export default {
}, },
series: [ series: [
{ {
// name: '车辆类型占比',
type: 'pie', type: 'pie',
radius: ['60%', '100%'], radius: ['60%', '100%'],
left: 'center', left: 'center',
...@@ -117,8 +112,8 @@ export default { ...@@ -117,8 +112,8 @@ export default {
} }
] ]
}; };
myChart.setOption(option);
option && myChart.setOption(option); this.chart = myChart
} }
} }
} }
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
<EchartsPie <EchartsPie
:dataList="vechieSpecialList" :dataList="vechieSpecialList"
:colorList="vechieSpecialPurpose" :colorList="vechieSpecialPurpose"
idKey="vechieSpecialPurpose"
/> />
</div> </div>
<div class="box"> <div class="box">
...@@ -58,7 +57,6 @@ ...@@ -58,7 +57,6 @@
<EchartsPie <EchartsPie
:dataList="vechieTypeList" :dataList="vechieTypeList"
:colorList="vechieType" :colorList="vechieType"
idKey="vechieType"
/> />
</div> </div>
</div> </div>
...@@ -66,7 +64,6 @@ ...@@ -66,7 +64,6 @@
<div class="title">辖区急救车辆总数排行</div> <div class="title">辖区急救车辆总数排行</div>
<EchartsBar <EchartsBar
:dataList="carCountList" :dataList="carCountList"
idKey="carCount"
:areaList="areaList" :areaList="areaList"
title="车辆" title="车辆"
/> />
...@@ -75,7 +72,6 @@ ...@@ -75,7 +72,6 @@
<div class="title">辖区站点总数排行</div> <div class="title">辖区站点总数排行</div>
<EchartsBar <EchartsBar
:dataList="siteCountList" :dataList="siteCountList"
idKey="siteCount"
:areaList="areaList" :areaList="areaList"
title="站点" title="站点"
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment