Reputation: 63
I create a graph using Antv/G6, and this graph has tooltips. It works properly. However, if I destroy and recreate the graph (see code below), the graph redisplays, but the tooltips are no longer displaying. Any idea would be greatly appreciated as I am currently at a loss for ideas.
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
}
Upvotes: 0
Views: 498
Reputation: 63
I was misusing destroy(). I should be using clear() instead and make sure to not recreate the graph. The following works as expected:
if (endpointsGraphCreated) {
// removes all nodes and edges. Leaves configuration intact
endpointsGraph.clear();
} else {
endpointsGraph = new G6.Graph(endpointConfiguration); // ERROR
endpointsGraphCreated = true;
}
Upvotes: 1