Hi Micro - sorry but have been very busy. And now I can't see your code.
From what I remember you had about 7 groupings that seemed quite straight forward to calculate. I wouldn't know if it was possible without looking at your data model, but could you calculate which group each value belonged to on load? You could then sum up by that group to get the numbers and use a mapping for the background colours.