After spending a considerable amount of time grappling with this issue, I find myself stuck. My objective is to construct a d3 collapsible tree, but every time I attempt to zoom in, the tree shifts to position 0,0. I've come across other queries like d3.behavior.zoom jitters, shakes, jumps, and bounces when dragging that seem to address a similar problem, but I'm struggling to implement those solutions in my particular case.
My suspicion is that this particular segment of code might be at the root of the issue, yet I'm uncertain how to modify it for the zooming function to work correctly.
d3.select('g').transition()
.duration(duration)
.attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")")
zoomListener.scale(scale);
For reference, here is the code I am currently working with: https://jsfiddle.net/ramo2600/y79r5dyk/11/