2022-11-17

How to detect a node in one graph being dragged over another?

Drawing node/edge graphs in Vis.js-network, I want to have two graphs graphDrag and graphStatic: where the user can drag the nodes of graphDrag around the canvas, while graphStatic remains fixed in place, so that the user can attach the graphDrag nodes to the nodes of graphStatic; the idea is for the user to be able to check whether graphStatic is a subgraph of graphDrag.

I didn't see anything in the Vis.js documentation about listening for an event where one node gets dragged onto another, or sticking nodes to each other. I know that I can do my own event handling by checking for overlap between the screen positions of graphDrag and graphStatic nodes, and then presumably changing the fixed property of the graphDrag node when they overlap, but I'm hoping that this functionality already exists somewhere. Is this possible in Vis.js, or is there a different graph visualization SDK that would be more appropriate?



No comments:

Post a Comment