| | |
| | | this.$options.chartData = sendData; |
| | | this.organizeData(sendData) |
| | | } else { |
| | | let userId = localStorage.getItem('userId'); |
| | | let params = { |
| | | userId: userId |
| | | } |
| | | batteryGroup(params).then((res) => { |
| | | if (res.data.code == 1) { |
| | | let optionData = { |
| | | xData: [], |
| | | data: [] |
| | | } |
| | | let resData = res.data.data; |
| | | for (let key in resData) { |
| | | optionData.xData.push(key); |
| | | optionData.data.push(resData[key]); |
| | | } |
| | | this.$options.chartData = optionData; |
| | | this.organizeData(optionData) |
| | | } |
| | | }).catch((err) => { |
| | | console.log(err) |
| | | }); |
| | | this.postData() |
| | | setInterval(() => { |
| | | this.postData() |
| | | }, 3000) |
| | | } |
| | | }, |
| | | postData() { |
| | | let userId = localStorage.getItem('userId'); |
| | | let params = { |
| | | userId: userId |
| | | } |
| | | batteryGroup(params).then((res) => { |
| | | if (res.data.code == 1) { |
| | | let optionData = { |
| | | xData: [], |
| | | data: [] |
| | | } |
| | | let resData = res.data.data; |
| | | for (let key in resData) { |
| | | optionData.xData.push(key); |
| | | optionData.data.push(resData[key]); |
| | | } |
| | | this.$options.chartData = optionData; |
| | | this.organizeData(optionData) |
| | | } |
| | | }).catch((err) => { |
| | | console.log(err) |
| | | }); |
| | | }, |
| | | resize() { |
| | | setTimeout(() => { |
| | | this.$options.chart.resize(); |