js data manipulation for d3 compatability