Skip to content

Commit

Permalink
Radius, charge and link distance based on file size
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Jan 24, 2013
1 parent 20d0463 commit 26ab775
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tpl/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ window.onload = function () {
.nodes(d3.values(assetgraph.assets))
.links(assetgraph.relations)
.size([window.innerWidth, window.innerHeight]) // Some browsers have trouble reading dimensions of svg elements
.gravity(.05)
.charge(-300)
.linkDistance(200);

.gravity(.1)
.charge(function (d) { return -40 - (d.size / 100); })
.linkDistance(function (d) {
return Math.sqrt(d.source.size / 100) +
Math.sqrt(d.target.size / 100) +
d.type.length * 8;
});

var edges = svg.append('g')
.attr('class', 'relations')
Expand Down Expand Up @@ -37,13 +40,13 @@ window.onload = function () {
.append('g');

nodes.append('circle')
.attr('r', 6)
.attr('r', function (d) { return 3 + Math.sqrt(d.size / 100); })
.attr('class', function (d) { return d.type; })
.call(force.drag);

nodes.append('text')
.attr('text-anchor', 'middle')
.attr('dy', function () { return -10; })
.attr('dy', function (d) { return -1 * (8 + Math.sqrt(d.size / 100)); })
.text(function (d) { return d.fileName; });


Expand Down

0 comments on commit 26ab775

Please sign in to comment.