Module:Television ratings graph: Difference between revisions

Content deleted Content added
Reverted to revision 784403696 by AlexTheWhovian (talk). (TW)
m again testing
Line 98:
-- Determine maximum viewer figure
local maxviewers = -1
local multiple = 'millions'
for k,v in pairs(args) do
local num = tonumber(v)
if tonumber(k) ~= nil and num ~= nil and num > maxviewers then
maxviewers = num
end
end
if maxviewers <= 1.5 then
local multiple = 'thousands'
maxviewers = maxviewers*1000
for k, v in pairs(args) do
local num = tonumber(v)
if tonumber(k) ~= nil and num ~= nil then args[k] = tostring(num*1000) end
end
end
Line 109 ⟶ 118:
timeline = timeline .. "Period = from:0 till:" .. math.ceil(maxviewers) .. "\n"
timeline = timeline .. "TimeAxis = orientation:vertical\n"
timeline = timeline .. "ScaleMajor = gridcolor:a increment:1" .. 10^math.ceil(math.log10(maxviewers)-math.log10(15)) .. " start:0\n"
timeline = timeline .. "Legend = orientation:horizontal\n"
Line 170 ⟶ 179:
timeline = timeline .. "TextData =\n"
timeline = timeline .. " pos:(" .. ((args.width or 1000)/2-18) .. ",45) textcolor:black fontsize:S text:Episode\n"
timeline = timeline .. " pos:(10," .. ((args.height or 300)-10) .. ") textcolor:black fontsize:S text:" .. (args.country or "") .. (args.country and " v" or "V") .. "iewers (millions' .. multiple .. ')\n"
-- Add timeline to div
Line 186 ⟶ 195:
if args.title ~= nil and args.title ~= '' then
rtable:tag('caption'):wikitext("''" .. args.title .. "''" .. frame:expandTemplate{ title = 'hsp' } ..
": " .. (args.country or "") .. (args.country and " v" or "V") .. "iewers per episode (millions' .. multiple .. ')")
else
rtable:tag('caption'):wikitext("Viewers per episode (millions' .. multiple .. ')")
end