87,994
社区成员
发帖
与我相关
我的任务
分享
<div id="LeftSecond" style="width:25%;height:35%;top:33.8%;position:absolute;left:0.2%;border-style:solid;border-width:1.5px;border-color:#404a59;background-size:100% 100%!important;"></div>
<script src="js/worldm7.js"></script>
<script type="text/javascript">
function loadScript(url, callback) {
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState) { //IE
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function() {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
// 基于准备好的dom,初始化echarts实例
var LeftSecondChart = echarts.init(document.getElementById('LeftSecond'));
option2 = {
backgroundColor: '',
title: {
text: '全球xx疾病人数分布',
subtext: '',
left: 'left',
top: 'top',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
tooltip: {
trigger: 'item',
position: 'bottom',
textStyle: {
color: '#fff',
fontStyle: 'normal',
fontFamily: '微软雅黑',
fontSize: 6,
},
formatter: function(params) {
var value = (params.value + '').split('.');
value = value[1].split(',')[1];
return params.name;
}
},
visualMap: {
show: false,
min: 0,
max: 100, //调整直径大小
inRange: {
symbolSize: [1, 60]
}
},
//该项设置无效
grid:{
x:3,
y:3,
x2:3,
y2:1,
borderWidth:1
},
geo: {
name: 'Enroll distribution',
type: 'map',
map: 'world',
//改变地图位置和大小
layoutCenter:['50%','55%'], //'50%'位置居中
layoutSize:320,//改变地图大小
roam: true,
label: {
emphasis: {
show: true
}
},
itemStyle: {
normal: {
areaColor: 'rgba(37, 43, 61, .5)',//#6df8f0#0092e7#36648Brgba(50, 195, 255, 1)#1874CD
borderColor: '#91e6ff'
},
emphasis: {
areaColor: '#6df8f0'
}
}
},
series: [{
type: 'scatter',
coordinateSystem: 'geo',
zoom: 5,
data: DATA.map(function(item) {
return {
name: item[0] + item[1] ,
value: [
item[3],
item[2],
Math.sqrt(item[1]) * 10
],
itemStyle: {
normal: {
color: "red"
}
}
};
})
}]
};
// 间隔20秒获取.js数据。
LeftSecondChart.setOption(option2);
myEcharts.push(LeftSecondChart);
setInterval(function(){
loadScript('js/worldm7.js', function(){
LeftSecondChart.clear();
option2.series[0].data = DATA;
LeftSecondChart.setOption(option2);
});
}, 20000);
</script>
var DATA = [
["悉尼", 3, -33.860489, 151.163061],
["新加坡", 2, 26.258324, 105.961714],
["天津市", 1, 39.14393, 117.210813],
["Kingston", 2, 44.268447, -76.512442],
["上塞纳省", 1, 48.8399127, 2.100653],
["明尼苏达州 明尼阿波利斯", 1, 44.953389, -93.202599],
["纽约州 纽约", 1, 40.79617, -73.983747],
["田纳西州 Franklin", 1, 41.394644, -79.824889],
["瑞典 斯德哥尔摩", 1, 59.338882, 18.075865],
["英国 英格兰", 1, 53.005662, -1.158626]
]

感谢囧哥!!!
主要是JavaScript代码完全不懂,用vb的思路在这瞎改,复杂点的改一天也成功不了,一次次请教您实在不好意思。。。
<div id="LeftSecond" style="width:25%;height:35%;top:33.8%;position:absolute;left:0.2%;border-style:solid;border-width:1.5px;border-color:#404a59;background-size:100% 100%!important;">
</div>
<script src="js/worldm7.js"></script>
<script type="text/javascript">
function loadScript(url, callback) {
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState) { //IE
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function() {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
// 基于准备好的dom,初始化echarts实例
var LeftSecondChart = echarts.init(document.getElementById('LeftSecond'));
function getOption(title, data){
var option = {
backgroundColor: '',
title: {
text: title,
subtext: '',
left: 'left',
top: 'top',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
tooltip: {
trigger: 'item',
position: 'bottom',
textStyle: {
color: '#fff',
fontStyle: 'normal',
fontFamily: '微软雅黑',
fontSize: 6,
},
formatter: function(params) {
var value = (params.value + '').split('.');
value = value[1].split(',')[1];
return params.name;
}
},
visualMap: {
show: false,
min: 0,
max: 100,
//调整直径大小
inRange: {
symbolSize: [1, 60]
}
},
//该项设置无效
grid: {
x: 3,
y: 3,
x2: 3,
y2: 1,
borderWidth: 1
},
geo: {
name: 'Enroll distribution',
type: 'map',
map: 'world',
//改变地图位置和大小
layoutCenter: ['50%', '55%'],
//'50%'位置居中
layoutSize: 320,
//改变地图大小
roam: true,
label: {
emphasis: {
show: true
}
},
itemStyle: {
normal: {
areaColor: 'rgba(37, 43, 61, .5)',
//#6df8f0#0092e7#36648Brgba(50, 195, 255, 1)#1874CD
borderColor: '#91e6ff'
},
emphasis: {
areaColor: '#6df8f0'
}
}
},
series: [{
type: 'scatter',
coordinateSystem: 'geo',
zoom: 5,
data: data.map(function(item) {
return {
name: item[0] + item[1],
value: [
item[3], item[2], Math.sqrt(item[1]) * 10],
itemStyle: {
normal: {
color: "red"
}
}
};
})
}]
};
return option;
}
// 间隔20秒获取.js数据。
var option2 = getOption(chartTitle, DATA);
LeftSecondChart.setOption(option2);
myEcharts.push(LeftSecondChart);
setInterval(function() {
loadScript('js/worldm7.js',
function() {
LeftSecondChart.clear();
option2 = getOption(chartTitle, DATA);
LeftSecondChart.setOption(option2);
});
}, 20000);
</script>
var DATA = [
["悉尼", 3, -33.860489, 151.163061],
["新加坡", 2, 26.258324, 105.961714],
["天津市", 1, 39.14393, 117.210813],
["Kingston", 2, 44.268447, -76.512442],
["上塞纳省", 1, 48.8399127, 2.100653],
["明尼苏达州 明尼阿波利斯", 1, 44.953389, -93.202599],
["纽约州 纽约", 1, 40.79617, -73.983747],
["田纳西州 Franklin", 1, 41.394644, -79.824889],
["瑞典 斯德哥尔摩", 1, 59.338882, 18.075865],
["英国 英格兰", 1, 53.005662, -1.158626]
];
var chartTitle = '全球xx疾病人数分布';
你这个处理外来都差不多,把option放到函数里合成,刷新后再调用一次函数
如果DATA不用处理,就可以用option.series[0].data = DATA这样赋值