1.找到对应的json文件
2.打开网址
3.输入代码
$.get(ROOT_PATH + '/data/asset/data/life-expectancy.json', function (data) {
var itemStyle = {
opacity: 0.8
};
// Schema:
var schema = [
{ name: 'x', index: 0, text: '图中位置x' },
{ name: 'y', index: 1, text: '图中位置y' },
{ name: '经纬度', index: 2, text: '经纬度' },
{ name: '基站index', index: 3, text: '基站index' }
];
option = {
baseOption: {
title: [
{
textAlign: 'center',
left: '63%',
top: '55%',
textStyle: {
fontSize: 100
}
},
{
text: '基站时间序列特征提取',
left: 'center',
top: 10,
textStyle: {
fontWeight: 'normal',
fontSize: 20
}
}
],
tooltip: {
padding: 5,
borderWidth: 1,
formatter: function (obj) {
var value = obj.value;
// prettier-ignore
return schema[3].text + ':' + value[3] + '<br>'
+ schema[1].text + ':' + value[1] + '<br>'
+ schema[0].text + ':' + value[0] + '<br>'
+ schema[2].text + ':' + value[2] + '<br>';
}
},
grid: {
top: 100,
containLabel: true,
left: 30,
right: '110'
},
xAxis: {
type: 'log',
name: '人均收入',
max: 100000,
min: 300,
nameGap: 25,
nameLocation: 'middle',
nameTextStyle: {
fontSize: 18
},
splitLine: {
show: false
},
axisLabel: {
formatter: '{value} $'
}
},
yAxis: {
type: 'value',
name: '平均寿命',
max: 100,
nameTextStyle: {
fontSize: 18
},
splitLine: {
show: false
},
axisLabel: {
formatter: '{value} 岁'
}
},
series: [
{
type: 'scatter',
itemStyle: itemStyle,
data: data.series[0],
}
],
},
options: []
};
for (var n = 0; n < data.timeline.length; n++) {
option.options.push({
series: {
name: data.timeline[n],
type: 'scatter',
itemStyle: itemStyle,
data: data.series[n],
}
});
}
myChart.setOption(option);
});
4.打开json文件,替换掉代码中的data数据
5.在网页上运行代码