Module:Flugvallar tölfræði
Hægt er að búa til leiðbeiningar fyrir þessa skriftu á Module:Flugvallar tölfræði/doc
local p = {}
function p._main(frame)
local pframe = frame:getParent()
return p.main(pframe)
end
function p.main(frame)
local args = frame.args
local item = nil
if args[2] and mw.wikibase.entityExists( args[2] ) then
item = args[2]
else
item = mw.wikibase.getEntityIdForCurrentPage()
end
local statementMax = 0
local lined = {}
local i = 10
local k = 0
if item and mw.wikibase.getAllStatements(item, "P3872")[1] then
local AllStat = mw.wikibase.getAllStatements(item, "P3872")
local debut = (args['début'] or args['upphafsár'])
if debut == nil then
debut = 0
end
while AllStat[i] ~= nil do
if AllStat[i].mainsnak.datavalue
and AllStat[i].references and AllStat[i].references[1] and AllStat[i].qualifiers['P585'] then
local Bstat = AllStat[i]
local statement = Bstat.mainsnak.datavalue.value.amount
local qualifier = nil
if mw.wikibase.entityExists( 'P585' ) and Bstat.qualifiers['P585'][1] and
Bstat.qualifiers['P585'][1].datavalue and
tonumber(mw.language.getContentLanguage():formatDate("Y", Bstat.qualifiers['P585'][1].datavalue.value.time)) > debut then
qualifier = mw.language.getContentLanguage():formatDate((args.timeformat or "Y"),
Bstat.qualifiers['P585'][1].datavalue.value.time)
if statement and Bstat.qualifiers['P585'][1].datavalue.value.precision == 9 then
statement = statement + 0
table.insert(lined, ' bar:' .. qualifier .. ' from:start till:' .. statement .. '\n')
if statementMax < statement then
statementMax = statement
end
end
end
else
break
end
if i == 30 then
break
end
i = i + 1
end
end
local state10 = math.modf(math.log10(statementMax))
local inc = math.pow(10, state10 - 2)*1
local Eztimeline = [[
ImageSize = width:600 height:405
PlotArea = left:50 bottom:20 top:10 right:10
TimeAxis = orientation:vertical
AlignBars = justify
TextData =
pos:(70,380) textcolor:black fontsize:M
text:Farþegafjöldi
]]
local period = 'Period = from:' .. inc .. ' till:' .. statementMax
local sm = 'ScaleMajor=increment:' .. inc .. ' start:' .. statementMax
local EzPlot = [[
PlotData =
color:red width:20
]]
if statementMax > 0 then -- not show graphs which are improperly sourced.
return frame:extensionTag('timeline', Eztimeline .. period .. '\n' .. sm .. EzPlot .. table.concat(lined, ''))
else
return ''
end
end
return p