Modulo:Graph: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
fix
m correggo
 
(6 versioni intermedie di uno stesso utente non sono mostrate)
Riga 31:
if #errors > 0 then
local out = string.format('<strong class="error">%s</strong>', table.concat(errors, "; "))
if nocat or not cfg.uncategorized_namespaces[mw.title.getCurrentTitle().nsnsText] then
out = out .. '[[Category:' .. cfg.errors_category .. ']]'
end
Riga 414:
stats =
{
name = "aggregatestats", source = "chart", transform = {
{
{ type = "facetaggregate", keys = { "x" } },
{ type summarize = "aggregate",{ valuey = "ysum" },
groupby = { "x" }
{}
}
}
Line 449 ⟶ 451:
if args.yMin or args.yMax then yscale.clamp = true end
if args.is_stacked then
yscale.___domain = { data = "aggregatestats", field = "sumsum_y" }
else
yscale.___domain = { data = "chart", field = "y" }
end
-- Color scale
local colorScale = {
name = "color",
type = "ordinal",
range = args.colors },
___domain = { data = "chart", field = "series" }
}
local alphaScale
if args.alphas then alphaScale = { name = "transparency", graph_type = "ordinal", range = args.alphas } end
-- Symbols scale
local symbolsScale
if type(args.symbols) == 'table' then
if args.symbols then symbolsScale = { name = "symbolssymShape", type = "ordinal", range = args.symbols, ___domain = { data = "chart", field = "series" } end}
end
-- for bar charts with multiple series: each series is grouped by the x value, therefore the series need their own scale within each x group
local groupScale
Line 497 ⟶ 506:
if args.is_stacked then
-- for stacked charts this lower bound is cumulative/stacking
marks.properties.enter.y2 = { scale = "y", field = "y2layout_end" }
else
--[[
Line 520 ⟶ 529:
if args.graph_type == "line" then marks.properties.enter.strokeWidth = { value = args.stroke_thickness } end
-- stacked charts have their own (stacked) y values
if args.is_stacked then marks.properties.enter.y.field = "ylayout_start" end
-- set interpolation mode
if args.interpolate then marks.properties.enter.interpolate = { value = args.interpolate } end
Line 529 ⟶ 538:
from = { data = "chart" },
properties = {
enter = {
update x = { strokescale = {"x", scalefield = "colorx"} },
{
xy = { scale = "xy", field = "xy" },
yshape = { scale = "ysymShape", field = "yseries" },
shapestroke = { scale = "symbolscolor", field = "series" },
},
update = { stroke = { scale = "color"} }
}
}
if args.symbol_size then symbolsMarks.properties.enter.size = { value = args.symbol_size } end
if alphaScale then
symbolsMarks.properties.update.strokeenter.fillOpacity = { scale = "transparency", field = "series" }
symbolsMarks.properties.enter.strokeOpacity = { scale = "transparency", field = "series" }
end
end
if #args.y == 1 then
Line 552 ⟶ 564:
if symbolsScale then
symbolsMarks.properties.enter.shape.field = "series"
symbolsMarks.properties.update.stroke.field = "series"
end
if alphaScale then marks.properties.update[colorField .. "Opacity"].field = "series" end
Line 575 ⟶ 586:
-- for stacked charts apply a stacking transformation
if args.is_stacked then
table.insert(marks.from.transform[2] = { type = "stack", point = "x"1, height = "y" }{
field = "y",
type = "stack",
sortby = { "-_id" },
groupby = { "x" }
})
else
-- for bar charts the series are side-by-side grouped by x
if args.graph_type == "rect" then
marks.from.transform[1].keysgroupby = "x"
marks.scales = { groupScale }
marks.properties = { enter = { x = { field = "key", scale = "x" }, width = { scale = "x", band = true } } }
Line 657 ⟶ 673:
-- is not to use symbol.
if chart_arg.graph_type == "line" and not args:is_no('symbols') then
chart_arg.symbols = stringArray(args:value('symbols')) or cfg.default.symbol)
chart_arg.symbol_size = args:number('symbolSize', cfg.default.symbol_size)
end
Line 742 ⟶ 758:
end
local chart = frame:extensionTag('graph', chart_json)
local align = args[cfg.localization.:value('thumb]')
return wrap_graph(chart, external_legend, align, chart_arg.graphwidth) .. errors_output(args:value('NoTracking'))
end
Line 761 ⟶ 777:
___domain = { data = "highlights", field = "v" },
range = args.colorScale,
nice = true,
zero = false
}
}