unhardcoded the legend and made it automated through d3.