Reputation: 1993
From past few days I have been googling around in D3.JS
library. Its a Great Visualization library indeed.
I have used Force Directed Graph for the representation of data of social networks. Until now its fine but all the different groups of different color are coming together.
What I want to do is to define different cluster for each node. So that same color nodes come together in one cluster.
How can I do so ?
My current Force directed graph looks like this
Upvotes: 2
Views: 788
Reputation: 1993
Finally Solved my problem with the following lines of code
function tick(e) {
// Push different nodes in different directions for clustering.
var k = 6 * e.alpha;
graph.nodes.forEach(function(o, i) {
o.y += i & 1 ? k : -k;
o.x += i & 2 ? k : -k;
});
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
}
Upvotes: 3