I use vis. How do I make it so that when clicking on a link with a parameter, I get to a specific node, while it is highlighted, scaled and centered on the screen.
for example, the link yourpage.html?NodeID=4 go to id node 4 like this.
This code makes the node in focus but does not center it on the screen:
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
const nodeId = getQueryParam('nodeId');
if (nodeId) {
network.selectNodes([parseInt(nodeId)]);
network.focus(parseInt(nodeId), {animation: true});
}
I need a working code example.
1 Answer 1
You simply need to fix your code by adding a scale: 2.0 setting inside your focus options to make the camera zoom in close, and make sure to select that node ID so it glows, because otherwise your node is just sitting there lonely in the middle of a very faraway map!
Comments
Explore related questions
See similar questions with these tags.