echarts切换飞线图未清空_echarts做飞线图

该博客展示了如何使用ECharts结合地图数据创建飞线图。通过获取地图数据,利用ECharts的effectScatter和lines类型组件,实现从特定位置出发的效果。在地图上展示云南省的飞线连接,并在点击地图时输出点击信息。
摘要由CSDN通过智能技术生成
飞线图

height:100%;

}

body{

height:100%;

margin:0;

padding:0;

background-color:#2F4056;

}

const xhr= newXMLHttpRequest();

xhr.open('get','https://geo.datav.aliyun.com/areas/bound/530000_full.json',true)

xhr.send(null)

xhr.onreadystatechange= () =>{if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304){

const data=JSON.parse(xhr.responseText);

console.log(Object.prototype.toString(data))

const coord= data.features.map(val =>{return{

name:val.properties.name,

value:val.properties.center

}

})

const lines_coord=[];

coord.forEach((v,index)=>{

index> 0 &&lines_coord.push({

coords:[v.value,coord[0].value]

})

})//地市取简称

data.features.forEach(v =>{

v.properties.name= v.properties.name.indexOf('版纳')>-1 ?v.properties.name.substr(0,4) : v.properties.name.substr(0,2);

})

echarts.registerMap('yns', data);

const option={

title: {

text:'云南省',

},

geo: {

map:'yns',

zlevel:10,

show:true,

layoutCenter: ['50%', '50%'],

roam:false,

layoutSize:"90%",

zoom:1,

label: {

normal: {

show:true,

textStyle:{

fontSize:12,

color:'#43D0D6'}

}

},

itemStyle: {

normal: {

color:'#062031',

borderWidth:1.1,

borderColor:'#43D0D6'}

},

emphasis: {

areaColor:'#FFB800',

label:{

show:false}

}

},

series: [

{

type:'effectScatter',

coordinateSystem:'geo',

zlevel:15,

symbolSize:8,

rippleEffect: {

period:4, brushType: 'stroke', scale: 4},

itemStyle:{

color:'#FFB800',

opacity:1},

data:coord.slice(1)

},

{

type:'effectScatter',

coordinateSystem:'geo',

zlevel:15,

symbolSize:12,

rippleEffect: {

period:6, brushType: 'stroke', scale: 8},

itemStyle:{

color:'#FF5722',

opacity:1},

data:coord.slice(0,1)

},

{

type:'lines',

coordinateSystem:'geo',

zlevel:15,

effect: {

show:true, period: 5, trailLength: 0, symbol: 'arrow', color:'#01AAED',symbolSize: 8,

},

lineStyle: {

normal: {width:1.2, opacity: 0.6, curveness: 0.2, color: '#FFB800'}

},

data:lines_coord

}

]

}

chart.setOption(option);

chart.on('click', function(params) {

console.log(params);

});

}else{

alert(xhr.status);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值