Fit Force Directed Graph in a viewpoint

I’m using this force directed graph from: < and some nodes appear off-screen. I’d like to be able to zoom out to see all the nodes. Please help if you know a solution!
(Or if you can make everything fit in the view point, it’ll also work!)

please share (or publish “unlisted”) the notebook?

@Fil sorry, I just publish it.

you can adjust the forces like so:

//create a simulation for an array of nodes, and compose the desired forces.
simulation = d3.forceSimulation()
    .force("link", d3.forceLink() // This force provides links between nodes
                    .id(d => // This sets the node id accessor to the specified function. If not specified, will default to the index of a node.
    .force("charge", d3.forceManyBody().strength(-15)) // This adds repulsion (if it's negative) between nodes. 
    .force("center", d3.forceCenter(width / 2, height / 2)); // This force attracts nodes to the center of the svg area

works perfectly! Thank you :slight_smile: