Various functions useful in d3.js