fuliqi
2024-09-18 4c03db2f0d6b4320e670b770f4c1e252809303a3
src/views/screen/components/lineChart.vue
@@ -15,13 +15,18 @@
  },
  data () {
    return {
      dataList: {
        name: [],
        data1: [],
        data2: [],
      myDrawLine: null
    }
      },
      // 配置
      option: {
  methods: {
    initDrawLine() {
      const that = this
      let option = {
        grid: {
          width: '100%'
        },
@@ -66,7 +71,7 @@
            margin: 20,
            rotate: 30
          },
          data: this.dataList.name,
          data: that.name,
        },
        // Y轴配置
        yAxis: {
@@ -92,7 +97,7 @@
          {
            name: '已处理工单数',
            type: 'line',
            data: this.dataList.data1,
            data: that.data1,
            smooth: true,
            areaStyle: {
              color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
@@ -113,7 +118,7 @@
          {
            name: '未处理工单数',
            type: 'line',
            data: this.dataList.data2,
            data: that.data2,
            smooth: true,
            areaStyle: {
              color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
@@ -132,17 +137,9 @@
            }
          }
        ]
      },
      myDrawLine: null
    }
  },
  methods: {
    initDrawLine () {
      const that = this
      that.myDrawLine = this.$echarts.init(this.$refs.lineChart)
      that.myDrawLine.setOption(that.option)
      that.myDrawLine.setOption(option)
      window.addEventListener('resize', function () {
        that.myDrawLine.resize()
      })
@@ -152,20 +149,14 @@
  watch: {
    workOrderRegion: {
      handler(newV, oldV) {
        let name = [];
        let data1 = [];
        let data2 =  [];
        this.workOrderRegion.map((item) => {
          name.push(item.area);
          data1.push(item.doneNum);
          data2.push(item.todoNum);
        this.name =[]
        this.data1=[]
        this.data2=[]
        newV.map((item) => {
          this.name.push(item.area);
          this.data1.push(item.doneNum);
          this.data2.push(item.todoNum);
        })
        console.log(this, "ddddd")
        console.log(this.dataList, "ddddd")
        this.dataList.name = name;
        console.log(name)
        this.dataList.data1 = data1;
        this.dataList.data2 = data2;
        this.initDrawLine()
      },
      deep: true