Modulo:Diagramma parlamentare: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Errori di Lint: Colors
mNessun oggetto della modifica
Riga 140:
altezza = (dimx+dimc)*scala
end
 
local graph = {
-- crea HTML
version = 2, width = larghezza, height = altezza, padding = "no",
agg(ss, string.format('<div style="position: relative; width: %dpx; height: %dpx; margin: 2px auto;">', larghezza, altezza))
data = { },
 
scales = {
{ name = "x", type = "linear", range = "width", zero = true, domainMin = 0, domainMax = 2*dimx },
{ name = "y", type = "linear", range = "height", zero = true, domainMin = 0, domainMax = dimx + dimc }
},
marks = { }
}
local ee = 0
local valori
for i=1,num do
valori = {}
for j=1,dati[i].n do
ee = ee + 1
pylocal px = dimc+(dimx-punti[ee][2]*math.sincos(math.pi*punti[ee][1]),) * scala
valori[j] = {
pxlocal py = dimxaltezza - (dimc+punti[ee][2]*math.cossin(math.pi*punti[ee][1]),) * scala
filllocal = {valuecolor = dati[i].c},
py = dimc+punti[ee][2]*math.sin(math.pi*punti[ee][1]),
local size = {value = (2 * dimc * scala)^2}
}
 
end
-- punti come elementi div
graph['data'][i] = { name = "tab"..i, values = valori }
agg(ss, string.format(
graph['marks'][i] = { type = "symbol", from = {data = "tab"..i },
'<div style="position: absolute; left: %.2fpx; top: %.2fpx; width: %.2fpx; height: %.2fpx; background-color: %s; border-radius: 50%%;"></div>',
properties = {
px, py, size, size, color
enter = {
}))
x = {scale = "x",field = "px"},
y = {scale = "y",field = "py"},
fill = {value = dati[i].c},
size = {value = (2*dimc*scala)^2}
}
}
}
if (dati[i].b ~= "-") then
graph['marks'][i]['properties']['enter']['stroke'] = {value = dati[i].b}
graph['marks'][i]['properties']['enter']['strokeWidth'] = {value = 1}
end
end
 
graph['marks'][num+1] = {
agg(ss, '</div>')
type = "text",
 
properties = {
-- Aggiungiamo la didascalia, se presente
enter = {
x = {scale = "x",value=dimx},
y = {scale = "y",value=dimc+8},
align = {value = "center"},
fill = {value = "#000"},
font = {value = "Helvetica"},
fontSize = { value = 36*scala },
fontWeight = { value = "bold" },
text = {value = totalepunti }
}
}
}
agg(ss, mw.getCurrentFrame():extensionTag('graph', mw.text.jsonEncode(graph)))
if (dida ~= '') then
agg(ss,string.format('<p style="font-size:90%%; margin-left:10px">%s</p>',dida))
Riga 210 ⟶ 183:
agg(ss,'</p>')
end
 
if args['debug'] then
return mwtable.text.jsonEncodeconcat(graphss)
else
return table.concat(ss)