Diferencia entre revisiones de «Módulo:Graph»

Contenido eliminado Contenido añadido
Acualizo desde la versión alemana Modul:Graph, bajo licencia CC BY-SA 3.0
Acualizo desde la versión alemana Modul:Graph, bajo licencia CC BY-SA 3.0
Línea 3:
--
-- Version History (_PLEASE UPDATE when modifying anything_):
-- 2019-01-24 Allow comma-separated lists to contain values with commas
-- 2018-10-13 Fix browser color-inversion issues via #54595d per [[mw:Template:Graph:PageViews]]
-- 2018-09-16 Allow disabling the legend for templates
Línea 8 ⟶ 9:
-- 2018-08-26 Use user-defined order for stacked charts
-- 2018-02-11 Force usage of explicitely provided x minimum and/or maximum values, rotation of x labels
-- 2017-08-08 Added showSymbols param to show symbols on line charts
-- 2016-05-16 Added encodeTitleForPath() to help all path-based APIs graphs like pageviews
-- 2016-03-20 Allow omitted data for charts, labels for line charts with string (ordinal) scale at point location
Línea 37 ⟶ 39:
end
 
local function stringArray(csvtext)
if not csvtext then return end
 
returnlocal list = mw.text.split(csvmw.ustring.gsub(tostring(text), "%s*\\,%s*", "<COMMA>"), ",", true)
for i = 1, #list do
list[i] = mw.ustring.gsub(mw.text.trim(list[i]), "<COMMA>", ",")
end
return list
end
 
Línea 644 ⟶ 650:
return textmarks
end
end
 
local function getSymbolMarks(chartvis)
local symbolmarks =
{
type = "symbol",
properties =
{
enter =
{
x = { scale = "x", field = "x" },
y = { scale = "y", field = "y" },
fill = { scale = "color", field = "series" },
shape = "circle",
size = { value = 49 }
}
}
}
if chartvis.from then symbolmarks.from = copy(chartvis.from) end
 
return symbolmarks
end
 
Línea 671 ⟶ 698:
angle = { value = xAxisAngle },
align = { value = xAxisAlign },
fill = { value = "#54595d" }
},
ticks =
{
stroke = { value = "#54595d" }
},
axis =
{
stroke = { value = "#54595d" },
strokeWidth = { value = 2 }
}
}
else
xAxis.properties =
{
title =
{
fill = { value = "#54595d" }
},
labels =
{
fill = { value = "#54595d" }
},
Línea 769 ⟶ 817:
local xGrid = frame.args.xGrid or "0"
local yGrid = frame.args.yGrid or "0"
-- for line chart, show a symbol at each data point
local showSymbols = frame.args.showSymbols
-- show legend with given title
local legendTitle = frame.args.legend
Línea 855 ⟶ 905:
-- create chart markings
local chartvis = getChartVisualisation(chartType, stacked, colorField, #y, innerRadius, outerRadius, linewidth, alphaScale, radiusScale, interpolate)
local marks = { chartvis }
 
-- text marks
local textmarks
if showValues then
if type(showValues) == "string" then -- deserialize as table
local keyValues = mw.text.split(showValues, "%s*,%s*")
showValues = {}
for _, kv in ipairs(keyValues) do
local key, value = mw.ustring.match(kv, "^%s*(.-)%s*:%s*(.-)%s*$")
if key then showValues[key] = value end
end
end
 
local chartmarks = chartvis
if chartmarks.marks then chartmarks = chartmarks.marks[1] end
local textmarks = getTextMarks(chartmarks, chartType, outerRadius, scales, radiusScale, yType, showValues)
if chartmarks ~= chartvis then
table.insert(chartvis.marks, textmarks)
else
textmarks = nil
table.insert(marks, textmarks)
end
end
 
-- symbol marks
if chartType == "line" and showSymbols then
local chartmarks = chartvis
if chartmarks.marks then chartmarks = chartmarks.marks[1] end
local symbolmarks = getSymbolMarks(chartmarks)
if chartmarks ~= chartvis then
table.insert(chartvis.marks, symbolmarks)
else
table.insert(marks, symbolmarks)
end
end
Línea 893 ⟶ 956:
scales = scales,
axes = { xAxis, yAxis },
marks = { chartvis, textmarks }marks,
legends = { legend }
}