Module:Graph: Difference between revisions

Content deleted Content added
m Undid revision 925239569 by Tom.Reding (talk) Attempt to sync to [https://de.wikipedia.org/wiki/Modul:Graph] first
Sync to de:Modul:Graph (2019-01-24 Allow comma-separated lists to contain values with commas), except local (en) WorldMap file
Line 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
Line 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-09 Add showSymbols param to show symbols on line charts
-- 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
Line 15:
 
local p = {}
 
local baseMapDirectory = "Module:Graph/"
 
local function numericArray(csv)
Line 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
 
Line 57 ⟶ 63:
function p.map(frame)
-- map path data for geographic objects
local basemap = frame.args.basemap or "Template:Graph:Map/Inner/Worldmap2c-json" -- de uses "WorldMap-iso2.json" in Module:Graph/
-- scaling factor
local scale = tonumber(frame.args.scale) or 100
Line 726 ⟶ 732:
}
end
 
if yType == "integer" and not yAxisFormat then yAxisFormat = "d" end
yAxis =
Line 788 ⟶ 794:
local interpolate = frame.args.interpolate
-- mark colors (if no colors are given, the default 10 color palette is used)
local colorscolorString = stringArray(frame.args.colors)
if colorString then colorString = string.lower(colorString) end
local colors = stringArray(colorString)
-- for line charts, the thickness of the line; for pie charts the gap between each slice
local linewidth = tonumber(frame.args.linewidth)
Line 969 ⟶ 977:
-- This function is critical for any graph that uses path-based APIs, e.g. PageViews graph
function p.encodeTitleForPath(frame)
return mw.uri.encode(mw.text.decode(mw.text.trim(frame.args[1]) ), 'PATH')
end