Attempt to implement d3.axis() by hand