macOS High Sierra:10.13.6
Safari:11.1.2(13605.3.8)浏览器下
连线没有颜色
配置项如下
var positions = {
"data": {
"cityDatas": [{
"symbolSize": 15,
"name": "福州",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [119.3, 26.08]
}, {
"symbolSize": 15,
"name": "南宁",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [108.33, 22.84]
}, {
"symbolSize": 15,
"name": "成都",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [104.06, 30.67]
}, {
"symbolSize": 15,
"name": "济南",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [117, 36.65]
}, {
"symbolSize": 15,
"name": "上海",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [121.48, 31.22]
}, {
"symbolSize": 15,
"name": "重庆",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [106.54, 29.59]
}, {
"symbolSize": 15,
"name": "石家庄",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [114.48, 38.03]
}, {
"symbolSize": 15,
"name": "武汉",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [114.31, 30.52]
}, {
"symbolSize": 15,
"name": "广州",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [113.23, 23.16]
}, {
"symbolSize": 15,
"name": "哈尔滨",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [126.63, 45.75]
}, {
"symbolSize": 15,
"name": "天津",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [117.2, 39.13]
}, {
"symbolSize": 15,
"name": "西安",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [108.95, 34.27]
}, {
"symbolSize": 15,
"name": "郑州",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [113.65, 34.76]
}, {
"symbolSize": 15,
"name": "杭州",
"itemStyle": {
"normal": {
"color": "#F58158"
}
},
"value": [120.19, 30.26]
}, {
"symbolSize": 15,
"name": "太原",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [112.53, 37.87]
}, {
"symbolSize": 15,
"name": "北京",
"itemStyle": {
"normal": {
"color": "#58B3CC"
}
},
"value": [116.46, 39.92]
}],
"tempCapitals": {
"福州": [119.3, 26.08],
"南宁": [108.33, 22.84],
"成都": [104.06, 30.67],
"济南": [117, 36.65],
"上海": [121.48, 31.22],
"重庆": [106.54, 29.59],
"石家庄": [114.48, 38.03],
"武汉": [114.31, 30.52],
"广州": [113.23, 23.16],
"哈尔滨": [126.63, 45.75],
"天津": [117.2, 39.13],
"西安": [108.95, 34.27],
"郑州": [113.65, 34.76],
"杭州": [120.19, 30.26],
"太原": [112.53, 37.87],
"北京": [116.46, 39.92]
},
"Rows": {
"山东": 28,
"福建": 20,
"上海": 10,
"山西": 24,
"四川": 30,
"河北": 25,
"河南": 26,
"广西": 13,
"浙江": 36,
"重庆": 30,
"湖北": 27,
"黑龙江": 20,
"广东": 30,
"天津": 12,
"陕西": 19,
"北京": 15
}
},
"message": "请求成功",
"status": 0
}
var historyTraceLookData = positions['data']['Rows'] || []
console.info(historyTraceLookData)
var cityDatas = positions['data']['cityDatas'] || []
var moveLines = []
var gap = parseInt(cityDatas.length / 2) - 1
for (var i = 0; i < cityDatas.length; i++) {
cityDatas[i]['symbolSize'] = 8
for (var j = 0;
(j < cityDatas.length && j < gap); j++) {
if (cityDatas[i]['name'] !== cityDatas[j]['name']) {
moveLines.push({
'fromName': cityDatas[i]['name'],
'toName': cityDatas[j]['name'],
'coords': [cityDatas[i]['value'], cityDatas[j]['value']]
})
}
}
}
option = {
backgroundColor: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [{
offset: 0,
color: '#404353' // 0% 处的颜色
}, {
offset: 1,
color: '#22242A' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
},
title: {
text: '历史记录回看',
left: 'center',
top: 'top',
textStyle: {
fontSize: 15,
color: 'rgba(255,255,255, 0.9)'
}
},
geo: {
map: 'china',
label: {
normal: {
show: true,
fontSize: 8
},
emphasis: {
show: true,
fontSize: 8
}
},
itemStyle: {
normal: {
areaColor: '#323c48',
borderColor: '#111'
},
emphasis: {
areaColor: '#2a333d'
}
}
},
series: [{
name: '地点',
type: 'effectScatter',
coordinateSystem: 'geo',
zlevel: 2,
rippleEffect: {
brushType: 'stroke'
},
label: {
emphasis: {
show: true,
position: 'right',
formatter: '{b}'
}
},
symbolSize: 2,
showEffectOn: 'render',
itemStyle: {
normal: {
color: '#46bee9'
}
},
data: cityDatas
}, {
name: '线路',
type: 'lines',
coordinateSystem: 'geo',
zlevel: 2,
large: true,
effect: {
show: true,
constantSpeed: 30,
symbol: 'pin',
symbolSize: 3,
trailLength: 0
},
lineStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#58B3CC'
}, {
offset: 1,
color: '#F58158'
}], false),
width: 2,
opacity: 0.2,
curveness: 0.1
}
},
data: moveLines
}]
};