echart:表格动态加载(ajax)

echarts.json(模拟数据)

{
    
    
  "code": 200,
  "msg": "请求成功",
  "data": {
    
    
    "date": [
      "2020-12-01",
      "2020-12-02",
      "2020-12-03",
      "2020-12-04",
      "2020-12-05",
      "2020-12-06",
      "2020-12-07",
      "2020-12-08",
      "2020-12-09",
      "2020-12-10"
    ],
    "pvuv": [
      12,
      32,
      45,
      67,
      53,
      75,
      31,
      83,
      80,
      100
    ]
  }
}

关键方法(前面图表部分省略)

echartsRecords.showLoading();//加载动画
$.ajax({
    
    
    type : "get",
    async : true,     //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
    url : "./echarts.json",   
    dataType : "json",        //返回数据形式为json
    success : function(result) {
    
    
        option.xAxis[0].data = result.data.date;
        option.series[0].data = result.data.pvuv;
        echartsRecords.hideLoading();
        echartsRecords.setOption(option);
    }
})

猜你喜欢

转载自blog.csdn.net/weixin_44777669/article/details/111515525