Could u add the feature to zoom in the graph?
nelvintan opened this issue · comments
Nelvin Tan commented
Thank you for the graph, I have around 500+ nodes and would like to zoom in the graph. I tried using advice from this but it did not work... :(
Nelvin Tan commented
Sorry for the trouble I figured it out.
Just add this few blocks of code and zooming in/out works:
var svg = d3.select("#svg-body")
.append("svg:svg")
.attr("width", 800)
.attr("height", 600)
.attr("pointer-events", "all")
.append('svg:g')
.call(d3.behavior.zoom().on("zoom", redraw))
.append('svg:g');
function redraw() {
console.log("here", d3.event.translate, d3.event.scale);
svg.attr("transform",
"translate(" + d3.event.translate + ")"
+ " scale(" + d3.event.scale + ")");
}