Modulo:Grafico XY: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 130:
-- legge valori
local numero = 1
local dx, dy, dt, cc
local err = '-'
dt = {}
while (args['x'..numero]) do
dx = leggi(args, "x"..numero)
dy = leggi(args, "y"..numero)
if (dx and dy) then
if (#dx == #dy) then
dt[numero] = unisci(dx, dy, fattoreX, fattoreY)
else
err = 'Errore nel numero di elementi per serie '..numero
break
end
else
err = 'Errore nella serie '..numero
break
end
numero = numero+1
end
numero = numero-1
if err == '-' then
cc = i%10
if cc == 0 then cc = 10 end
graph['data'][i] = {
name = "tab"..i,
transform = { { type = "sort", by = "nx" } },
}
graph['data'][i]['values'] = dt[i]
graph['marks'][i] = {
type = "line",
from = {data = "tab"..i },
x = {scale = "x",field = "nx"},
}
}
}
graph['marks'][i+numero] = {
type = "symbol",
properties = {
}
}
graph['marks'][i+2*numero] = {
type = "text",
properties = {
}
}
graph['scales'][1]['___domain']['fields'][i] = {data = "tab"..i,field = "nx"}
graph['scales'][
graph['scales'][
-- colori
if args['colore'..i] then
graph['marks'][i+numero]['properties']['enter']['stroke']['value'] = args['colore'..i]
graph['
end
-- opzioni etichette
if args['etichette'..i] then
if args['
graph['marks'][i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 == 1"}}
elseif args['etichette'..i] == 'pari' then
graph['marks'][i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 == 0"}}
elseif args['etichette'..i] == 'no' then
graph['marks'][i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}} end
end
-- mostra dati
if args['mostra'..i] then
if args['mostra'..i] == '1' then
graph['marks'][numero+i]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
elseif args['mostra'..i] == '2' then
graph['marks'][i]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
end
-- legenda
graph['data'][numero+1] = {
name = "nomi",
local lg = 1
while (args['nome'..lg]) do
lg = lg +1
end
if args.legenda then graph['legends'][1]['orient'] = args.legenda end
table.insert(ris,'<p>'..args.didascalia..'</p>')
return mw.text.jsonEncode(graph)
else
return table.concat(ris)
end
else
return '<span style="color:red"><b>Template GraficoXY:</b> '..err..'</span>'
end
end
|