Created
July 2, 2013 07:35
-
-
Save nsonnad/5907400 to your computer and use it in GitHub Desktop.
Multi-foci d3 force layout, based on data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
force.on("tick", function(e) { | |
// Push nodes toward their designated focus. | |
var k = .1 * e.alpha; | |
nodes.forEach(function(o, i) { | |
o.y += (foci[o.id].y - o.y) * k; | |
o.x += (foci[o.id].x - o.x) * k; | |
}); | |
vis.selectAll("circle.node") | |
.attr("cx", function(d) { return d.x; }) | |
.attr("cy", function(d) { return d.y; }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment