A detailed description of this example can be found at emptypipes.org/2017/04/29/d3v4-selectable-zoomable-force-directed-graph/.
In summary:
Upgrading selectable zoomable force directed graph implementation to D3 v4 required a few minor and not-so-minor changes.
d3-brush
and modified it
so that it doesn't capture the shift events. The new version (d3-brush-lite)
can be found on github. There
is an open github issue to
disable this behavior in d3-brush
..fx
and .fy
parameters. This
eliminates the need to set the .fixed
parameter on each node.forked from pkerpedjiev's block: D3v4 Selectable, Draggable, Zoomable Force Directed Graph
xxxxxxxxxx
<head>
<meta charset="utf-8" />
</head>
<div align='center' id="d3_selectable_force_directed_graph" style="width: 960px; height: 500px; margin: auto; margin-bottom: 12px">
<svg />
</div>
<link rel='stylesheet' href='d3v4-selectable-zoomable-force-directed-graph.css'>
<script src="https://d3js.org/d3.v4.js"></script>
<script src="d3v4-brush-lite.js"></script>
<script src="d3v4-selectable-force-directed-graph.js"></script>
<script>
var svg = d3.select('#d3_selectable_force_directed_graph');
d3.json('miserables.with-ids.json', function(error, graph) {
if (!error) {
//console.log('graph', graph);
createV4SelectableForceDirectedGraph(svg, graph);
} else {
console.error(error);
}
});
</script>
https://d3js.org/d3.v4.js