Now fully commented with my limited understanding of D3 and SVG