基础配置
echarts.registerMap('china', chinaGeo)
this.mapEchart = echarts.init(this.$refs.mapEchart)
const mapOption = {
tooltip: {
trigger: 'item',
formatter: params => {
if (this.commonUtils.isNull(params.data)) {
return params.name
} else {
return params.name + ': ' + params.data.value + '吨'
}
}
},
visualMap: {
show: true,
x: 'left',
y: 'center',
splitList: [
{ start: splitNumber * 3, end: maxNumber },
{
start: splitNumber * 2,
end: splitNumber * 3
},
{
start: splitNumber * 1,
end: splitNumber * 2
},
{ start: 0, end: splitNumber }
],
color: [
'#0249D8',
'#3F7EFD',
'rgba(63,126,253,0.60)',
'rgba(63,126,253,0.30)'
]
},
series: [
{
name: '数据',
type: 'map',
mapType: 'china',
roam: false,
emphasis: {
itemStyle: {
areaColor: '#58B2FF',
},
label:{
color: '#8FF0FF'
}
},
data: data
}
]
}
this.mapEchart.setOption(mapOption)
this.mapEchart.off('selectchanged')
this.mapEchart.on('selectchanged', param => {
if (param.selected && param.selected.length) {
this.preSelectMapIndex = param.selected[0].dataIndex[0]
}
})
this.mapEchart.on('click', param => {
this.dealProvince = param.name
getProvinceMapPopup({
belong_province: this.dealProvince
}).then(res => {
if (res) {
this.storageProductData = res
this.expandRowKeys = this.setExpandRowKey(this.storageProductData)
this.isShowDetailDlg = true
}
})
})
listenClickEvent (event, click) {
this.mapEchart.dispatchAction({
type: 'mapUnSelect',
seriesIndex: 0,
dataIndex: this.preSelectMapIndex
})
},