0

我使用 Antv/G6 创建了一个图表,这个图表有工具提示。它工作正常。但是,如果我销毁并重新创建图表(参见下面的代码),图表会重新显示,但工具提示不再显示。任何想法都将不胜感激,因为我目前不知所措。

    if (endpointsGraphCreated) {
            endpointsGraph.destroy();
          }
          endpointsGraph = new G6.Graph(endpointConfiguration); // ERROR
          endpointsGraphCreated = true;
    
          // This element must be mounted before creating the graph
          const data = { nodes: gNodes, edges: gEdges.slice(0) };
          // endpointsGraph.data(data);
          endpointsGraph.read(data); // combines data and render
    }
4

1 回答 1

0

我在滥用destroy()。我应该改用 clear() 并确保不重新创建图表。以下按预期工作:

      if (endpointsGraphCreated) {
        // removes all nodes and edges. Leaves configuration intact
        endpointsGraph.clear();
      } else {
        endpointsGraph = new G6.Graph(endpointConfiguration); // ERROR
        endpointsGraphCreated = true;
      }
于 2021-12-10T14:30:45.733 回答