myChart.setOption(lineOption);
var ajax = function() {
$.ajax({
url : '/echarts/showImage',
success: function(responseText) {
//请求成功时处理
var responseText = eval('(' + responseText + ')');
lineOption.legend.data=responseText.legend;
lineOption.xAxis[0].data = responseText.xAxis;
var serieslist = responseText.series;
//alert(serieslist);
for(var i=0;i<serieslist.length;i++) {
lineOption.series[i] = serieslist[i];
}
//alert(lineOption.series);
myChart.setOption(lineOption,true);
},
complete: function() {
//请求完成的处理
},
error: function() {
//请求出错处理
alert("加载失败");
}
})
}
window.setTimeout(ajax,100);
//window.setInterval(ajax,1000*60*5);
</script>
</body>
</html>
运行项目,结果如图所示: