Module:Sandbox/Frietjes/political graph: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 11:
local targs = {}
for k,v in pairs(args) do
if k:find('^y[%d]+Party$') then
local digit = mw.ustringstring.match(k, '[%d]+')
local color = isnotempty(colors[tonumber(digit)]) and colors[tonumber(digit)] or pfetch({v, 'color'})
local pname = isnotempty(args['y' .. digit .. 'Title']) and args['y' .. digit .. 'Title'] or pfetch({v, 'abbrev'})
Line 21:
end
end
targs['colors'] = mw.ustringstring.gsub(table.concat(colors, ', '), '#', '#')
 
return targs
end
 
function p.testdebug(frame)
local args = p._chart_args(frame:getParent().args)
local res = '<pre>\n{{Graph:Chart\n'
Line 37:
end
 
function p.templatemain(frame)
return mw.getCurrentFrame():expandTemplate{
title = 'Graph:Chart',
Line 44:
end
 
function p.mainmainlua(frame)
local graphgraphchart = require('Module:Graph:Chart')
local chart_argsframe.args = p._chart_args(frame:getParent().args)
return graphchart[''](frame)
frame.args = chart_args
local newFrame = {
getParent = function(self)
return frame
end,
getTitle = function(self)
return 'Template:Graph:Chart'
end,
args = {}
}
setmetatable(newFrame, {
__index = function(t, k)
if type(frame[k]) == 'function' then
return function(...)
return frame[k](frame, select(2, ...))
end
else
return frame[k]
end
end
})
 
return frame:extensionTag{ name='templatestyles', args={src='Template:Graph:Chart/styles.css'} },
frame:extensionTag('graph', graph.chartWrapper(newFrame))
end