鍍金池/ 問(wèn)答/HTML5  HTML/ echarts3 模擬遷徒 鼠標(biāo)移入的提示數(shù)據(jù)經(jīng)緯度的值怎么改成BJData里面

echarts3 模擬遷徒 鼠標(biāo)移入的提示數(shù)據(jù)經(jīng)緯度的值怎么改成BJData里面的value

clipboard.png

echarts3 模擬遷徒 鼠標(biāo)移入的提示數(shù)據(jù)經(jīng)緯度的值怎么改成BJData里面的value
找了好久找不到,在線等待高手

var BJData = [
        [{name:'銀川'}, {name:'上海',value:95}],
        [{name:'銀川'}, {name:'廣州',value:90}],
        [{name:'銀川'}, {name:'大連',value:80}],
        [{name:'銀川'}, {name:'南寧',value:70}],
        [{name:'銀川'}, {name:'南昌',value:60}],
        [{name:'銀川'}, {name:'拉薩',value:50}],
        [{name:'銀川'}, {name:'長(zhǎng)春',value:40}],
        [{name:'銀川'}, {name:'包頭',value:30}],
        [{name:'銀川'}, {name:'重慶',value:20}],
        [{name:'銀川'}, {name:'常州',value:10}]
    ];
    
    
    var convertData = function (data) {
        var res = [];
        for (var i = 0; i < data.length; i++) {
            var dataItem = data[i];
            var fromCoord = geoCoordMap[dataItem[0].name];
            var toCoord = geoCoordMap[dataItem[1].name];
            if (fromCoord && toCoord) {
                res.push({
                    fromName: dataItem[0].name,
                    toName: dataItem[1].name,
                    coords: [fromCoord, toCoord]
                });
            }
        }
        return res;
    };
    
    var color = ['#a6c84c'];
    var series = [];
    [['北京', BJData]].forEach(function (item, i) {
        series.push({
            name: "開(kāi)通城市分部圖",
            type: 'lines',
            zlevel: 1,
            effect: {
                show: true,
                period: 6,
                trailLength: 0.7,
                color: '#fff',
                symbolSize: 3
            },
            lineStyle: {
                normal: {
                    color: color[i],
                    width: 0,
                    curveness: 0.2
                }
            },
            data: convertData(item[1])
        },
        {
            name: "開(kāi)通城市分部圖",
            type: 'lines',
            zlevel: 2,
            symbol: 'none',
            symbolSize: 10,
            lineStyle: {
                normal: {
                    color: color[i],
                    width: 1,
                    opacity: 0.6,
                    curveness: 0.2
                }
            },
            data: convertData(item[1])
        },
        {
            name: "開(kāi)通城市分部圖",
            type: 'effectScatter',
            coordinateSystem: 'geo',
            zlevel: 2,
            rippleEffect: {
                brushType: 'stroke'
            },
            label: {
                normal: {
                    show: true,
                    position: 'right',
                    formatter: ''
                }
            },
            symbolSize: function (val) {
                return val[2] / 8;
            },
            itemStyle: {
                normal: {
                    color: color[i]
                }
            },
            data: item[1].map(function (dataItem) {
                return {
                    name: dataItem[1].name,
                    value: geoCoordMap[dataItem[1].name].concat(dataItem[1].value)
                };
            })
        });
    });
    
    option = {
        backgroundColor: '#404a59',
        tooltip : {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            top: 'bottom',
            left: 'right',
            data:['開(kāi)通城市分部圖'],
            textStyle: {
                color: '#fff'
            },
            selectedMode: 'single'
        },
        geo: {
            map: 'china',
            label: {
                emphasis: {
                    show: false
                }
            },
            roam: true,
            itemStyle: {
                normal: {
                    areaColor: '#323c48',
                    borderColor: '#404a59'
                },
                emphasis: {
                    areaColor: '#2a333d'
                }
            }
        },
        series: series
    };
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
回答
編輯回答
舊螢火

你要上你的代碼,才能具體給你說(shuō)啊。。。toolTip 里面有個(gè)formatter方法。

2018年7月28日 00:02