Skip to main content
100%

D3 Selectable Force-Directed Graph

✓ Published0🌍 Public
FFrissAnalytics
Last edited May 31, 2018
Created on May 31, 2018

This interactive D3 visualization demonstrates a force-directed network graph where nodes can be repositioned through dragging. Users can select multiple nodes using shift-click or by drawing a selection rectangle, enabling simultaneous movement of grouped nodes. The graph renders as an SVG using d3.forceSimulation, with selection semantics similar to window managers: clicking a node selects it exclusively, while shift-clicking toggles individual nodes. The implementation includes a zooming behavior via a custom d3.svg.brush for rectangular selection and a zoomer for scaling and panning the entire graph.

AI-generated description

This is an extension of Mike Bostock's Draggable Network II example, allowing one to drag multiple nodes in a force-directed graph. Nodes can be selected by holding the shift key and either dragging on the canvas or clicking on specific nodes. The selection and dragging semantics aim to mirror those of most window managers:

  1. Shift clicking on a node toggles whether it is selected
  2. Clicking (without shift) on a node, selects it and deselects everything else.
  3. Shift dragging on the canvas toggles the selection status of the nodes enclosed within it.
  4. Dragging a set of selected nodes drags all of them.
  5. Clicking on the canvas de-selects everything.

forked from <a href='http://bl.ocks.org/pkerpedjiev/'>pkerpedjiev</a>'s block: <a href='http://bl.ocks.org/pkerpedjiev/0389e39fad95e1cf29ce'>D3 Selectable Force-Directed Graph</a>

mit Licensed

Similar vizzes