refactored how chart data was formatted
refactored query builder and get_chart_data function