gpt4 book ai didi

echarts报错Uncaught (in promise) Error: Initialize failed: invalid dom.

转载 作者:知者 更新时间:2024-03-13 03:16:45 27 4
gpt4 key购买 nike

在echart初始化函数外加个延时就可以:

加上延时会进入异步队列,同步可能获取不到dom

setTimeout(() => {
          init2();
        }, 1);


function init2() {
      var chartDom = document.getElementById("Node2");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "0%",
          //   bottom:"5%",
          left: "center",
          textStyle: {
            color: "#ffffff",
          },
        },
        series: [
          {
            // name: "能耗",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "40",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: haoneng.value,
          },
        ],
      };

      option && myChart.setOption(option);
    }

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com