convert raw api data to format suitable for charting