What you need are not 31 but 93 donut segments, one of each color for the 31 days. For each triad, the data value will be 1 for the desired color and 0 for the other two, so the sum of all 93 points will be 31. The points with value 1 will appear, those with value 0 will not appear. It takes a whole lot of formulas to set these values to 0 or 1, based on the desired colors for the days.
I should write it up on my blog.