whyczyk
2021-03-22 fc74998431982dc1385d2930adcf339cbf15ffd6
src/components/charts/abeamProChart.vue
@@ -43,7 +43,7 @@
        let dataColor = posData.color;
        let bgColor = posData.bgColor;
        let yData = posData.yData;
        let radius = (this.$refs.chart.clientHeight / 3 - 7) > 0 ? this.$refs.chart.clientHeight / 3 - 7 : 0;
        let radius = (this.$refs.chart.clientHeight / 4 - 7) > 0 ? this.$refs.chart.clientHeight / 4 - 7 : 0;
        let data = posData.data;
        let max = posData[0];
        data.map(item => {
@@ -173,30 +173,36 @@
          this.$options.chartData = sendData;
          this.organizeData(sendData)
        } else {
          let userId = localStorage.getItem('userId');
          let params = {
            userId: userId
          }
          batteryStatus(params).then((res) => {
            if (res.data.code == 1) {
              let optionData = {
                yData: [],
                color: ['#f58881', '#b4d465', '#ffcb29'],
                bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
                data: []
              }
              let resData = res.data.data;
              for (let key in resData) {
                optionData.yData.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
        }
        batteryStatus(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = {
              yData: [],
              color: ['#f58881', '#b4d465', '#ffcb29'],
              bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
              data: []
            }
            let resData = res.data.data;
            for (let key in resData) {
              optionData.yData.push(key);
              optionData.data.push(resData[key]);
            }
            this.$options.chartData = optionData;
            this.organizeData(optionData)
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        setTimeout(() => {
@@ -230,6 +236,6 @@
  .flexCon .con {
    width: 100%;
    height: 70%;
    height: 80%;
  }
</style>