At the time of the click, you do not have the d3.event set, because no events occur from d3, so you need to specify the scaling / translation parameters
function zoomClicked(translate, scale) {
d3.select(".svg-container").attr("transform", "translate(" + translate + ")scale(" + scale + ")");
}
$(document).ready(function() {
$("#zoom").click(function() {
zoomClicked(4, 4);
});
});
source
share