Modulo:Demografia/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
ottimizzazioni al codice
Moroboshi (discussione | contributi)
colori, visualizzazione etichette
Riga 38:
-- =====================================================================
local function merge_years_population(years, populations)
local values = { }
for i =1,#populations do
values[i] = { year = years[i], population = populations[i] }
end
return values
end
 
Riga 50:
-- =====================================================================
function p._demografia(args)
-- Definizione base del grafico
local graph = {
version = 2,
Riga 115:
x = {scale = "x",field = "year"},
y = {scale = "y",field = "population"},
stroke = {value = "#fc899CCFF"},
strokeWidth = {value = 3}
}
Riga 127:
x = {scale = "x",field = "year"},
y = {scale = "y",field = "population"},
stroke = {value = "#f8080B3E6"},
fill = {value = "#fff"},
size = {value = 12}
Riga 140:
x = {scale = "x",field = "year"},
y = {scale = "y",field = "population"},
stroke = {value = "#800369"},
fill = {value = "#fff"},
size = {value = 30}
Riga 192:
local years2 = read_array(args, "b", "anni2")
graph['data'][1]['values'] = merge_years_population(years, populations)
graph['data'][2]['values'] = merge_years_population(years2, populations2)
graph['width'] = args.dimx and tonumber(args.dimx) and tonumber(args.dimx)
graph['height'] = args.dimy and tonumber(args.dimy) and tonumber(args.dimy)
if args.etichette then
local etichette = tonumber(args.etichette)
if etichette == 1 or etichette == 2 then
graph['marks'][4]['properties']['transform'] = string.format('{{ type = "filter", test: "datum._id %% 2 == %d"}}', etichette)
end
end
--if true then return mw.text.jsonEncode(graph) end
local template_text = "Censimenti dal {{datum.min_year}} al {{datum.max_year}}"
Riga 205 ⟶ 211:
end
 
-- ======================================================================================================
-- Funzione di intefaccia con template:Demografia
-- ======================================================================================================
function p.demografia(frame)
local args = getArgs(frame)