move d3 code into main.js