Module:Television ratings graph: Difference between revisions

Content deleted Content added
Typo
oops typo
 
(7 intermediate revisions by 4 users not shown)
Line 35:
args = args or {}
local categories = ''
local title = mw.title.getCurrentTitle()
-- Variables
Line 74 ⟶ 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 99 ⟶ 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 113 ⟶ 118:
args["color" .. season] = args["color" .. season] or '#CCCCFF'
hex = args["color" .. season]:gsub("#","")
if #hex == 3 then
-- If it's 3 hex chars then make it six instead
hex = hex:sub(1,1) .. hex:sub(1,1) .. hex:sub(2,2) .. hex:sub(2,2) .. hex:sub(3,3) .. hex:sub(3,3)
end
rgbR = tonumber("0x"..hex:sub(1,2))/256
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 124 ⟶ 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 185 ⟶ 199:
if num_episodes > 100 then
root:tag('div'):wikitext("Too many episodes to display graph (maximum 100).")
if title.namespace == 0 then
categories = categories .. '[[Category:Articles using Template:Television ratings graph with excessive figures]]'
end
else
timelineBase = frame:preprocess("<timeline>"..timeline.."</timeline>")
Line 264 ⟶ 280:
row:tag('th')
:css('background-color', args['color' .. season])
:css('width','10px14px')
:css('padding','0')
row:tag('th')