Modulo:Grafico XY: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m fix errore legenda
Nessun oggetto della modifica
Riga 8:
flex['ultimo'] = {'<div style="flex-grow:0;flex-shrink:0;flex-basis:auto;padding: 0 2em 0 0">','</div></div>'}
flex['destra'] = {'<div class="floatright">','</div>'}
 
local clr = { "#1f77b4","#ff7f0e","#2ca02c2","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf" }
 
-- =====================================================================
Riga 43 ⟶ 45:
height = 250,
padding = "auto",
data = { },
{
name = "tab",
transform = { { type = "sort", by = "nx" } },
values = { }
},
{
name = "tab2",
transform = { { type = "sort", by = "nx" } },
values = { }
},
{
name = "tab3",
transform = { { type = "sort", by = "nx" } },
values = { }
},
{
name = "nomi",
values = { }
}
},
scales = {
{
Riga 84 ⟶ 66:
type = "ordinal",
___domain = { data = "nomi", field = "testo"},
range = { "#1f77b4", "b80000", "#00c000" }
}
},
Riga 110 ⟶ 92:
orient = "top-left",
offset = 8,
shape = {value = "square"},
strokeWidth = 0
}
},
marks = { }
{
type = "line",
from = {data = "tab" },
properties = {
enter = {
interpolate = {value = "linear"},
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "#1f77b4"},
strokeWidth = {value = 4},
opacity = {value = 0.5}
}
}
},
{
type = "line",
from = {data = "tab2" },
properties = {
enter = {
interpolate = {value = "linear"},
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "#b80000"},
strokeWidth = {value = 4},
opacity = {value = 0.5}
}
}
},
{
type = "line",
from = {data = "tab3" },
properties = {
enter = {
interpolate = {value = "linear"},
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "#00c000"},
strokeWidth = {value = 4},
opacity = {value = 0.5}
}
}
},
{
type = "symbol",
from = {data = "tab"},
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "1f77b4"},
fill = {value = "#fff"},
size = {value = 30}
}
}
},
{
type = "symbol",
from = {data = "tab2"},
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "#b80000"},
fill = {value = "#fff"},
size = {value = 30}
}
}
},
{
type = "symbol",
from = {data = "tab3"},
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = "#00c000"},
fill = {value = "#fff"},
size = {value = 30}
}
}
},
{
type = "text",
from = { data = "tab" },
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny", offset = -6},
align = {value = "center"},
fill = {value = "#000"},
text = {field = "ny" }
}
}
},
{
type = "text",
from = { data = "tab2" },
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny", offset = -6},
align = {value = "center"},
fill = {value = "#000"},
text = {field = "ny" }
}
}
},
{
type = "text",
from = { data = "tab3" },
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny", offset = -6},
align = {value = "center"},
fill = {value = "#000"},
text = {field = "ny" }
}
}
}
}
}
-- titoli assi
Riga 262 ⟶ 123:
if (args.zeroX and args.zeroX == 's') then graph['scales'][1]['zero'] = true end
if (args.zeroY and args.zeroY == 'n') then graph['scales'][2]['zero'] = false end
 
-- legge valori
local dx1 = leggi(args, "x1")
local dy1 = leggi(args, "y1")
local dx2 = leggi(args, "x2")
local dy2 = leggi(args, "y2")
local dx3 = leggi(args, "x3")
local dy3 = leggi(args, "y3")
graph['data'][1]['values'] = unisci(dx1, dy1, fattoreX, fattoreY)
graph['data'][2]['values'] = unisci(dx2, dy2, fattoreX, fattoreY)
graph['data'][3]['values'] = unisci(dx3, dy3, fattoreX, fattoreY)
-- dimensioni
graph['width'] = args.dimx and tonumber(args.dimx) and tonumber(args.dimx) or 350
graph['height'] = args.dimy and tonumber(args.dimy) and tonumber(args.dimy) or 250
 
-- colori
-- legge valori
if args.colore1 then
local numero = 1
graph['marks'][1]['properties']['enter']['stroke']['value'] = args.colore1
while (args['x'..n]) do numero = numero+1 end
graph['marks'][4]['properties']['enter']['stroke']['value'] = args.colore1
numero = numero-1
graph['scales'][3]['range'][1] = args.colore1
end
local dx
if args.colore2 then
local dy
graph['marks'][2]['properties']['enter']['stroke']['value'] = args.colore2
for i = 1,numero do
graph['marks'][5]['properties']['enter']['stroke']['value'] = args.colore2
graph['scalesdata'][3]['range'][2i] = args.colore2{
name = "tab"..i,
end
transform = { { type = "sort", by = "nx" } },
if args.colore3 then
}
graph['marks'][3]['properties']['enter']['stroke']['value'] = args.colore3
dx = leggi(args, "x"..i)
graph['marks'][6]['properties']['enter']['stroke']['value'] = args.colore3
dy = leggi(args, "y"..i)
graph['scales'][3]['range'][3] = args.colore3
graph['data'][i]['values'] = unisci(dx, dy, fattoreX, fattoreY)
end
 
-- opzioni etichette
graph['marks'][i] = {
if args.etichette1 then
type = "line",
if args.etichette1 == 'dispari' then
graph['marks'][7]['from']['transform'] = {{ typedata = "filtertab", test = "datum.num.i % 2 == 1"}},
properties = {
elseif args.etichette1 == 'pari' then
enter = {
graph['marks'][7]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 == 0"}}
interpolate = {value = "linear"},
elseif args.etichette1 == 'no' then
graph['marks'][7]['from']['transform'] x = {{ typescale = "filterx", testfield = "datum.num < 1nx"}},
y = {scale = "y",field = "ny"},
stroke = {value = clr[i%10+1] },
strokeWidth = {value = 4},
opacity = {value = 0.5}
}
}
}
graph['marks'][i+numero] = {
type = "symbol",
from = {data = "tab"..i },
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny"},
stroke = {value = clr[i%10+1] },
fill = {value = "#fff"},
size = {value = 30}
}
}
}
graph['marks'][i+2*numero] = {
type = "text",
from = { data = "tab"..i },
properties = {
enter = {
x = {scale = "x",field = "nx"},
y = {scale = "y",field = "ny", offset = -8},
align = {value = "center"},
fill = {value = "#000"},
text = {field = "ny" }
}
}
}
graph['scales'][3]['range'][i] = clr[i%10+1]
-- colori
if args['colore'..i] then
graph['marks'][i]['properties']['enter']['stroke']['value'] = args['colore'..i]
graph['marks'][i+numero]['properties']['enter']['stroke']['value'] = args['colore'..i]
graph['scales'][3]['range'][i] = args['colore'..i]
end
-- opzioni etichette
end
if args['etichette'.mostra1.i] then
if args['etichette'..mostra1i] == '1dispari' then
graph['marks'][4i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num <% 2 == 1"}}
elseif args['etichette'..mostra1i] == '2pari' then
graph['marks'][1i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num <% 12 == 0"}}
elseif args['etichette'..i] == 'no' then
graph['marks'][i+2*numero]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
-- mostra dati
end
if args['mostra'.etichette2.i] then
if args['mostra'..etichette2i] == 'dispari1' then
graph['marks'][8numero+i]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 ==< 1"}}
elseif args['mostra'..etichette2i] == 'pari2' then
graph['marks'][8i]['from']['transform'] = {{ type = "filter", test = "datum.num %< 2 == 01"}}
end
elseif args.etichette2 == 'no' then
graph['marks'][8]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
if args.mostra2 then
if args.mostra2 == '1' then
graph['marks'][5]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
elseif args.mostra2 == '2' then
graph['marks'][2]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
if args.etichette3 then
if args.etichette3 == 'dispari' then
graph['marks'][9]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 == 1"}}
elseif args.etichette3 == 'pari' then
graph['marks'][9]['from']['transform'] = {{ type = "filter", test = "datum.num % 2 == 0"}}
elseif args.etichette3 == 'no' then
graph['marks'][9]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
if args.mostra3 then
if args.mostra3 == '1' then
graph['marks'][6]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
elseif args.mostra3 == '2' then
graph['marks'][3]['from']['transform'] = {{ type = "filter", test = "datum.num < 1"}}
end
end
-- legenda
graph['data'][numero+1] = {
if args.nome1 then
name = "nomi",
graph['data'][4]['values'][1] = { testo = args.nome1 }
values = { }
if args.nome2 then
}
graph['data'][4]['values'][2] = { testo = args.nome2 }
local lg = 1
if args.nome3 then graph['data'][4]['values'][3] = { testo = args.nome3 } end
while (args['nome'..lg]) do
end
graph['data'][numero+1]['values'][lg] = { testo = args['nome'..i] }
lg = lg +1
end
if args.legenda then graph['legends'][1]['orient'] = args.legenda end