Note: (Similar to question here D3.js Set initial zoom level. However their answer is for v3, and the v4 answer in the comment doesn't work.)
I'm trying to setup initial pan/zoom of a d3 animation. As per the answer above, I've setup my SVG zoom with the appropriate translations.
var svg = d3.select("#chart").append("svg")
.on("touchmove mousemove", moved)
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.call(zoom)
.append ("g")
.attr("transform","translate(400,200) scale(.4,.4)");
svg.call(zoom.transform, d3.zoomIdentity.translate(400, 200).scale(0.4))
.call(zoom);
The graph loads fine as intended. However, the initial zooming action breaks the translation/scale, going back to the zoom identity. I have reviewed the docs and numerous zoom examples, but can't pin down this d3 V4 behavior.
Does anyone know what is going on? Feels like a bug.