Callback that Does Its Thing on the Second Call Only

The basic issue I ran into was that I was setting off two d3 animations, and I couldn't know which one would finish first. Whichever one finished last, I wanted something else to happen.

A solution that seems to work is to have both animations call the same callback when finished, which is set via the .each("end", callback), and on the second call to the callback do the work I wanted done.

The basic idea (here) is to define a new function, which I call MakeCallCallbackOnSecondCall, like the following:

The purpose of this page is to summarize in one place some of the interactive visualizations I have worked on. Most of these were built...

"When you start on your journey to Ithaca, then pray that the road is long, full of adventure, full of knowledge... Always keep Ithaca fixed in your mind. To arrive there is your ultimate goal. But do not hurry the voyage at all." (from "Ithaca", by C. P. Cavafy)