First, you need to bind the scaling behavior to the SVG object. In addition, you can call the zoom function of the zoom object.
var zoom = d3.behavior.zoom() .scaleExtent([0.5, 4]) .on('zoom', onzoom); //svgElement is an actual element such as a rect or text or group svgElement.call(zoom); // later on zoom.scale(2); zoom.event(svgElement);
Bret
source share