level 1
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--自适应device-width设备宽度-->
<meta http-equiv="viewport" content="width=device-width";>
<script type="text/javascript" src="js/china.js"></script>
<script type="text/javascript" src="js/echarts.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<title>ECharts</title>
<style>
</style>
</head>
<body>
<div id="center" style="width:2200px;height:1200px">
<script >
//初始化
var myChart = echarts.init(document.getElementById('center'));
myChart.showLoading();//加载数据前显示的动画效果
//读取微博JSON数据
$.getJSON('/json/weibo.json', function (weiboData) {
myChart.hideLoading();//加载数据完成后隐藏动画
//定义一个Data方法将读取的微博数据根据经纬度组合成新的JSON,用于显示
Data = function (index) {
data = weiboData[index];
var px = data[0] / 1000;
var py = data[1] / 1000;
var res = [[px, py]];
for (var i = 2; i < data.length; i += 2) {
var dx = data[i] / 1000;
var dy = data[i + 1] / 1000;
var x = px + dx;
var y = py + dy;
res.push([x, y, 1]);
px = x;
py = y;
}
return res;
};
//设置参数
myChart.setOption(
option = {
backgroundColor: '#404a59',
title: { //标题组件
text: '微博签到数据点亮中国',
subtext: 'From ThinkGIS',
sublink: 'http://www.thinkgis.cn/public/sina',
left: 'center',
top: 'top',
textStyle: {
color: '#fff'
}
},
legend: { //图例组件
left: 'left',
data: ['强', '中', '弱'],
textStyle: {
color: '#ccc'
}
},
geo: { //地理坐标系组件
name: '强',
type: 'scatter',
map: 'china',
label: {
emphasis: {
show: false
}
},
itemStyle: {
normal: {
areaColor: '#323c48',
borderColor: '#111'
},
emphasis: {
areaColor: '#2a333d'
}
}
},
series: [{ //系列列表
name: '弱',
type: 'scatter',
coordinateSystem: 'geo',
symbolSize: 1,
large: true,
itemStyle: {
normal: {
shadowBlur: 2,
shadowColor: 'rgba(37, 140, 249, 0.8)',
color: 'rgba(37, 140, 249, 0.8)'
}
},
data: Data(0)
}, {
name: '中',
type: 'scatter',
coordinateSystem: 'geo',
symbolSize: 1,
large: true,
itemStyle: {
normal: {
shadowBlur: 2,
shadowColor: 'rgba(14, 241, 242, 0.8)',
color: 'rgba(14, 241, 242, 0.8)'
}
},
data: Data(1)
}, {
name: '强',
type: 'scatter',
coordinateSystem: 'geo',
symbolSize: 1,
large: true,
itemStyle: {
normal: {
shadowBlur: 2,
shadowColor: 'rgba(255, 255, 255, 0.8)',
color: 'rgba(255, 255, 255, 0.8)'
}
},
data: Data(2)
}]
});
myChart.setOption(option);
});
</script>
</div>
</body>
</html>
2016年10月31日 03点10分

