Looping a transition in v5
This example demonstrates a looping transition in which a steelblue circle travels from the left side of an SVG canvas to the right and back again, repeating indefinitely. It shows how to chain two sequential transitions on the same element by using the `transition` API from d3-transition, with the `.duration()` method controlling the 2000-millisecond timing for each leg. The circle’s position is set with `.attr('cx', ...)` and `.attr('cy', ...)`, and the `on("end", repeat)` callback restarts the entire sequence, creating seamless motion across the 960×500 viewport.
AI-generated descriptionThis is a demonstration of looping transition chaining using d3.js v5.
The circle moves from left to right and then back again so that it starts and ends in the same state and then we instruct the transition code to repeat itself.
This graph is part of the code samples for the update to the book D3 Tips and Tricks to version 5 of d3.js.