-1

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.

asked 13 hours ago
New contributor
Unit Unitovich is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

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!

answered 12 hours ago
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.