Modulo:Demografia/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 45:
end
 
-- =====================================================================
-- Crea tabella laterale
-- =====================================================================
local function mostraTabella(a,b)
local ss = {}
table.insert(ss,'</td><td><table class="wikitable"><tr><th>Anno</th><th>Abitanti</th></tr>')
for i =1,#b do
table.insert(ss,string.format('<tr><td>%s</td><td>%s</td></tr>',a[i],math.floor(b[i]+0.5)))
end
table.insert(ss,'</table></td></tr></table>')
return table.concat(ss)
end
 
-- =====================================================================
Riga 108 ⟶ 120:
marks = {
{
type = "arealine",
from = {data = "table" },
properties = {
Riga 115 ⟶ 127:
x = {scale = "x",field = "year"},
y = {scale = "y",field = "population"},
y2stroke = {scalevalue = "y#1f77b4", value = 0 },
fillstrokeWidth = {value = "#1f77b4"4},
opacity = {value = 0.5}
}
Riga 200 ⟶ 212:
graph['width'] = args.dimx and tonumber(args.dimx) and tonumber(args.dimx)
graph['height'] = args.dimy and tonumber(args.dimy) and tonumber(args.dimy)
local tabella1 = ''
local tabella2 = ''
if args.etichette then
if args.etichette == "1dispari" then
graph['marks'][4]['from']['transform'] = {{ type = "filter", test = "(datum.num > 1) && (datum.num % 2 == 1)"}}
elseif args.etichette == "2pari" then
graph['marks'][4]['from']['transform'] = {{ type = "filter", test = "(datum.num > 1) && (datum.num % 2 == 0)"}}
elseif args.etichette == "tabella" then
graph['marks'][4]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
tabella1 = '<table><tr><td>'
tabella = mostraTabella(years, population)
end
else
Riga 216 ⟶ 234:
graph['marks'][5]['properties']['enter']['text']['template'] = template_text
end
local ris = {}
return titolo .. mw.getCurrentFrame():extensionTag('graph', mw.text.jsonEncode(graph))
table.insert(ris,tabella1)
table.insert(ris,titolo)
return titolo table.. insert(ris,mw.getCurrentFrame():extensionTag('graph', mw.text.jsonEncode(graph)))
table.insert(ris,tabella2)
return table.concat(ris)
end