Refer to this code. You can specify distance using distance() function. If you need dynamic distance then instead of hard coded value, call a function which shall return distance.

this.force = d3.forceSimulation() .force(‘link’, d3.forceLink().id((d: any) => d.id).distance(150)) .force(‘charge’, d3.forceManyBody().strength(-500)) .force(‘x’, d3.forceX(this.width / 2)) .force(‘y’, d3.forceY(this.height / 2)) .on(‘tick’, () => this.tick());

Cloud Solution Architect | Author | Full Stack Developer | https://www.linkedin.com/in/balram-chavan | https://www.hiretheauthor.com/balramchavan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store