Modulo:Diagramma parlamentare: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m modulo no globals obsoleto
legenda: uso codice generato da t:Box colorato e t:,
 
(5 versioni intermedie di 2 utenti non mostrate)
Riga 140:
altezza = (dimx+dimc)*scala
end
 
local graph = {
-- crea HTML
version = 2, width = larghezza, height = altezza, padding = "no",
agg(ss,mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Template:Diagramma parlamentare/styles.css' } })
data = { },
agg(ss, string.format('<div class="diaPar" style="width: %dpx; height: %dpx">', larghezza, altezza))
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
local size = {value = (2 * dimc * scala)^2}
valori[j] = {
local px = (dimx-punti[ee][2]*math.cos(math.pi*punti[ee][1]),) * scala - size/2
local py = altezza - (dimc+punti[ee][2]*math.sin(math.pi*punti[ee][1]),) * scala - size/2
filllocal = {valuecolor = dati[i].c},
}
 
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="left: %.2fpx; top: %.2fpx; width: %.2fpx; height: %.2fpx; background-color: %s"></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 197 ⟶ 171:
if mostra == 1 then
for i=1,num do
agg(ss2,string.format('<span style="display:inline-block;border:1px solid grey 1px; background-color:%s; color:black; width:1em; height:1em">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;%s', dati[i].c, dati[i].n))
end
agg(ss,'<p style="font-size:90%; margin-left:10px">')
agg(ss,table.concat(ss2," <b>&nbsp;· &nbsp;</b>"))
agg(ss,'</p>')
elseif mostra ==2 then
for i=1,num do
agg(ss2,string.format('<span style="display:inline-block;border:1px solid grey 1px; background-color:%s; color:black; width:1em; height:1em">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;%s %s', dati[i].c, dati[i].p, dati[i].n))
end
agg(ss,'<p style="font-size:90%; margin-left:10px">')
Riga 210 ⟶ 184:
agg(ss,'</p>')
end
 
if args['debug'] then
return mwtable.text.jsonEncodeconcat(graphss)
else
return table.concat(ss)