-- this module implements [[Template:Political graph]]
local p = {}
function p.chart(args, flag)
local chartfun = require('Module:Graph').chart
local pfetch = require('Module:Political party')._fetch
local tframe = {}
tframe.args = {}
local colors = mw.text.split(args['colors'] or '', '%s*[,]%s*')
local tracking = ''
for k,v in pairs(args) do
if k:find('^y[%d]+Party$') then
if nil then
local digit = mw.ustring.match(k, '[%d]+')
local color = colors[tonumber(digit)] or pfetch({v, 'color'})
local pname = args['y' .. digit .. 'Title'] or pfetch({v, 'abbrev'})
tframe.args['y' .. digit .. 'Title'] = pname
colors[tonumber(digit)] = color
else
tframe.args[k] = v
end
else
tframe.args[k] = v
end
end
if nil then
tframe.args.colors = mw.ustring.gsub(table.concat(colors, ', '), '#', '#')
end
return chartfun(tframe)
end
function p.chartWrapper(frame)
return p.chart(frame:getParent().args, frame:getParent().args['debug'])
end
return p