Transform rotate direction

43 views
Skip to first unread message

Whitney Dunn

unread,
May 22, 2013, 6:27:34 PM5/22/13
to d3...@googlegroups.com
I am using transform rotate on a line pointer on a dial with a 270 degree arc.

            pointer.transition()
.duration(3000)
                .ease('linear')
.attr('transform', 'rotate(' +newAngle +')');

The problem is that the pointer will take the shortest path to the newAngle value.  Sometimes that is outside the arc of the dial.  Anyway to force the transform rotate to travel in a certain direction?

Mike Bostock

unread,
May 22, 2013, 6:36:02 PM5/22/13
to d3...@googlegroups.com
Yes, use attrTween:


Mike

marc fawzi

unread,
May 22, 2013, 6:55:12 PM5/22/13
to d3...@googlegroups.com
 The magic sauce there comes from d3.interpolateString :)  Very powerful in that it keeps your transitions within the D3 model, as opposed to doing stuff with CSS3 transitions 



--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John Delacour

unread,
May 22, 2013, 7:01:20 PM5/22/13
to d3...@googlegroups.com
On 22/5/13 at 23:27, dunn.w...@gmail.com (Whitney Dunn) wrote:

>...Anyway to force the transform rotate to travel in a certain
>direction?

On 22/5/13 at 23:36, mi...@ocks.org (Mike Bostock) wrote:

>Yes, use attrTween...

You might like to look at this beginner's solution as well,
where an element is rotated 360° at two different speeds using attrTween:

<http://bl.ocks.org/JohnDelacour/5588283>

JD

Whitney Dunn

unread,
May 22, 2013, 7:44:50 PM5/22/13
to d3...@googlegroups.com, mi...@ocks.org
Thanks for all the help.  Got it working.
Reply all
Reply to author
Forward
0 new messages