yichenxi
2022-12-12 eb07bc16cb0b06f3b96a4f59d74f82b62195f096
src/views/charts/index.vue
@@ -18,8 +18,8 @@
        style="margin-left: 20px"
      >
        <el-option
          v-for="item in newSensor"
          :key="item.value"
          v-for="(item, index) in newSensor"
          :key="index"
          :label="item.label"
          :value="item.value"
        />
@@ -272,45 +272,35 @@
          let lockLength = 0
          for (let i = 0; i < data.length; i++) {
            for (let j = 0; j < data[i].deviceData.length; j++) {
              console.log(data[i].deviceData);
              // console.log(data[i].deviceData);
              if (res.data[0].deviceData.length == 1) {
                if (lockLength < data[i].deviceData.length) {
                  newLineChartData.series.push({
                    data: [],
                    name: '',
                    type: 'line',
                    label: {
                      show: true,
                      position: 'top',
                    },
                  })
                }
              } else if (lockLength < data[i].deviceData.length) {
                newLineChartData.series.push({
                  data: [],
                  name: '',
                  type: 'line',
                  label: {
                    show: false,
                    show: true,
                    position: 'top',
                  },
                })
              } else {
                newLineChartData.series.push({
                  data: [],
                  name: '',
                  type: 'line',
                })
              }
              newLineChartData.series[j].name = data[i].deviceData[j].name
              newLineChartData.title.push(data[i].deviceData[j].name)
              lockLength++
              newLineChartData.series[j].data.push(
                data[i].deviceData[j].sensorValue
              )
            }
            newLineChartData.xAxis.push(data[i].time)
          }
          // newLineChartData.title = this.value
          this.lineChartData = newLineChartData
          // console.log(newLineChartData, 'newLineChartData')
          console.log(lineChartData, 'newLineChartData')
        })
        .catch((err) => {
          console.log(err)