大白莎 2022-04-14 15:26 采纳率: 60%
浏览 1006
已结题

Echarts实现折线图时不显示

img

img


 showchart() {
      riverChart()
        .then((res) => {
          this.dateTime = res[0];
          this.ql = res[1];
          this.wrz = res[2];
          this.zl == res[3];
          console.log(this.dateTime)
          console.log(this.ql)
        })
        .catch((error) => {
          this.$message.error(error);
        });

      this.chartLine = echarts.init(document.getElementById("chartLineBox"));

      var option = {
        title: {
          text: "Stacked Line",
        },
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["水位", "警戒水位", "流量"],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: this.dateTime,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "水位",
            data: this.zl,
            type: "line",
            stack: "Total",
          },
          {
            name: "警戒水位",
            data: this.wrz,
            type: "line",
            stack: "Total",
          },
          {
            name: "流量",
            data: this.ql,
            type: "line",
            stack: "Total",
          },
        ],
      };

      this.chartLine.setOption(option);
    },

使用从后端获取的数据,折线图不显示,使用直接写的一个数组数据显示,这是为什么呀?

  • 写回答

1条回答 默认 最新

  • 木子石@ 2022-04-14 15:35
    关注

    你的数据格式问题 你传的是字符串 要使用number类型 你可以拿到数字之后用parseInt处理一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月22日
  • 已采纳回答 4月14日
  • 创建了问题 4月14日

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器