echarts 中国地图,根据省份数值高低改变省份颜色深浅

时间:2022-10-04 16:54:24


function randomValue() {
return Math.round(Math.random()*2000);
}

option = {
backgroundColor:'block',
tooltip: {},
visualMap: {
min: 0,
max: 2000,
text:['High','Low'],
realtime: false,
calculable: true,
inRange: {
color: ['#e0ffff', 'red']
}
},
geo: {
map: 'china',
roam: true,
label: {
normal: {
show: true,
textStyle: {
color: 'rgba(0,0,0,0.4)'
}
}
},
itemStyle: {
normal:{
borderColor: 'rgba(0, 0, 0, 0.2)'
},
emphasis:{
areaColor: null,
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowBlur: 20,
borderWidth: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
},
series : [
{
name: '浏览量',
type: 'map',
roam: true,
coordinateSystem: 'geo',
geoIndex: 0,
// tooltip: {show: false},
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#F06C00'
}
},
data:[
{name: '北京', value: randomValue()},
{name: '天津', value: randomValue()},
{name: '上海', value: randomValue()},
{name: '重庆', value: randomValue()},
{name: '河北', value: randomValue()},
{name: '河南', value: randomValue()},
{name: '云南', value: randomValue()},
{name: '辽宁'