Echarts地图

最近项目需要,研究前端。

工具:HBuilder.

<script type="text/javascript">
		$.get('220100.json', function (CcJson){
			echarts.registerMap('长春', CcJson);
			var myChart9 = echarts.init(document.getElementById('changchun_map'));
			var option9 = {
				title: {  
	                text: '长春-test',  
	                left:'center'  
				},
				tooltip: {
		          	//提示框,飘窗
		          	trigger: 'item',
		          	backgroundColor:'#000',
		          	textStyle:{
		          		color:'#f2ec10'
		          	}
		       	},
		        legend: {
                    //地图上面的点
                 	orient: 'vertical'
              	},
              	itemStyle:{
              		normal:{
              			backgroundColor:'#000'
              		},
              		emphasis:{
              			backgroundColor:'#000'
              		}
              	},
	            series:[{
                    name:'XX数据',
	            	type:'map',
	        		mapType:'长春',
	        		roam: false,
	        		label: {//地图上面文字
	                    normal: {show: true,color:'#fff'},
	                    //选中状态
                        emphasis: {show: true,color:'#000'}
	        		},
	        		data:[
	        			{name:'宽城区',value:401178},
	        			{name:'绿园区',value:401178},
	        			{name:'朝阳区',value:401178},
	        			{name:'德惠市',value:401178},
	        			{name:'二道区',value:401178},
	        			{name:'九台市',value:401178},
	        			{name:'南关区',value:281953},
	        			{name:'农安县',value:170259},
	        			{name:'双阳区',value:171110},
	        			{name:'榆树市',value:371027}
	        		]			
	            }]
	        };
            //轮播
	        var count = 0;
			var timeTicket = null;
			var dataLength = option9.series[0].data.length;
			timeTicket && clearInterval(timeTicket);
			timeTicket = setInterval(function() {
				myChart9.dispatchAction({
					type: 'downplay',
					seriesIndex: 0,
				});
				myChart9.dispatchAction({
					type: 'highlight',
					seriesIndex: 0,
					dataIndex: (count) % dataLength
				});
				myChart9.dispatchAction({
					type: 'showTip',
					seriesIndex: 0,
					dataIndex: (count) % dataLength
				});
				count++;
			}, 1500);
			myChart9.on('mouseover', function(params) {
				console.log(params);
				clearInterval(timeTicket);
				myChart9.dispatchAction({
					type: 'downplay',
					seriesIndex: 0
				});
				myChart9.dispatchAction({
					type: 'highlight',
					seriesIndex: 0,
					dataIndex: params.dataIndex
				});
				myChart9.dispatchAction({
					type: 'showTip',
					seriesIndex: 0,
					dataIndex: params.dataIndex
				});
			});
			myChart9.on('mouseout', function(params) {
				timeTicket && clearInterval(timeTicket);
				timeTicket = setInterval(function() {
				myChart9.dispatchAction({
					type: 'downplay',
					seriesIndex: 0,
				});
				myChart9.dispatchAction({
					type: 'highlight',
					seriesIndex: 0,
					dataIndex: (count) % dataLength
				});
				myChart9.dispatchAction({
					type: 'showTip',
					seriesIndex: 0,
					dataIndex: (count) % dataLength
				});
				count++;
			}, 1500);
		});
        myChart9.setOption(option9);
        window.onresize = myChart9.resize;
		});
	</script>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值