安徽省飛行機路線図(echarts+map)
15816 ワード
Webサイト:https://gallery.echartsjs.com/editor.html?c=xfZ7Taz9LH&v=2
var uploadedDataURL = "/asset/get/s/data-1519279347346-BkslpCjwf.json";
/**
geoindex && seriesIndex: [1] geo map ,
hover tooltip
,map series geo 。
geoIndex geo 。
,map series( ) geo 。
,geo map series , visualMap 。
geoIndex ,series-map.map ,
series-map.itemStyle , geo 。
http://echarts.baidu.com/option.html#series-map.geoIndex
pin
*/
myChart.showLoading();
$.getJSON(uploadedDataURL, function(geoJson) {
echarts.registerMap('jiangxi', geoJson);
myChart.hideLoading();
var geoCoordMap = {
' ': [117.37, 31.786],
' ': [117.37, 31.386],
' ': [116.27, 31.786],
' ': [118.07, 32.486],
' ': [117.27, 33.086],
' ': [116.67, 32.786],
' ': [117.77, 33.486],
' ': [116.67, 33.686],
' ': [116.27, 33.386],
' ': [115.57, 32.986],
' ': [116.47, 30.486],
' ': [117.47, 30.386],
' ': [118.17, 29.886],
' ': [119.27, 30.916],
' ': [118.17, 31.186],
' ': [118.47, 31.616],
' ': [117.87, 30.956],
};
var moveLine = {
'normal': [{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[117.37, 31.386],
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[116.27, 31.786],
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[118.07, 32.486],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[117.27, 33.086],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[116.67, 32.786],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[117.77, 33.486],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[116.67, 33.686],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[116.27, 33.386],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[115.57, 32.986],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[117.47, 30.386],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[118.17, 29.886],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[119.27, 30.916],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[118.17, 31.186],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[116.47, 30.486],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[118.47, 31.616],
[117.37, 31.786]
]
},
{
"fromName": " ",
"toName": " ",
'coords': [
[117.37, 31.786],
[117.87, 30.956],
[117.37, 31.786]
]
},
],
};
var data = [{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 90
},
{
name: ' ',
value: 120
},
{
name: ' ',
value: 120
},
{
name: ' ',
value: 120
},
{
name: ' ',
value: 120
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 190
},
{
name: ' ',
value: 90
},
];
var max = 480,
min = 9; // todo
var maxSize4Pin = 100,
minSize4Pin = 20;
var convertData = function(data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = geoCoordMap[data[i].name];
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
});
}
}
return res;
};
var planePath =
"path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z";
option = {
backgroundColor: '#091c3d',
title: {
top: 20,
text: '',
subtext: '',
x: 'center',
textStyle: {
color: '#ccc'
}
},
tooltip: {
trigger: 'item',
formatter: function(params, ticket, callback) {
console.log(params);
if (params.seriesType == "effectScatter") {
return params.data.name + ":" + params.data.value[2];
} else if (params.seriesType == "lines") {
return params.data.fromName + "->" + params.data.toName; //+ ":" + params.data.value;
} else {
return params.name;
}
}
},
legend: {
orient: 'vertical',
y: 'bottom',
x: 'right',
data: ['pm2.5'],
textStyle: {
color: '#fff'
}
},
visualMap: {
show: false,
min: 0,
max: 500,
left: 'left',
top: 'bottom',
text: [' ', ' '], // ,
calculable: true,
seriesIndex: [1],
inRange: {
// color: ['#3B5077', '#031525'] //
// color: ['#ffc0cb', '#800080'] //
// color: ['#3C3B3F', '#605C3C'] //
//color: ['#0f0c29', '#302b63', '#24243e'] //
//color: ['#23074d', '#cc5333'] //
// color: ['#00467F', '#A5CC82'] //
// color: ['#1488CC', '#2B32B2'] //
// color: ['#00467F', '#A5CC82'] //
// color: ['#00467F', '#A5CC82'] //
// color: ['#00467F', '#A5CC82'] //
// color: ['#00467F', '#A5CC82'] //
}
},
// toolbox: {
// show: true,
// orient: 'vertical',
// left: 'right',
// top: 'center',
// feature: {
// dataView: {readOnly: false},
// restore: {},
// saveAsImage: {}
// }
// },
geo: {
show: true,
map: 'jiangxi',
label: {
normal: {
show: false
},
emphasis: {
show: false,
}
},
roam: true,
itemStyle: {
normal: {
areaColor: 'transparent',
borderColor: '#3fdaff',
borderWidth: 2,
shadowColor: 'rgba(63, 218, 255, 0.5)',
shadowBlur: 30
},
emphasis: {
areaColor: '#2B91B7',
}
}
},
series: [{
name: 'light',
type: 'scatter',
coordinateSystem: 'geo',
data: convertData(data),
symbolSize: function(val) {
return val[2] / 10;
},
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#F4E925'
}
}
},
{
type: 'map',
map: 'anhui',
geoIndex: 0,
aspectScale: 0.75, //
showLegendSymbol: false, // legend
label: {
normal: {
show: false
},
emphasis: {
show: false,
textStyle: {
color: '#fff'
}
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#031525',
borderColor: '#FFFFFF',
},
emphasis: {
areaColor: '#2B91B7'
}
},
animation: false,
data: data
},
{
name: 'Top 5',
type: 'effectScatter',
coordinateSystem: 'geo',
data: convertData(data.sort(function(a, b) {
return b.value - a.value;
}).slice(0, 5)),
symbolSize: function(val) {
return val[2] / 10;
},
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
}
},
itemStyle: {
normal: {
color: '#F4E925',
shadowBlur: 10,
shadowColor: '#05C3F9'
}
},
zlevel: 1
},
{
name: ' ',
type: 'lines',
coordinateSystem: 'geo',
zlevel: 2,
large: true,
effect: {
show: true,
constantSpeed: 30,
symbol: planePath, //ECharts 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
symbolSize: 15,
trailLength: 0,
},
lineStyle: {
normal: {
color: '#0fff17',
/*
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0, color: '#58B3CC'
}, {
offset: 1, color: '#F58158'
}], false),*/
width: 2,
opacity: 1.0,
curveness: 0.15
}
},
data: moveLine.normal
},
]
};
myChart.setOption(option);
});