made d3 chart into reusable chart