Permalink
Browse files

Added panning and zooming

  • Loading branch information...
1 parent efd142c commit 7c625734ad583e5971330e056dbd72c0b0828aae @Munter committed Jan 24, 2013
Showing with 9 additions and 4 deletions.
  1. +9 −4 tpl/graph.js
View
@@ -19,7 +19,12 @@ window.onload = function () {
relation.distance = distance;
});
- var svg = d3.select('.graph'),
+ var graph = d3.select('.graph')
+ .attr('pointer-events', 'all')
+ .call(d3.behavior.zoom().on('zoom', function () {
+ graph.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")");
+ }))
+ .append('g'),
force = d3.layout.force()
.nodes(d3.values(assetgraph.assets))
.links(assetgraph.relations)
@@ -41,15 +46,15 @@ window.onload = function () {
return d.distance;
});
- var edges = svg.append('g')
+ var edges = graph.append('g')
.attr('class', 'relations')
.selectAll('path')
.data(force.links())
.enter()
.append('path')
.attr('id', function (d, i) { return 'p' + i; });
- var edgeLabels = svg.append('g')
+ var edgeLabels = graph.append('g')
.attr('class', 'relationLabels')
.selectAll('text')
.data(force.links()).enter()
@@ -63,7 +68,7 @@ window.onload = function () {
.attr('xlink:href', function (d, i) { return '#p' + i; })
.text(function (d) { return d.type; });
- var nodes = svg.append('g')
+ var nodes = graph.append('g')
.attr('class', 'assets')
.selectAll('g')
.data(force.nodes()).enter()

0 comments on commit 7c62573

Please sign in to comment.