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

Content deleted Content added
No edit summary
No edit summary
 
(38 intermediate revisions by the same user not shown)
Line 2:
local p = {}
 
local function p.chartisnotempty(frame, flags)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
local chartfun = require('Module:Graph').chart
end
 
function p._chart_args(args)
local pfetch = require('Module:Political party')._fetch
local tframe = {}
tframe.args = {}
local colors = mw.text.split(args['colors'] or '', '%s*[,]%s*')
local trackingtargs = ''{}
for k,v in pairs(args) do
if k:find('^y[%d]+Party$') then
local digit = mw.ustringstring.match(k, '[%d]+')
if nil then
local color = isnotempty(colors[tonumber(digit)]) and colors[tonumber(digit)] or pfetch({v, 'color'})
local digit = mw.ustring.match(k, '[%d]+')
local colorpname = colors[tonumberisnotempty(args['y' .. digit .. 'Title']) and args['y' .. digit .. 'Title'] or pfetch({v, 'colorabbrev'})
local pname = argstargs['y' .. digit .. 'Title'] or= pfetch({v, 'abbrev'})pname
tframe.argscolors['y' .. tonumber(digit .. 'Title')] = pnamecolor
colors[tonumber(digit)] = color
else
tframe.args[k] = v
end
else
tframe.argstargs[k] = v
end
end
tframe.args. targs['colors'] = mw.ustringstring.gsub(table.concat(colors, ', '), '#', '#')
if nil then
 
tframe.args.colors = mw.ustring.gsub(table.concat(colors, ', '), '#', '#')
return targs
end
 
function p.debug(frame)
local args = p._chart_args(frame:getParent().args)
local res = '<pre>\n{{Graph:Chart\n'
for k,v in pairs(args) do
res = res .. '| ' .. k .. ' = ' .. v .. '\n'
end
res = res .. '}}\n</pre>'
return chartfun(tframe)
return res
end
 
function p.main(frame)
return mw.getCurrentFrame():expandTemplate{
title = 'Graph:Chart',
args = p._chart_args(frame:getParent().args)
}
end
 
function p.chartWrappermainlua(frame)
local chartfungraphchart = require('Module:Graph:Chart').chart
return p.chart(frame:getParent().args, frame:getParent().args['debug'])
frame.args = p._chart_args(frame:getParent().args)
return graphchart[''](frame)
end