js按照需求重构数组

 // 饼图
    async screenTablespace() {
      const result = await screenTablespace();
      if (result) {
        const colors = [
          "#014CF5",
          "#06D9D9",
          "#06B7D9",
          "#FF6C24",
          "#3AE9A1",
          "#06D9D9",
          "#06D9D9",
          "#014CF5"
        ];
        this.tableData = result.data.rows.map((x, index) => {
          const item = {
            name: x["表空间名"],
            value: x["总大小_m"],
            itemStyle: {
              normal: {
                color: colors[index]
              }
            }
          };
          return item;
        });
        console.log("asff");
        console.log(this.tableData);

        this.pieList = result.data.rows.map(x => {
          return x.总大小_m;
        });
        this.pienameList = result.data.rows.map(x => {
          return x.表空间名;
        });
        this.drawLine();
      }
    },

你可能感兴趣的:(代码片段)