Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Last active January 4, 2019 11:48
Show Gist options
  • Save LironHazan/7a5f0de0097f79d412260bf05c3dd5c3 to your computer and use it in GitHub Desktop.
Save LironHazan/7a5f0de0097f79d412260bf05c3dd5c3 to your computer and use it in GitHub Desktop.
for medium post
export const forceSimulation = (d3, {width, height}) => d3.forceSimulation()
.force("charge", d3.forceManyBody())
.force("center", d3.forceCenter(width / 2, height / 2));
// use:
const simulation = forceSimulation(d3, {width,height});
simulation.force("link",
d3.forceLink()
.id(function (d) {return d.id;})
.distance(200)
.strength(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment