Revision 23983045 of "Modul:Testmodul/Lavallen/start" on svwikip = {}
function p.diagram(frame)
local pFrame = frame:getParent()
local args = pFrame.args
local text = ''
local namn = args.namn or frame.args.namn
local max = -math.huge
local note = args['ref'] or ''
local noter = {}
local fotnot = args.fotnot or ''
if namn == nil or namn == ''then
return 'Inget namn är angivet'
end
local fran = tonumber(args.fran) or 1800
local fran2 = math.huge
local till2 = -math.huge
local till = tonumber(args.till) or tonumber(os.date("%Y"))
local step = 1
local areakolumn = nil -- variabel för att avgöra om en kolumn för area behövs
local fkr = nil -- variabel för att avgöra om "före Kristus" behöver markeras
if args.fkr then
fkr = 'fkr'
end
if till < fran then
step = -1
end
local reffarna = ''
local notraknare = 1
for i = fran, till, step do
local pu = 'inv' .. i
if tonumber(args[pu]) then
local pv = 'area' .. i
if args[pv] then
areakolumn = ''
end
if tonumber(args[pu]) > max then
max = tonumber(args[pu])
end
if i > till2 then
till2 = i
end
if i < fran2 then
fran2 = i
end
if i < 0 then
fkr = 'fkr'
end
local pw = 'typ' .. i
if args[pw] then
reffarna = 'A'
if args[pw] == 'småort' then
args[pw] = 'som småort'
end
if args[pw] == 'tätort' then
args[pw] = 'som tätort'
end
if noter[args[pw]] == nil then
notraknare = notraknare + 1
noter[args[pw]] = 'Not'..tostring(notraknare)
end
end
end
end
if tonumber(args.max) then
max = tonumber(args.max)
end
text = 'Befolkningsutvecklingen i ' .. namn
if fran2 == till2 then
text = text .. ' ' .. fran2 .. note
else
text = text .. ' ' .. fran2 .. ' – ' .. till2 .. note
end
text = mw.text.tag('big', {}, text)
text = mw.text.tag('th', {colspan="5"}, text)
text = mw.text.tag('tr', {style="background:#DDD;"}, text)
text = text .. mw.text.tag('tr', {}, mw.text.tag('td', {colspan="5", style="padding:4px"}, ''))
local h1 = mw.text.tag('td', {style="padding:0 4px", valign="top"}, 'År')
h1 = h1 .. mw.text.tag('td', {style="padding:0 4px;", align="right", valign="top"}, '')
h1 = h1 .. mw.text.tag('td', {style="width:525px"}, '')
h1 = h1 .. mw.text.tag('td', {style="padding:0 4px;width:5em", align="right", valign="top"}, 'Folkmängd')
if areakolumn then
areaenhet = args.areaenhet or '([[hektar|ha]])'
h1 = h1 .. mw.text.tag('td', {style="padding:0 4px;", align="right", valign="top"}, 'Areal '.. areaenhet)
end
text = text .. mw.text.tag('tr', {style="font-size:88%;"}, h1)
local color = args.color or '#B0C4DE'
for i = fran, till, step do
local pu = 'inv' .. i
if tonumber(args[pu]) then
local h4 = math.floor(480*tonumber(args[pu]/max)) .. ''
local h7 = math.abs(i) .. ''
if fkr then
if i < 0 then
h7 = h7 .. ' f. Kr.'
else
h7 = h7 .. ' e. Kr.'
end
end
local h8 = 'color' .. i
if args[h8] then
color = args[h8]
end
local h9 = 'typ' .. i
local color2 = color
local lokalnot = ''
if args[h9] == 'småort' then
color2 = '#d0e0f5'
elseif args[h9] == 'tätort' then
color2 = '#B0C4DE'
end
local h2 = mw.text.tag('td', {colspan="2", style="padding-right:0.4em; padding-left:0.4em"}, h7)
local h3 = mw.text.tag('div', {style="margin-top:0; margin-bottom:0; background:"..color2.."; height:10px; width:"..h4.."px; overflow:hidden"}, '  ')
h2 = h2 .. mw.text.tag('td', {style="border-left:solid 1px silver;border-right:solid 1px silver;"}, h3)
local content = args[pu]
if areakolumn == nil then
content = content .. lokalnot
end
h2 = h2 .. mw.text.tag('td', {style="min-width:3em;padding-left:0.4em", align="right"}, content)
if areakolumn then
local h5 = 'area' .. i
local h6 = args[h5] or ''
h2 = h2 .. mw.text.tag('td', {style="min-width:3em;padding-left:0.4em", align="right"}, h6 .. lokalnot)
end
text = text .. mw.text.tag('tr', {}, h2)
end
end
if reffarna ~= '' then
text = text + frame:extensionTag{ name = 'references', args = { group = 'N' } }
end
text = mw.text.tag('table', {cellspacing="0", cellpadding="0", style="clear:none;float:none;border:silver solid 1px; font-size:90%; padding:0.4em;margin:0.4em;width:650px"}, text)
return text
end
return pAll content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://sv.wikipedia.org/w/index.php?oldid=23983045.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|