Skip to main content
100%

Force-Directed Layout with Convex Hull

✓ Published0🌍 Public
FFrissAnalytics
Last edited Oct 1, 2018
Created on Dec 8, 2016

A force-directed layout arranges 100 nodes into four groups, each distinguished by color and encircled by a semi-transparent convex hull that updates live as the nodes move under simulated forces. The D3.js code nests nodes by group using `d3.nest()`, then draws the hulls by recomputing their paths with `d3.geom.hull` during the `force.on("tick")` callback. The SVG animation also supports dragging and re-randomizing positions to demonstrate the clustering.

AI-generated description

I have modified the force-multi-foci example to add a convex hull around each cluster of nodes.

I achieved this by using d3.nest() to create a new dataset of clusters containing the nodes in each cluster. Then in the tick() method I create and update the path element for each cluster in this dataset.

forked from <a href='http://bl.ocks.org/donaldh/'>donaldh</a>'s block: <a href='http://bl.ocks.org/donaldh/2920551'>force-multi-foci with convex hulls</a>

forked from <a href='http://bl.ocks.org/newsummit/'>newsummit</a>'s block: <a href='http://bl.ocks.org/newsummit/00336c9eb59ee956426d'>force-multi-foci with convex hulls</a>

mit Licensed

Similar vizzes