ECharts繪製國內各省市地圖時要注意series.map屬性值的配置要與對應的js地圖文件註冊名一致。
如繪製湖北地圖引入hubei.js,該文件中註冊地圖名爲‘湖北’而不是‘hubei’;
源代碼如下:
<template>
<div class='hubei'>
<div ref='main' style="width: 600px; height: 400px"></div>
</div>
</template>
<script>
import echarts from 'echarts'
import 'echarts/map/js/province/hubei.js'
export default {
mounted () {
let myChart = echarts.init(this.$refs.main)
let option = {
series: [
{
type: 'map',
map: '湖北' // 此處要跟hubei.js裏對應
}
]
}
myChart.setOption(option)
}
}
</script>
<style scoped>
</style>