<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.osolia.xyz/index.php?action=history&amp;feed=atom&amp;title=Module%3ASeats_diagram</id>
	<title>Module:Seats diagram - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.osolia.xyz/index.php?action=history&amp;feed=atom&amp;title=Module%3ASeats_diagram"/>
	<link rel="alternate" type="text/html" href="https://wiki.osolia.xyz/index.php?title=Module:Seats_diagram&amp;action=history"/>
	<updated>2026-04-25T23:01:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.osolia.xyz/index.php?title=Module:Seats_diagram&amp;diff=440&amp;oldid=prev</id>
		<title>Hydrogen: Created page with &quot;require(&#039;strict&#039;) local p = {} local getArgs = require(&#039;Module:Arguments&#039;).getArgs local errorCategory = &#039;Category:Compilation error of the Seats diagram template&#039;  -- get the party color from Module:Party color -- a = party; b = optional color -- (copied from Module:Parliament_diagram) local function color(a,b) 	local c = &#039;#CCC&#039; 	if (b) then 		c = b 	else 		c = &quot;FFF&quot; 	end 	if string.sub(c,1,5) == &#039;&amp;#35;&#039; then c = &quot;#&quot; .. string.sub(c, 6, 11) end 	return c end  local...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.osolia.xyz/index.php?title=Module:Seats_diagram&amp;diff=440&amp;oldid=prev"/>
		<updated>2024-06-18T19:20:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require(&amp;#039;strict&amp;#039;) local p = {} local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs local errorCategory = &amp;#039;&lt;a href=&quot;/index.php?title=Category:Compilation_error_of_the_Seats_diagram_template&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Compilation error of the Seats diagram template (page does not exist)&quot;&gt;Category:Compilation error of the Seats diagram template&lt;/a&gt;&amp;#039;  -- get the party color from Module:Party color -- a = party; b = optional color -- (copied from Module:Parliament_diagram) local function color(a,b) 	local c = &amp;#039;#CCC&amp;#039; 	if (b) then 		c = b 	else 		c = &amp;quot;FFF&amp;quot; 	end 	if string.sub(c,1,5) == &amp;#039;#&amp;#039; then c = &amp;quot;#&amp;quot; .. string.sub(c, 6, 11) end 	return c end  local...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local errorCategory = &amp;#039;[[Category:Compilation error of the Seats diagram template]]&amp;#039;&lt;br /&gt;
&lt;br /&gt;
-- get the party color from Module:Party color&lt;br /&gt;
-- a = party; b = optional color&lt;br /&gt;
-- (copied from Module:Parliament_diagram)&lt;br /&gt;
local function color(a,b)&lt;br /&gt;
	local c = &amp;#039;#CCC&amp;#039;&lt;br /&gt;
	if (b) then&lt;br /&gt;
		c = b&lt;br /&gt;
	else&lt;br /&gt;
		c = &amp;quot;FFF&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if string.sub(c,1,5) == &amp;#039;&amp;amp;#35;&amp;#039; then c = &amp;quot;#&amp;quot; .. string.sub(c, 6, 11) end&lt;br /&gt;
	return c&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function partyShortLink(p)&lt;br /&gt;
	return p&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function getData(args)&lt;br /&gt;
	local totalSeats = 0&lt;br /&gt;
	local data = {}&lt;br /&gt;
	local num = 1&lt;br /&gt;
	&lt;br /&gt;
	while (args[&amp;#039;n&amp;#039;..num]) do&lt;br /&gt;
		if (tonumber(args[&amp;#039;n&amp;#039;..num])) then&lt;br /&gt;
			data[num] = {&lt;br /&gt;
				n = args[&amp;#039;n&amp;#039;..num] and tonumber(args[&amp;#039;n&amp;#039;..num]),&lt;br /&gt;
				c = color(args[&amp;#039;p&amp;#039;..num] or &amp;#039;&amp;#039;, args[&amp;#039;c&amp;#039;..num]),&lt;br /&gt;
				b = args[&amp;#039;b&amp;#039;..num] or &amp;#039;-&amp;#039;,&lt;br /&gt;
				p = args[&amp;#039;p&amp;#039;..num] or &amp;#039;Serie &amp;#039;..num&lt;br /&gt;
			}&lt;br /&gt;
			totalSeats = totalSeats + data[num].n&lt;br /&gt;
			num = num+1&lt;br /&gt;
		else&lt;br /&gt;
			error(string.format(&amp;#039;Invalid value for n%d&amp;#039;, num),2)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	data[&amp;#039;totalSeats&amp;#039;] = totalSeats&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function generateDiagram(root, args, data)&lt;br /&gt;
	local totalSeats = 0&lt;br /&gt;
	local width = args.width or 240&lt;br /&gt;
	local range = root&lt;br /&gt;
	&lt;br /&gt;
	local lastRotation = 0&lt;br /&gt;
	&lt;br /&gt;
	for i, v in ipairs(data) do&lt;br /&gt;
		&lt;br /&gt;
		if v.n &amp;gt; 0 then&lt;br /&gt;
			range = range:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;transform&amp;#039;, &amp;#039;rotate(&amp;#039;..tostring(180 * lastRotation)..&amp;#039;deg)&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;width&amp;#039;, tostring(width)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;height&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;position&amp;#039;, &amp;#039;relative&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;transform-origin&amp;#039;, &amp;#039;bottom center&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;border-top-left-radius&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;border-top-right-radius&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			range:css(&amp;#039;background&amp;#039;, v.c)&lt;br /&gt;
			&lt;br /&gt;
			range:tag(&amp;#039;div&amp;#039;) -- seats number&lt;br /&gt;
			     :css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;width&amp;#039;, tostring(width)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;height&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;position&amp;#039;, &amp;#039;absolute&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;transform&amp;#039;, &amp;#039;rotate(&amp;#039;..tostring(-90 + 180 * (v.n/data.totalSeats/2))..&amp;#039;deg)&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;transform-origin&amp;#039;, &amp;#039;bottom center&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;top&amp;#039;, &amp;#039;-15px&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;line-height&amp;#039;, &amp;#039;15px&amp;#039;)&lt;br /&gt;
			     :css(&amp;#039;padding-bottom&amp;#039;, &amp;#039;15px&amp;#039;)&lt;br /&gt;
			     :wikitext(tostring(v.n))&lt;br /&gt;
			     :done()&lt;br /&gt;
			&lt;br /&gt;
			lastRotation = v.n/data.totalSeats&lt;br /&gt;
		&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	root:tag(&amp;#039;div&amp;#039;) --inner circle&lt;br /&gt;
	    :css(&amp;#039;width&amp;#039;, tostring(width*3/8)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;height&amp;#039;, tostring(width*3/8)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;margin&amp;#039;, tostring(-width*3/16)..&amp;#039;px auto&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;border-radius&amp;#039;, tostring(width*3/16)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;transform&amp;#039;, &amp;#039;translate(0,0)&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;background&amp;#039;, args.background)&lt;br /&gt;
	    :done()&lt;br /&gt;
	    :tag(&amp;#039;div&amp;#039;) --cover below&lt;br /&gt;
	    :css(&amp;#039;width&amp;#039;, tostring(width+1)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;height&amp;#039;, tostring(width*3/8)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;transform&amp;#039;, &amp;#039;translate(0,0)&amp;#039;)&lt;br /&gt;
	    :css(&amp;#039;background&amp;#039;, args.background)&lt;br /&gt;
	    :done()&lt;br /&gt;
	&lt;br /&gt;
	return root&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function generateCaption(root, args, data)&lt;br /&gt;
	&lt;br /&gt;
	local list = root:tag(&amp;#039;ul&amp;#039;)&lt;br /&gt;
	list:css(&amp;#039;column-count&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
	list:css(&amp;#039;margin-left&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	for i, v in ipairs(data) do&lt;br /&gt;
		list:tag(&amp;#039;li&amp;#039;) --li&lt;br /&gt;
			:css(&amp;#039;list-style-type&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;list-style-image&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;margin&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
				:tag(&amp;#039;span&amp;#039;) --span&lt;br /&gt;
				:css(&amp;#039;border&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;width&amp;#039;, &amp;#039;1.2em&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;height&amp;#039;, &amp;#039;1.2em&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background-color&amp;#039;, v.c)&lt;br /&gt;
				:css(&amp;#039;margin-right&amp;#039;, &amp;#039;0.3em&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;vertical-align&amp;#039;, &amp;#039;middle&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;display&amp;#039;, &amp;#039;inline-block&amp;#039;)&lt;br /&gt;
				:done()&lt;br /&gt;
			:wikitext(partyShortLink(v.p) .. &amp;#039;: &amp;#039; .. v.n)&lt;br /&gt;
			:done()&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return list&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parliamentFloat(root, args, data)&lt;br /&gt;
	local width = args.width or 240&lt;br /&gt;
	local mainDiv = root:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	mainDiv:addClass(&amp;#039;thumb&amp;#039;)&lt;br /&gt;
	mainDiv:addClass(&amp;#039;t&amp;#039;..args[&amp;#039;float&amp;#039;])&lt;br /&gt;
	&lt;br /&gt;
	local divThumbinner = mainDiv:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	divThumbinner:addClass(&amp;#039;thumbinner&amp;#039;)&lt;br /&gt;
	divThumbinner:css(&amp;#039;width&amp;#039;, tostring(width*1.125)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divThumbinner:css(&amp;#039;padding-right&amp;#039;, &amp;#039;6.5px !important&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	if args[&amp;#039;title&amp;#039;] then&lt;br /&gt;
		local divTitle = divThumbinner:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
		divTitle:addClass(&amp;#039;thumbdescription&amp;#039;)&lt;br /&gt;
		divTitle:css(&amp;#039;font-weight&amp;#039;, &amp;#039;bold&amp;#039;)&lt;br /&gt;
		divTitle:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
		divTitle:css(&amp;#039;font-size&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
		divTitle:wikitext(args[&amp;#039;title&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local divThumbimage = divThumbinner:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	divThumbimage:addClass(&amp;#039;thumbimage&amp;#039;)&lt;br /&gt;
	divThumbimage:addClass(&amp;#039;diagram&amp;#039;)&lt;br /&gt;
	divThumbimage:addClass(&amp;#039;noprint&amp;#039;)&lt;br /&gt;
	divThumbimage:css(&amp;#039;width&amp;#039;, tostring(width)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divThumbimage:css(&amp;#039;height&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divThumbimage:css(&amp;#039;padding&amp;#039;, tostring(width/15)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divThumbimage:css(&amp;#039;overflow&amp;#039;, &amp;#039;hidden&amp;#039;)&lt;br /&gt;
	divThumbimage:css(&amp;#039;background&amp;#039;, args.background)&lt;br /&gt;
	&lt;br /&gt;
	generateDiagram(divThumbimage, args, data)&lt;br /&gt;
	&lt;br /&gt;
	local divThumbcaption = divThumbinner:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	divThumbcaption:addClass(&amp;#039;thumbcaption&amp;#039;)&lt;br /&gt;
	divThumbcaption:wikitext(&amp;#039;Total &amp;#039;..tostring(data.totalSeats)..&amp;#039; seats&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	generateCaption(divThumbcaption, args, data)&lt;br /&gt;
	&lt;br /&gt;
	return root&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parliamentNonFloat(root, args, data)&lt;br /&gt;
	local width = args.width or 240&lt;br /&gt;
	local mainDiv = root:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	local divCentered = mainDiv:tag(&amp;#039;div&amp;#039;)&lt;br /&gt;
	divCentered:addClass(&amp;#039;centered&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;margin-left&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;margin-right&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
	divCentered:addClass(&amp;#039;diagram&amp;#039;)&lt;br /&gt;
	divCentered:addClass(&amp;#039;noprint&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;width&amp;#039;, tostring(width)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;height&amp;#039;, tostring(width/2)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;padding&amp;#039;, tostring(width/15)..&amp;#039;px&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;padding-top&amp;#039;, &amp;#039;15px&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;padding-bottom&amp;#039;, &amp;#039;5px&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;overflow&amp;#039;, &amp;#039;hidden&amp;#039;)&lt;br /&gt;
	divCentered:css(&amp;#039;background&amp;#039;, args.background)&lt;br /&gt;
	&lt;br /&gt;
	divCentered:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	generateDiagram(divCentered, args, data)&lt;br /&gt;
	&lt;br /&gt;
	return root&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._parliament(args)&lt;br /&gt;
	local root = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	local data = getData(args)&lt;br /&gt;
	&lt;br /&gt;
	if not args.background then args.background = &amp;#039;white&amp;#039; end&lt;br /&gt;
	&lt;br /&gt;
	if args[&amp;#039;float&amp;#039;] then&lt;br /&gt;
		return parliamentFloat(root, args, data)&lt;br /&gt;
	else&lt;br /&gt;
		return parliamentNonFloat(root, args, data)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.parliament(frame)&lt;br /&gt;
	return p._parliament(getArgs(frame))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Hydrogen</name></author>
	</entry>
</feed>