zmc
2023-11-23 0825e9e96a6f2d4b71a51d32dae1302f2496c4d1
src/utils/chartFunction/lineChart.js
@@ -1,4 +1,5 @@
import dayjs from 'dayjs'
import { time } from 'echarts'
export default {
  // 获取该月份天数
@@ -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,50 @@
   */
  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]
  },
}