vue中echarts基礎調用后台數據


async getList() {
  const responseData = await screen_count_lineChart({
    startTime: "2020-07-20",
    endTime: "2020-07-27"
  });
  // 任務總量
  responseData.data.allTask.forEach(item => {
    this.allTask.date.push(item.date);
    this.allTask.workNum.push(item.tasknum);
  });
  // 訂單總數
  responseData.data.mapOrder.forEach(item => {
    this.mapOrder.date.push(item.date);
    this.mapOrder.workNum.push(item.tasknum);
  });
  // 成功率
  responseData.data.successTask.forEach(item => {
    this.successTask.date.push(item.date);
    this.successTask.workNum.push(item.tasknum);
  });

 

  if (this.isFirst == false) {
  // 訂單圖例
    this.myChart = echarts.init(document.getElementById("main"));
    this.myChart.setOption({
      title: {
        text: "訂單數"
      },
      color: ["green"],
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "cross",
          label: {
            backgroundColor: "#E9EEF3"
          }
        }
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: this.mapOrder.date
      },
      yAxis: {
        type: "value"
      },
      series: [{
        name: "訂單數",
        type: "line",
        stack: "總量",
        data: this.mapOrder.workNum
      }]
    });

 

  // 執行任務數/成功率 圖例
  this.myChart2 = echarts.init(document.getElementById("main2"));
  this.myChart2.setOption({
    title: {
      text: "執行任務數/成功率"
    },
    color: ["orange", "skyblue"],
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "cross",
        label: {
          backgroundColor: "#E9EEF3"
        }
      }
    },
    grid: {
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: this.allTask.date
    },
    yAxis: {
      type: "value"
    },
    series: [{
      name: "執行任務數",
      type: "line",
      stack: "總量",
      data: this.allTask.workNum
    },{
      name: "任務成功率",
      type: "line",
      stack: "百分比",
      data: this.successTask.workNum
    }]
  });
  this.isFirst = true;
  }
},


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM