Permalink
Browse files

Precalculate edge lengths

  • Loading branch information...
Munter committed Jan 24, 2013
1 parent 4dce6d0 commit c51d92053a7167992b000a676c5ab6dd785f428f
Showing with 17 additions and 0 deletions.
  1. +17 −0 tpl/graph.js
View
@@ -2,6 +2,23 @@
/*jshint onevar:false*/
window.onload = function () {
+ // Fallback to show nothing. This shoudl probably be improved
+ window.assetgraph = assetgraph || {
+ assets: [],
+ relations: []
+ };
+
+ // Data preperation for simpler d3 code
+ assetgraph.relations.forEach(function (relation) {
+ var distance = 10 +
+ assetgraph.assets[relation.source].r +
+ assetgraph.assets[relation.target].r +
+ assetgraph.assets[relation.source].outgoing * 2 +
+ relation.type.length * 6;
+
+ relation.distance = distance;
+ });
+
var svg = d3.select('.graph'),
force = d3.layout.force()
.nodes(d3.values(assetgraph.assets))

0 comments on commit c51d920

Please sign in to comment.