Module:Stat

local p = {};

function p.bar( frame ) local title  = frame.args[1];                -- which bar to generate local value  = tonumber( frame.args[2] );    -- value of the bar local divisor = 7;                           -- 7 or 10 level column local bits   = "";                           -- generated cells -- width of the generated bar local width = value > 7 and 220 or 154; -- function to repeat a string -- s is the string to be repeated -- n is the amount of times local function times( s, n ) return n > 0 and s .. times( s, n-1 ) or "" end; if ( value > 7 ) then divisor = 10; end -- allocate room for padding width = divisor == 7 and width - ( 7 * 2 ) or width - ( 10 * 2 ); -- HTML for a cell local bit = ""; return "" .. times( bit, value ) .. ""; end

return p;