Populate json for charts via query