Clipping when zooming does not work

In this notebook, I plot the chapters of Gibbon’s masterpiece as rectangles representing the period they describe, and their number of pages. Hovering the mouse over displays the chapter details. For more precision I added a zoom function. My problem is that I cannot clip the chart inside the axes: If I uncomment the line that does the clipping(.attr("clip-path…), the whole chart disappears.

I’ve sent you a suggestion. The problem was mainly because the update code was doing a svg.selectAll(“rect”).remove() which was removing the rect inside the clipPath too.

Great. Thank you!

François