| | |
| | | chart.resize(); |
| | | }) |
| | | } else { |
| | | let userId = localStorage.getItem('userId'); |
| | | let params = { |
| | | userId: userId |
| | | } |
| | | powerAlarmStatus(params).then((res) => { |
| | | if (res.data.code == 1) { |
| | | let optionData = [{ |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#37a9b3', |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#f3535f' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#ff8b00' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#757ffb' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#4ba0d9' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#7fc57c' |
| | | }] |
| | | let index = 0; |
| | | let resData = res.data.data; |
| | | for (let key in resData) { |
| | | optionData[index].title = key; |
| | | if (typeof resData[key] == 'string') { |
| | | optionData[index].data = Number(resData[key].split('%')[0]); |
| | | optionData[index].unit = '%'; |
| | | } else { |
| | | optionData[index].data = resData[key]; |
| | | } |
| | | index++; |
| | | } |
| | | optionData.map((item, i) => { |
| | | let chart = this.$refs[`prossPieChart${i}`]; |
| | | chart.setData(item); |
| | | chart.resize(); |
| | | }) |
| | | } |
| | | }).catch((err) => { |
| | | console.log(err) |
| | | }); |
| | | this.postData() |
| | | setInterval(() => { |
| | | this.postData() |
| | | }, 3000) |
| | | } |
| | | |
| | | }) |
| | | }, |
| | | postData() { |
| | | let userId = localStorage.getItem('userId'); |
| | | let params = { |
| | | userId: userId |
| | | } |
| | | powerAlarmStatus(params).then((res) => { |
| | | if (res.data.code == 1) { |
| | | let optionData = [{ |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#37a9b3', |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#f3535f' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#ff8b00' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#757ffb' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#4ba0d9' |
| | | }, { |
| | | title: '', |
| | | data: 0, |
| | | unit: '', |
| | | color: '#7fc57c' |
| | | }] |
| | | let index = 0; |
| | | let resData = res.data.data; |
| | | for (let key in resData) { |
| | | optionData[index].title = key; |
| | | if (typeof resData[key] == 'string') { |
| | | optionData[index].data = Number(resData[key].split('%')[0]); |
| | | optionData[index].unit = '%'; |
| | | } else { |
| | | optionData[index].data = resData[key]; |
| | | } |
| | | index++; |
| | | } |
| | | optionData.map((item, i) => { |
| | | let chart = this.$refs[`prossPieChart${i}`]; |
| | | chart.setData(item); |
| | | chart.resize(); |
| | | }) |
| | | } |
| | | }).catch((err) => { |
| | | console.log(err) |
| | | }); |
| | | }, |
| | | resize() { |
| | | this.$refs.prossPieChart0.resize(); |
| | | this.$refs.prossPieChart1.resize(); |