zmc
2023-12-01 f4062e41dfbe26ca7664a963357cc0b9bea37b44
src/utils/chartFunction/lineChart.js
@@ -46,9 +46,10 @@
      if (tempData) {
        xData.push(tempData.lst)
        yAvg.push(tempData.dayAvg)
        yOnline.push(this.deleteLastStr(tempData.dayOnline))
        yValid.push(this.deleteLastStr(tempData.dayValid))
        yExceed.push(this.deleteLastStr(tempData.dayExceeding))
        yOnline.push(tempData.dayOnline)
        yValid.push(tempData.dayValid)
        yExceed.push(tempData.dayExceeding)
        continue
      }
@@ -113,8 +114,12 @@
    return result
  },
  //   组成无数据区域
  getMarkArea(timeInteval) {
  /**
   * 组成无数据区域
   * @param: 2维数组
   * @returns:
   */
  getMarkArea(timeInteval, describe = '无数据') {
    let result = []
    for (let i = 0; i < timeInteval.length; i++) {
      let temp = []
@@ -122,7 +127,7 @@
        let obj = {}
        // 给第一个对象加上name属性
        if (j == 0) {
          obj.name = '无数据'
          obj.name = describe
        }
        obj.xAxis = timeInteval[i][j]
        temp.push(obj)
@@ -159,5 +164,46 @@
   */
  deleteLastStr(valueStr) {
    return valueStr.slice(0, -1)
  },
  /**
   * 指定时间区间的线段变颜色
   * @param:
   * @returns:
   */
  getLineColor(timeInteval, xList) {
    let result = []
    // 只取
    let temp = []
    for (let i = 0; i < timeInteval.length; i++) {
      if (timeInteval[i][0] != timeInteval[i][1]) {
        temp.push(timeInteval[i])
      }
    }
    // 无连续的数据 直接退出
    if (temp.length == 0) {
      return []
    }
    // 取第一个连续的时段
    result.push([
      {
        lte: temp[0][0],
        color: 'green'
      },
      {
        gt: temp[0][0],
        lte: temp[0][1],
        color: 'red'
      },
      {
        gt: temp[0][1],
        lte: xList[xList.length - 1],
        color: 'green'
      }
    ])
    return result[0]
  }
}