地图(china map)
<div ref="fillcontainer">
<div id="fundPosition"></div>
</div>
<script>
import echarts from 'echarts';
import '../../../node_modules/echarts/map/js/china.js';
import '../../../node_modules/echarts/theme/roma.js'
export default {
data () {
return {
chart: null
}
},
mounted () {
this.$nextTick(function() {
this.$refs.fillcontainer.style.height = (document.body.clientHeight - 160) + 'px';
this.drawMap('fundPosition')
var that = this;
var resizeTimer = null;
window.onresize = function () {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
that.$refs.fillcontainer.style.height = (document.body.clientHeight 160) + 'px';
that.drawMap('fundPosition');
}, 100)
}
})
},
methods: {
randomData () {
return Math.round(Math.random() * 1000000);
}
drawMap(id) {
if (this.chart && this.chart.dispose) {
this.chart.dispose();
}
this.chart = echarts.init(document.getElementById(id), "roma")
this.chart.setOption({
title: {
text: '2021年全国各省份投资情况',
subtext: '单位/万元',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: 'left',
data: ['总投资额']
},
visualMap: {
min: 0,
max: 1200000,
left: 'left',
top: 'bottom',
text: ['高', '低'],
calculable: true
},
toolbox: {
show: true,
orient: 'vertical',
left: 'right',
top: 'center',
feature: {
dataView: {
readOnly: false},
restore: {
},
saveAsImage: {
}
}
},
series: [
{
name: '总投资额',
type: 'map',
mapType: 'china',
roam: false,
label: {
normal:{
show: true
},
emphasis: {
show: true
},
data:[
{
name: '北京',value: this.randomData() },
{
name: '天津',value: this.randomData() },
{
name: '上海',value: this.randomData() },
{
name: '重庆',value: this.randomData() },
{
name: '河北',value: this.randomData() },
{
name: '河南',value: this.randomData() },
{
name: '云南',value: this.randomData() },
{
name: '辽宁',value: this.randomData() },
{
name: '黑龙江',value: this.randomData() },
{
name: '湖南',value: this.randomData() },
{
name: