Skip to main content
100%

Fork of New template

✓ Published1🌍 Public
Vvenigallajaanu@gmail.com
Last edited Feb 22, 2025
Created on Feb 22, 2025
Forked from New template

This example shows an interactive truck built from SVG shapes: a red body, blue cabin, white window, yellow headlight, and two black wheels. Clicking the truck triggers a two-second animation that translates it to the right, and the wheels rotate 720 degrees around their centers. The code uses D3.js v7 to select the SVG container, append shape elements, and animate the truck’s movement and wheel spinning with a transition and `attrTween`.

AI-generated description

D3.js Animated Truck

This project creates a simple truck using D3.js. The truck moves when clicked, and the wheels rotate.

🚀 Features:

Click the truck to make it move forward.

  • Wheels spin while the truck moves.
  • Built using D3.js and SVG elements.

🛠️ How to Run:

Open index.html in a browser. 2. Click the truck to see the animation!

🎨 Components:

    Truck Body* (red rectangle)

  • Cabin (blue rectangle)
  • Windows (white rectangle)
  • Headlights (yellow circle)
  • Wheels (black circles that rotate)

Enjoy! 🚚✨

MIT Licensed

Similar vizzes