Fork of https://gist.github.com/mbostock/4063269