鍍金池/ 問答/Linux  HTML/ vue中使用echarts通過ajax獲取數(shù)據(jù)動態(tài)賦值

vue中使用echarts通過ajax獲取數(shù)據(jù)動態(tài)賦值

clipboard.png
這個option在mounted里

clipboard.png
當(dāng)我點(diǎn)擊按鈕在methods里獲取數(shù)據(jù),怎樣給legend和series里的data賦值呢?難道只能把option的代碼放進(jìn)ajax請求里嗎?

回答
編輯回答
溫衫

在data中聲明 option配置
在Axios中修改

Axios.then((res)=>{
    this.option.serise[0] = res.data.data;
    //數(shù)據(jù)處理之后  init echarts函數(shù)
})
2018年2月26日 11:13
編輯回答
神經(jīng)質(zhì)

我司做法是把常用的幾個Echart圖表的option配置寫幾個函數(shù)封裝好,用的時候直接傳數(shù)據(jù)進(jìn)去就行

2018年6月8日 13:42