Animated textPath
This example animates a blue arc expanding while the text “Hello, curved textPath!” follows its path. The code uses d3.svg.arc with interpolated angles and a transition.attrTween on the path’s “d” attribute. Two WebKit workarounds are shown: selecting textPath by class and repeatedly resetting its xlink:href attribute to force redraw. The SVG includes a path and textPath element, with the text appearing scrunched at the start due to the technique’s limitations.
AI-generated descriptionThis example demonstrates how to animate a path and a textPath at the same time. I wouldn’t use this technique—the text is scrunched up at the beginning of the arc at the beginning of the animation. Instead, I would use the arc to clip the text, so that the text is revealed as the arc expands.
This example also demonstrates two unfortunate bugs in WebKit browsers:
You can’t select textPath elements because of a bug in how WebKit handles case-sensitive element names. See bug 83438. WebKit shows no sign of fixing this bug, unfortunately.
Updating a path element by itself does not trigger redraw on dependent elements that reference this path. So, even though we update the path, the referencing textPath element will not be redrawn. To workaround this update bug, we create a custom transition that repeatedly sets the textPath’s xlink:href attribute to “#path”.