echarts地图自动轮播

地图自动轮播

需求:地图有数据的置灰并且不轮播,有数据的轮播展示数据

/* 
请勿在原图上直接修改保存
*/
function mapTooltipClick(name) {
    alert(name)
}

function tooltipCharts() {
    console.log(arguments[0]);
    var myChart1 = echarts.init(document.getElementById('tooltipBarId'));
    var option = {
        tooltip: {},
        xAxis: {
            type: 'category',
            interval: true,
            axisLabel: {
                rotate: 45
            },
            axisTick: {
                show: false
            }
        },
        yAxis: {},
        color: ['#4FA8F9', '#F5A623'],
        grid: {
            show: true,
            backgroundColor: '#FAFAFA',
            left: 30,
            right: 20,
            top: 20
        },
        series: [{
            type: 'bar',
            smooth: true,
            seriesLayoutBy: 'row',
            barWidth: 10
        }]
    };
    myChart1.setOption(option);
}
option = {
    visualMap: {
        min: 0,
        max: 1000,
        left: 'left',
        top: 'bottom',
        text: ['高', '低'],
        calculable: false,
        orient: 'horizontal',
        inRange: {
            color: ['#ccc', '#006edd'],
            // symbolSize: [30, 100]
        }
    },
    tooltip: {
        padding:8,
        enterable: true,
        transitionDuration: 1,
        textStyle: {
            color: '#fff',
            decoration: 'none',
        }
    },
    series: [{
        name: '接入医院数量',
        type: 'map',
        mapType: 'china',
        itemStyle: {
            normal: {
                label: {
                    show: false
                }
            },
            emphasis: {
                label: {
                    show: true
                }
            }
        },
        label: {
			normal: { //静态的时候展示样式
				show: true, //是否显示地图省份得名称
				textStyle: {
					color: "#fff",
					fontSize: 12
				}
			},
			emphasis: { //动态展示的样式
				color: '#fff',
			},
		},
        data: [{
                name: '北京',
                value: 50,
            },
            {
                name: '天津',
                value: 100,
            },
            {
                name: '上海',
                value: 200,
            },
            {
                name: '重庆',
                value: 300,
            },
            {
                name: '河北',
                value: 400,
            },
            {
                name: '河南',
                value: 500,
            },
            {
                name: '云南',
                value: 600,
            },
            {
                name: '辽宁',
                value: 700,
            },
            {
                name: '黑龙江',
                value: 800,
            },
            {
                name: '湖南',
                value:900,
            },
            {
                name: '安徽',
                value: 1000,
            }
        ]
    }, ]
}
var count = 0;
var timeTicket = null;
var dataLength = option.series[0].data.length;
timeTicket && clearInterval(timeTicket);
timeTicket = setInterval(function() {
    myChart.dispatchAction({
        type: 'downplay',
        seriesIndex: 0,
    });
    myChart.dispatchAction({
        type: 'highlight',
        seriesIndex: 0,
        dataIndex: (count) % dataLength
    });
    myChart.dispatchAction({
        type: 'showTip',
        seriesIndex: 0,
        dataIndex: (count) % dataLength
    });
    count++;
}, 2000);

myChart.on('mouseover', function(params) {
    console.log(params)
    clearInterval(timeTicket);
    myChart.dispatchAction({
        type: 'downplay',
        seriesIndex: 0
    });
    myChart.dispatchAction({
        type: 'highlight',
        seriesIndex: 0,
        dataIndex: params.dataIndex
    });
    myChart.dispatchAction({
        type: 'showTip',
        seriesIndex: 0,
        dataIndex: params.dataIndex,
    });
});
myChart.on('mouseout', function(params) {
    timeTicket && clearInterval(timeTicket);
    timeTicket = setInterval(function() {
        myChart.dispatchAction({
            type: 'downplay',
            seriesIndex: 0,
        });
        myChart.dispatchAction({
            type: 'highlight',
            seriesIndex: 0,
            dataIndex: (count) % dataLength
        });
        myChart.dispatchAction({
            type: 'showTip',
            seriesIndex: 0,
            dataIndex: (count) % dataLength
        });
        count++;
    }, 1000);
});
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值