var url = '这里输入请求的网址链接';
var year = [],temp = [];
console.log("aa");
$.ajax({
type: 'get',
url:url,
dataType:'json',
success:function(data){
for(var o in data['data']) {
year.push(data['data'][o]['date'].slice(0,4)-0);
temp.push(data['data'][o]['value']);
}
console.log(temp);
console.log(year);
var myChart = echarts.init(document.getElementById('main'));
option = {
title: {
text: '统计'
},
tooltip: {
trigger: 'axis'
},
legend: {
data:['统计']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: year
},
yAxis: {
type: 'value'
},
series: [
{
name:'统计',
type:'line',
stack: '总量',
data:temp
}
]
};
myChart.setOption(option);
}
})