Modulo:Sandbox/moroboshi2: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
test lettura anno
Moroboshi (discussione | contributi)
r
Riga 4:
local getArgs = require('Module:Arguments').getArgs
 
local function read_array(raw_data)
--if truenot(raw_data) then return graph_json{} end
local list = mw.text.split(raw_data, ",")
local year_sdata = {}
for _,s in ipairs(list) do
data[#data+1] = s
}end
return data
end
 
 
function p.demograph(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local raw_populationspopulations = mWikidata._getProperty({'P1082', from=args[1], rank='normal'}, true)
local raw_yearyears = read_array(mWikidata._getQualifier({'P1082', 'P585', from=args[1], rank='normal'}, true) )
--if #populations ~= #years then return "Dati da wikidata non congruenti" end
local populations = {}
if true then
local year_s = {}
forlocal itemp =1, #raw_populations do{}
for i = 1, year_s[#raw_populations-i+1]populations = raw_year[i]do
temp[i] = (years[i] or '') .. ': ' .. tostring(populations[i]) .. '<br/>'
populations[#raw_populations-i+1] = raw_populations[i]
end
return table.concat(temp)
if true then return mw.text.jsonEncode(raw_year, mw.text.JSON_PRETTY) .. "<br/>" .. mw.text.jsonEncode(year_s, mw.text.JSON_PRETTY) end
end
local graph_args = {
if true then return mw.text.jsonEncode(raw_yearpopulations, mw.text.JSON_PRETTY) .. "<br/>" .. mw.text.jsonEncode(year_s, mw.text.JSON_PRETTY) end
ygrid = true,
for i = 1, local math.floor(#populations/2) = {}do
xtitle = 'anni',
local ytitle j= 'popolazione',#populations-i+1
years[i], yyears[j] = {years[j], populations },years[i]
populations[i], populations[j] = populations[j], populations[i]
x = { year_s },
graph_type = 'rect',
seriesTitles = {'Popolazione'},
colors = {'#4682B4'}
}
local graph_json = mChart.chart_json(graph_args)
--if true then return graph_json end
return frame:extensionTag('graph', graph_json)
end
local graph_args = {
ygrid = true,
xtitle = 'anni',
ytitle = 'popolazione',
y = { populations },
x = { year_syears },
graph_type = 'rect',
seriesTitles = {'Popolazione'},
colors = {'#4682B4'}
}
local graph_json = mChart.chart_json(graph_args)
--if true then return graph_json end
return frame:extensionTag('graph', graph_json)
end
 
return p