Skip to content Skip to sidebar Skip to footer

How To Split Multiple D3 Transform Commands Into Separate Statements

I have some trouble with my zooming. I found this zooming with 2x translate and 1x zoom: g.transition() .duration(750) .attr('transform', 'translate(' + width / 2 + ','

Solution 1:

I solved it with the following - very creepy - solution. It's working well but for me it looks very ugly and is based on saving the transformation in a special variable:

var currentzoomy = d3.transform("translate(" + width / 2 + "," + height / 2 + ")scale(" + k + ")translate(" + -x + "," + -y + ")")
zoom.scale(currentzoomy.scale[0]);
zoom.translate(currentzoomy.translate);

Is that an OK solution? And maybe someone now has a better idea what my issue was about. =)

Post a Comment for "How To Split Multiple D3 Transform Commands Into Separate Statements"