Skip to main content
100%

Looping a transition in v7

✓ Published0🌍 Public
Dd3noob
Last edited Jun 19, 2021
Created on Jun 19, 2021

This example demonstrates a looping transition animation in d3.js v7. A single steel-blue circle moves horizontally across an SVG canvas, traveling from the left edge to the right and back again. The animation uses the `d3.transition` API, chaining two successive `.transition()` calls with a duration of 2000 milliseconds each. Upon completing the return trip, an `.on("end", repeat)` callback triggers the entire sequence to start over, creating an infinite loop. The circle’s position is set via the `cx` and `cy` attributes.

AI-generated description

This is a demonstration of looping transition chaining using d3.js v7.

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 7 of d3.js.

mit Licensed

Similar vizzes