echarts 中國地圖,根據省份數值高低改變省份顏色深淺

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

option = {
    tooltip: {},
    visualMap: {
        min: 0,
        max: 2000,
        text:['High','Low'],
        realtime: false,
        calculable: true,
        inRange: {
            color: ['#e0ffff', '#006edd']
        }
    },
    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: '遼寧', value: randomValue()},
                {name: '黑龍江', value: randomValue()},
                {name: '湖南', value: randomValue()},
                {name: '安徽', value: randomValue()},
                {name: '山東', value: randomValue()},
                {name: '新疆', value: randomValue()},
                {name: '江蘇', value: randomValue()},
                {name: '浙江', value: randomValue()},
                {name: '江西', value: randomValue()},
                {name: '湖北', value: randomValue()},
                {name: '廣西', value: randomValue()},
                {name: '甘肅', value: randomValue()},
                {name: '山西', value: randomValue()},
                {name: '內蒙古', value: randomValue()},
                {name: '陝西', value: randomValue()},
                {name: '吉林', value: randomValue()},
                {name: '福建', value: randomValue()},
                {name: '貴州', value: randomValue()},
                {name: '廣東', value: randomValue()},
                {name: '青海', value: randomValue()},
                {name: '西藏', value: randomValue()},
                {name: '四川', value: randomValue()},
                {name: '寧夏', value: randomValue()},
                {name: '海南', value: randomValue()},
                {name: '臺灣', value: randomValue()},
                {name: '香港', value: randomValue()},
                {name: '澳門', value: randomValue()}
            ]
        }
    ]
};
var chart=echarts.init(document.getElementById("Map"))
chart.setOption(option)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章