Add grouping capability to timechart func