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

Content deleted Content added
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 7:
 
function p._chart_args(args)
local chartfun = require('Module:Graph').chart
local pfetch = require('Module:Political party')._fetch
local colors = mw.text.split(args['colors'] or '', '%s*[,]%s*')
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 22 ⟶ 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 40 ⟶ 39:
function p.main(frame)
return mw.getCurrentFrame():expandTemplate{
title = 'Graph:Chart',
args = p._chart_args(frame:getParent().args)
}
end
 
function p.mainlua(frame)
local chartfungraphchart = require('Module:Graph:Chart').chart
frame.args = p._chart_args(frame:getParent().args)
return graphchart[''](frame)
end