I want to make a graph simulation with d3 where I can drag the nodes and move them around, but the length of the links must not be less than 300 or more than 600, how can I approach this?
Here is my simulation:
const simulation = d3
.forceSimulation(nodes)
.force("charge", d3.forceManyBody().strength(-300))
.force(
"link",
d3
.forceLink(links)
.id((d) => d.id)
.distance(300),
)
.force(
"center",
d3.forceCenter(
container.node().clientWidth / 2 - 75,
container.node().clientHeight / 2 - 75,
),
);
For now I could only set the constat length of a link.
I tried to search in the d3 documentation, but didn’t find anything, if there is alerady such a problem with described solution, I would be glad to see it.
Thank you!