Skip to main content
100%

Bounded Force Layout - very tightly packed

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Jun 26, 2016
Created on Oct 1, 2015

This example demonstrates a bounded force-directed graph layout using D3.js. Nodes from the Les Misérables co-occurrence dataset are tightly packed within a rectangular boundary, constrained by updating their cx and cy attributes to stay within the [radius, width - radius] and [radius, height - radius] ranges. The force simulation continuously repositions nodes while enforcing these bounds, resulting in a dense, space-filling arrangement. Node colors encode community groups, and links represent character co-occurrences, creating a compact, legible network visualization in SVG.

AI-generated description

This D3 version 3 example shows how to constrain the position of nodes within the rectangular bounds of the containing SVG element. As a side-effect of updating the node's "cx" and "cy" attributes, we update the node positions to be within the range [radius, width - radius] for x, [radius, height - radius] for y. If you prefer, you could use the each operator to do this as a separate step, rather than as a side-effect of setting attributes.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/1129492'>Bounded Force Layout</a>

Similar vizzes