Modulo:Demografia/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
Nessun oggetto della modifica
Moroboshi (discussione | contributi)
Nessun oggetto della modifica
Riga 44:
{ type = "sort", by = "year" }
},
values = { }
}
},
Riga 53:
range = "width",
zero = false,
___domain = { fields = { {data = " table", field = "year"}, { data = "table2", field = "year"} } }
},
{
Riga 60:
range = "height",
nice = true,
___domain = { fields = { {data = "table", field = "population"}, {data = "table2", field = "population"} } }
}
},
axes = {
{
{ type = "x", scale = "x", format = "d", title = "Anno", grid = true, },
type = "x",
{ type = "y", scale = "y", title = "Abitanti", grid = true, layer ="back" }
scale = "x",
format = "d",
title = "Anno",
grid = true,
},
{
type = "y",
scale = "y",
title = "Abitanti",
grid = true,
layer = "back"
}
},
marks = {
Riga 73 ⟶ 85:
properties = {
enter = {
interpolate = { value = "linear"},
x = { scale = "x", field = "year"},
y = { scale = "y", field = "population"},
stroke ={ {value = "#fc8"},
strokeWidth = { value = 3}
}
}
Riga 83 ⟶ 95:
{
type = "symbol",
from = { data = "table2" },
properties = {
enter = {
x = { scale = "x", field = "year"},
y = { scale = "y", field = "population"},
stroke ={ {value = "#f80"},
fill ={ {value = "#fff"},
size ={ {value = 12}
}
}
Riga 96 ⟶ 108:
{
type = "symbol",
from = { data = "table"},
properties = {
enter = {
x = { scale = "x", field = "year"},
y = { scale = "y", field = "population"},
stroke = { value = "#800"},
fill = { value = "#fff"},
size = { value = 30}
}
}
Riga 112 ⟶ 124:
properties = {
enter = {
x = { scale = "x", field = "year"},
y = { scale = "y", field = "population", offset = -8},
align = { value = "center" },
fill = { value = "#000"},
text = { field = "population" }
}
}
Riga 127 ⟶ 139:
{
type = "aggregate",
summarize = { year = {"min","max"} }
}
}
},
properties = {
enter = {
x = { signal = "width", mult = 0.5},
y = { value = -10},
text = {
template = ""
template = "Censimenti dal \u007b{datum.min_year}\u007d al \u007b{datum.max_year}\u007d {{#if:{{{b1|}}}|e dati annuali}}"
},
fill = {value = "black"},
fontSize = {value = 16},
align = {value = "center"},
fontWeight = { value = "bold"}
}
}
Riga 156 ⟶ 168:
local values1 = { }
for i =1,#populations do
values1[i] = { year = years[i], population = populations[i] }
end
graph['data'][1]['values'] = values1
local values2 = { }
for i =1,#populations2 do
values2[i] = { year = years2[i], population = populations2[i] }
end
graph['data'][2]['values'] = values2
localif width = tonumber(args.dimx) then
if width then graph['local width'] = width endtonumber(args.dimx)
if heightwidth then graph['heightwidth'] = heightwidth end
local height = tonumber(args.dimy)
end
if height then graph['height'] = height end
if args.dimy then
local height = tonumber(args.dimy)
if height then graph['height'] = height end
end
--if true then return mw.text.jsonEncode(graph) end
local templatetemplate_text = "Censimenti dal \u007b{{datum.min_year}\u007d} al \u007b{{datum.max_year}\u007d {{#if:{{{b1|}}}|e dati annuali}}"
if #values2 > 0 then
graph['marks'][5]['properties']['enter']['text']['template'] = template_text .. " e dati annuali"
else
graph['marks'][5]['properties']['enter']['text']['template'] = template_text
end
return titolo .. mw.getCurrentFrame():extensionTag('graph', mw.text.jsonEncode(graph))
end