First step, the color coding CAN be adjusted by the length of checkbox array.
Working legend for the return periods

* the legend is dynamic and grows with the number of entries
* the colors as well ..