Modulo:Grafico XY: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
m modulo no globals obsoleto
 
(22 versioni intermedie di un altro utente non mostrate)
Riga 1:
require("Module:No globalsstrict")
 
local getArgs = require('Module:Arguments').getArgs
local p = {}
Riga 29 ⟶ 30:
local function unisci(a,b,c,d)
local values = { }
local t
for i =1,#b do
t = string.format("%g",math.floor(10*b[i]/d+0.5)/10)
values[i] = { nx = a[i]/c, ny = b[i]/d, num = i }
t = t:gsub('%.',',')
values[i] = { nx = a[i]/c, ny = b[i]/d, num = i, txt = t }
end
return values
Riga 80 ⟶ 84:
scale = "x",
title = "",
format = args['formatoX'] or "d",
labelOverlap = "greedy",
grid = true,
properties = {
labels = { font = { value = "Helvetica" } },
title = { font = { value = "Helvetica" } },
}
},
{
Riga 88 ⟶ 97:
title = "",
grid = true,
format = args['formatoY'] or "d",
layerlabelOverlap = "backgreedy",
layer = "back",
properties = {
labels = { font = { value = "Helvetica" } },
title = { font = { value = "Helvetica" } },
}
}
},
Riga 99 ⟶ 113:
offset = 8,
properties = {
labels = { font = { value = "Helvetica" }, fontSize = { value = 12 } },
symbols = {
strokeWidth = { value = 0 },
shape = { value = "square" },
opacity = { value = 0.37 }
},
legend = { fill = { value = "#fff" } }
}
},
Riga 112 ⟶ 128:
offset = 8,
properties = {
labels = { font = { value = "Helvetica" }, fontSize = { value = 12 } },
symbols = {
strokeWidth = { value = 0 },
Riga 139 ⟶ 156:
}
-- titoli assi
local titoloX = args.titoloX or 'X'
local fattoreX = args.fattoreX and tonumber(args.fattoreX) and tonumber(args.fattoreX) or 1
if fattoreX == 0 then
Riga 149 ⟶ 166:
end
graph['axes'][1]['title'] = titoloX
local titoloY = args.titoloY or 'Y'
local fattoreY = args.fattoreY and tonumber(args.fattoreY) and tonumber(args.fattoreY) or 1
if fattoreY == 0 then
Riga 237 ⟶ 254:
align = {value = "center"},
fill = {value = "#000"},
textfont = {fieldvalue = "nyHelvetica" },
fontSize = { value = 12 },
text = {field = "txt" }
}
}
Riga 269 ⟶ 288:
end
end
 
-- legenda
graph['data'][numero+1] = {
Riga 290 ⟶ 310:
graph['data'][numero+2]['values'][lg] = { testo = args['area'..lg], x1 = args['area'..lg..'_x1'], x2 = args['area'..lg..'_x2'] }
graph['scales'][4]['range'][lg] = args['area'..lg..'_colore'] or clr[lg]
graph['scales'][1]['___domain']['fields'][numero+2*lg-1] = {data = "area",field = "x1"}
graph['scales'][1]['___domain']['fields'][numero+2*lg] = {data = "area",field = "x2"}
lg = lg +1
end
if args.area_legenda then graph['legends'][2]['orient'] = args.area_legenda end
 
if (args.minimoX and tonumber(args.minimoX)) then
graph['scales'][1]['domainMin'] = tonumber(args.minimoX)
end
if (args.massimoX and tonumber(args.massimoX)) then
graph['scales'][1]['domainMax'] = tonumber(args.massimoX)
end
 
if (args.minimoY and tonumber(args.minimoY)) then
graph['scales'][2]['domainMin'] = tonumber(args.minimoY)
end
if (args.massimoY and tonumber(args.massimoY)) then
graph['scales'][2]['domainMax'] = tonumber(args.massimoY)
end
 
local ris = {}
Riga 299 ⟶ 335:
table.insert(ris,mw.getCurrentFrame():extensionTag('graph', mw.text.jsonEncode(graph)))
if (args.didascalia) then
table.insert(ris,'<p style="font-size:90%;margin-left:30px">'..args.didascalia..'</p>')
end
if (flex[allinea]) then table.insert(ris,flex[allinea][2]) end
Riga 313 ⟶ 349:
 
-- ======================================================================================================
-- Funzione di intefaccia con template:DemografiaGrafico XY
-- ======================================================================================================
function p.grafico(frame)