3
votes

I've implemented zoom on force-directed graph

svg.call(d3.behavior.zoom().on("zoom", rescale))


function rescale() {
        var trans = d3.event.translate;
        var scale = d3.event.scale;

        svg.attr("transform",
            "translate(" + trans + ")"
                + " scale(" + scale + ")");
    }

Graph can be zoomed in either using mouse wheel or double click on it. I need some advice how to implement zooming out without using mouse wheel.

2

2 Answers

3
votes

Shift-double click should zoom out.

0
votes

If you are on a trackpad-equipped Mac, the zooming gestures are actually the Mac scrolling gestures: Scrolling up with two fingers zooms in, scrolling down with two fingers zooms out - Assuming that the Scroll direction in the Preferences is set to unnatural.