Module:Television ratings graph: Difference between revisions

Content deleted Content added
Don't error on 3-digit hex colors
oops typo
 
(5 intermediate revisions by 3 users not shown)
Line 75:
-- Bar and graph width
local barwidth
if num_episodes >= 80 then barwidth = 9
elseifif num_episodes >= 50args.bar_width then barwidth = 10args.bar_width
elseif num_episodes >= 20120 then barwidth = 116
elseelseif num_episodes >= 100 then barwidth = 127
ifelseif num_episodes >= 80 then barwidth = 98
elseif num_episodes >= 50 then barwidth = 9
elseif num_episodes >= 20 then barwidth = 10
else barwidth = 11
end
 
local graphwidth = num_episodes*barwidth
-- Determine maximum viewer figure
local maxviewers = -1
Line 100 ⟶ 102:
end
end
local graphwidthis_singular = num_episodes*barwidth == 1
 
-- Basis parameters
timeline = timeline .. "\nImageSize = width:" .. (is_singular and 200 or 'auto') .. " height:"..(args.height or 500).. (is_singular and '' or " barincrement:"..(barwidth+(num_episodes == 2 and 16 or 4))).."\n"
timeline = timeline .. "\nPlotArea = left:50 bottom:50 top:10 right:100\n"
timeline = timeline .. "\nAlignbars = justify\n"
Line 121 ⟶ 125:
rgbG = tonumber("0x"..hex:sub(3,4))/256
rgbB = tonumber("0x"..hex:sub(5,6))/256
local legend = season_title.."_"..(args["legend" .. season] and args["legend" .. season] or season )
timeline = timeline .. "\n id:season"..season.." value:rgb("..rgbR..", "..rgbG..", "..rgbB..") legend:Season_"..seasonlegend:gsub(" ", "_").."\n"
end
timeline = timeline .. "\n id:bars value:gray(0.95)"
Line 129 ⟶ 134:
timeline = timeline .. "\nScaleMajor = unit:year increment:"..(multiple == 'thousands' and 100 or 1).." start:0\n"
timeline = timeline .. "\nScaleMinor = unit:year increment:"..(multiple == 'thousands' and 100 or 1).." start:0\n"
 
local x_intervals = args.x_intervals or (num_episodes >= 80 and 2 or 1)
 
timeline = timeline .. "\nBarData=\n"
for episode = 1,num_episodes do
timelineepisodetext = timeline((episode ..% "\nx_intervals bar:"..episode.."== 0) and text:"..episode.. or "\n")
timeline = timeline .. "\n bar:"..episode.." text:"..episodetext.."\n"
end
Line 271 ⟶ 280:
row:tag('th')
:css('background-color', args['color' .. season])
:css('width','10px14px')
:css('padding','0')
row:tag('th')