参考官网,设置默认代码:
var chartDom = document.getElementById('main'); var myChart = echarts.init(chartDom); var option; option = {......}
更新核心代码:
var _option = myChart.getOption(); _option.series[0].data = data; //myChart.setOption(_option,true); myChart.setOption(_option);
jQuery测试:
$.ajax({
type: 'Get',
// url返回的数据类型要为:application/json
url: '/?p=1&time=5',
success: function (data) {
var _option = myChart.getOption();
_option.series[0].data = data;
myChart.setOption(_option,true);
}
});