-- this module implements [[Template:Political graph]]
local p = {}
function p.chart(frame, args)
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
local digit = mw.ustring.match(k, '[%d]+')
-- local color = colors[tonumber(digit)] or pfetch({v, 'color'})
local pname = args['y' .. tonumber(digit) .. 'Title'] or pfetch({v, 'abbrev'})
tframe.args['y' .. tonumber(digit) .. 'Title'] = tostring(pname)
tracking = tracking .. '<br>' .. pname
-- colors[tonumber(digit)] = color
tframe.args[k] = v
else
tframe.args[k] = v
end
end
-- tframe.args.colors = mw.ustring.gsub(table.concat(colors, ', '), '#', '#')
return chartfun(tframe)
end
function p.chartWrapper(frame)
return p.chart(frame, frame:getParent().args)
end
return p