local p =
function colorCell(val) local cell = '\n|style="text-align:center; background-color:#' if val > 48 then cell = cell .. '000' elseif val >= 37 then cell = cell .. '602000' elseif val >= 28 then cell = cell .. '804020' elseif val >= 23 then cell = cell .. 'b06030' elseif val >= 19 then cell = cell .. 'CC5500' elseif val >= 16 then cell = cell .. 'E9692C' elseif val >= 13 then cell = cell .. 'FF8C00' elseif val >= 10 then cell = cell .. 'FFA500' elseif val >= 7 then cell = cell .. 'FCC200' elseif val >= 4 then cell = cell .. 'FFDF00' elseif val >= 1 then cell = cell .. 'FBEC5D' else cell = cell .. 'FFF' end if val >= 19 then cell = cell .. ';color:#FF0' end cell = cell .. ';"|' .. val return cellend
function noval return '\n|style="text-align:center;|—'end
function cell(val) return '\n|style="text-align:center;"|' .. valend
function redgreen(val) local temp = '\n|style="text-align:center;' if val < 0 then temp = temp .. 'background-color:#FFC7C7;"|' .. val elseif val > 0 then temp = temp .. 'background-color:#BFD;"|+' .. val else temp = temp .. '"|0' end return tempend
function p.main(frame) local args = frame:getParent.args local year = args.year local months = local refs = local restored = tonumber(args.restored) or 0 local rfas = tonumber(args.rfas) or 0 local output = '|-\n!|' .. year local counter = 0 local total = 0 for i = 1, 12 do local month = tonumber(months[i]) if month ~= nil and month >= 0 then output = output .. colorCell(month) if (refs[i] ~= nil) then local efn = frame:expandTemplate output = output .. efn end total = total + month counter = counter + 1 else output = output .. noval end end local mean = math.floor((total / counter) * 10) / 10 if counter
return p