I’m having trouble when I try to correctly execute a rotation animation using the D3.js library. The problem has to do with the point at which I want to rotate the element about.
Here is a fiddle I made to show what I mean (in slow motion): http://jsfiddle.net/74mCb/
It seems like the source of the problem lies here:
.attr("transform", "rotate(-60, 150,130)");
And then I rotate it like so:
.attr("transform", "rotate(40 150,130)");
I would like the butt of the needle to stay in position (to be the center of rotation), could someone please explain what I am doing wrong?
Thanks!
This is a bit tricky to grasp (I don’t fully understand it myself) but D3 needs some help knowing how to interpolate between the two strings that represent your rotation.
dis the datum,iis the index,ais the attribute in case you want to make this data-driven.http://jsfiddle.net/SHF2M/