aggregate function for use with chartkick