Part 5: Controls and events

In the last example, we used window.interval to call the redraw function. Let's use some more sophisticated data, and a control to call redraw.

Handling events on SVG elements

Just like with HTML controls, we can attach events to any elements we add to our SVG. Try hovering your cursor over the circles below. Also, check out the docs on event handling.

Play with the code

Some suggestions:

  • ".on" is a d3 wrapper around the standard Web API addEventListener method. What other events could you try handling?