Skip to main content
100%

Draggable Network

✓ Published0🌍 Public
Mmbostock
Last edited Jun 6, 2017
Created on Jan 17, 2013

A force-directed network graph displays nodes and links, drawn as SVG circles and lines, with node positions pre-set from a JSON file. This example shows how to manually adjust a static layout by making each node draggable. Using `d3.drag()`, the code updates a node’s `x` and `y` properties during the drag event and directly rewrites the corresponding circle and connected link line coordinates. The data originates from the included `graph.json` file, and the implementation relies on D3 v4’s selection and drag APIs.

AI-generated description

This example demonstrates a simple method of hand-tweaking a force-directed layout. Using d3.behavior.drag, the nodes in this network are made draggable; dragging updates the x and y properties of each node. The resulting graph could then be saved back to a JSON file using JSON.stringify.

gpl-3.0 Licensed

Similar vizzes