Vés al contingut

Mòdul:Composition bar

De la Viquipèdia, l'enciclopèdia lliure
Icona de documentació de mòdul Documentació del mòdul [ mostra ] [ modifica el codi ] [ mostra l'historial ] [ refresca ]

Mòdul Composition bar (codi · ús · discussió · proves · tests · casos prova | subpàgines · enllaços)

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Llistes[modifica]

KeyDefault namesLocalized names (i18n)T.
widthwidthampladasz
heightheightalçadasz
background-colorbackground-colorcolor fonss
border-colorborder-colorcolor voras
border-widthborder-widthamplada vorasz
colorcolorcolors
stylestyleestils
valuestylevaluestyleestil valors
perperperi (0-2)
parenthesisparenthesisparèntesisb
perstyleperstyleestil percentatges
boldboldnegretab
roundroundarrodoniri (0-2)
nodivisornodivisorno divisorb
voidvoidsense xifresb
You can change the localizated text in: Module:Composition bar/i18nUsed argument types: sz (size), s (string), i (integer), b (boolean)
KeySourceTranslation
InvalNumInvalid numberNúmero invàlid
InvalParamNumInvalid parameter number in style itemNúmero pel paràmetre invàlid en l'element d'estil
You can change the localizated text in: Module:Composition bar/i18n

<templatedata>
{
"params": {
"amplada": {
"aliases": [
"width"
],
"type": "line"
},
"alçada": {
"aliases": [
"height"
],
"type": "line"
},
"color fons": {
"aliases": [
"background-color"
],
"type": "line"
},
"color vora": {
"aliases": [
"border-color"
],
"type": "line"
},
"amplada vora": {
"aliases": [
"border-width"
],
"type": "line"
},
"color": {
"aliases": [
"color"
],
"type": "line"
},
"estil": {
"aliases": [
"style"
],
"type": "line"
},
"estil valor": {
"aliases": [
"valuestyle"
],
"type": "line"
},
"per": {
"aliases": [
"per"
],
"type": "number"
},
"parèntesis": {
"aliases": [
"parenthesis"
],
"type": "boolean"
},
"estil percentatge": {
"aliases": [
"perstyle"
],
"type": "line"
},
"negreta": {
"aliases": [
"bold"
],
"type": "boolean"
},
"arrodonir": {
"aliases": [
"round"
],
"type": "number"
},
"no divisor": {
"aliases": [
"nodivisor"
],
"type": "boolean"
},
"sense xifres": {
"aliases": [
"void"
],
"type": "boolean"
}
},
"format": "block"
}
</templatedata>

Altres[modifica]

Aquesta és la versió des d'un mòdul de {{Barra escons}}, a més:

  • Afegeix una barra de transparència darrera el text si és necessari.
  • Afegeix una línia de límit per la barra si el color és molt clar i seria difícil de distingir del color de fons.
  • |border= admet none com la versió anglesa
  • |lang= per a visualització amb idiomes diferents (per tal de visualitzar el format dels números i la direcció de la barra.
  • |style= estil de text tant pels valors com pel percentatge. Llavors |valuestyle= i |perstyle= complementen |style= si és defineix aquest últim.
{{#invoke:Composition bar|full_bar|1000|1500|red|nodivisor=true|style=font-size:85%|perstyle=color:blue|per=1}} dóna:
1.000 / 1.500
  • |txt_end= ajusta el text al final de la barra (que és l'esquerra en els idiomes de dreta a esquerra). Això facilita la lectura en una sèrie:
txt_end=true txt_end=false
10.000.000 / 15.000.000
900.000 / 15.000.000
5.000.000 / 15.000.000
10.000.000 / 15.000.000
900.000 / 15.000.000
5.000.000 / 15.000.000
  • |bold= el text en negreta, que és l'opció per defecte.
  • Admet que el primer o el segon paràmetre no estiguin assignats. Així:
{{#invoke:Composition bar|full_bar||1500|red|width=200}} dóna:
cap valor / 1.500
{{#invoke:Composition bar|full_bar|150||red|width=200}} dóna:
150 / cap valor
{{#invoke:Composition bar|full_bar|150||red|width=200|per=1}} dóna:
150 / cap valor
{{#invoke:Composition bar|full_bar|||red|width=200|per=1}} dóna:
cap valor
  • |above_text= posa les dades a sobre la barra envers de la barra, per imitació a la versió més estesa, d'altres wikis.
{{#invoke:Composition bar|full_bar|10000000|15000000|red|width=200|height=10|above_text=true|bold=false}} dóna:
10.000.000 / 15.000.000
{{#invoke:Composition bar|full_bar|10000000|15000000|red|width=200|height=10|above_text=true|nodivisor=true|per=1}} dóna:
10.000.000 / 15.000.000
{{#invoke:Composition bar|full_bar|10000000|15000000|red|width=200|height=10|above_text=true|nodivisor=true|per=1|perstyle=color:blue}} dóna:
10.000.000 / 15.000.000
  • Detecció d'erors, per exemple:
{{#invoke:Composition bar|full_bar|200|150|red}} dóna:

Error de Lua: #1 = 200 és major de 150.

Full bar[modifica]

Syntax[modifica]

En la determinació dels colors dels paràmetres següents és admès:

  • nom de color HTML
  • format #nnnnnn o &#35;nnnnnn (notació RGB)
  • rgb(0–255,0–255,0–255)

En la determinació de la mida en els paràmetres següents és admès:

  • px, on si no s'especifica s'entén com a píxel
  • em
  • % en el cas de la mida del text.

Versió mínima[modifica]

{{Composition bar|1|2|3}} 
Descripció

Els paràmetres, tots OBLIGATORIS, són:

  • 1: nombre de subunitats a representar.
  • 2: nombre total de subunitats possibles.
  • 3: color de la barra dibuixada.

Versió complerta[modifica]

{{Composition bar|1|2|3
|width= 
|height= |color= |background-color= |border-color= |border-width= |per= |perstyle= |void= |lang=}}
Descripció

Els 3 primers paràmetres obligatoris anteriors

Opcionals
  • width: llargada caixa. Per defecte, 100px
  • height: alçada caixa. Per defecte, 1.5em
  • background-color: color de fons de la caixa. Per defecte, #f0f0f0
  • border-color: color del marc de la caixa. Per defecte, #c0c0c0
  • border-width: gruix del marc de la caixa. Per defecte, 1px
  • color: Color de la lletra. Per defecte, negra
  • style: estil de text tant pels valors com pel percentatge. Llavors |valuestyle= i |perstyle= complementen |style= si és defineix aquest últim.
  • valuestyle: permet aplicar un format al text, més enllà del color. (ex: font-size:85%;)
  • per: mostrar %. 0=no, 1=el % del paràmetre 1 sobre el 2, 2=el complement.
  • parenthesis: Si s'informa (ex.:parenthesis=n o no) oculta els parèntesis del percentatge. Per defecte, quan hi hagi % sortirà entre parèntesi.
  • perstyle: permet aplicar un format al text del %. (ex:font-size:85%;)
  • bold: text en negreta, per defecte, true
  • round: nombre de decimals per fer l'arrodoniment. Per defecte és 1
  • nodivisor: El format del text std. mostrat és valor/divisor (params. 1 i 2) per donar context de "quants en té d'entre quants disponibles". Quan no es vol mostrar el valor de referència o divisor, per exemple perquè ja es conegut o està informat fora de la barra, indicar nodivisor=x.
  • void: evita mostrar el text valor/divisor (1 i 2). Només mostra la barra amb text valor/divisor; el percentatge es mostra o no si s'ha informat el paràmetre "per".
  • lang: per a simulació en d'altres idiomes.
  • txt_end: ajusta el text al final de la barra (que és l'esquerra en els idiomes de dreta a esquerra). Això facilita la lectura en una sèrie.
  • above_text: posa les dades a sobre la barra envers de la barra, per imitació a la versió més estesa, d'altres Viquipèdies.

Exemples[modifica]

Codi Mostra
Primera prova
{{#invoke:Composition bar|full_bar|350|630|blue|height=16|valuestyle=font-size:80%}}
350 / 630

Color barra en model de color RGB
{{#invoke:Composition bar|full_bar|150|630|rgb(152,237,152)}}
150 / 630

Color barra en colors HTML
{{#invoke:Composition bar|full_bar|150|630|#98FB98|height=1.1em}}
150 / 630

Sense vora
{{#invoke:Composition bar|full_bar|150|630|#98FB98|height=1.1em|border-color=none}}
150 / 630

Mostrar % dins caixa (paràmetre ''per'')
{{#invoke:Composition bar|full_bar|150|630|#98FB98|per=1|perstyle=font-size:85%;color:red;|round=2|width=200}}
150 / 630

Mostrar % complementari (paràmetre ''per'')
{{#invoke:Composition bar|full_bar|150|630|#98FB98|per=2|perstyle=font-size:85%;color:blue;|width=200}}
150 / 630

Ample barra a elecció (paràmetre ''width'')
{{#invoke:Composition bar|full_bar|150|630|#98FB98|width=200}}
150 / 630

Color lletra a elecció (paràmetre ''color''. Sense xifres a l'interior)
{{#invoke:Composition bar|full_bar|150|630|#98FB98|width=200|void=y}}

Color lletra a elecció (paràmetre ''color'')
{{#invoke:Composition bar|full_bar|150|630|#98FB98|width=200 |color=purple}}
150 / 630

Color fons caixa a elecció (paràmetre ''background-color'')
{{#invoke:Composition bar|full_bar|350|630|green|width=200 |color=purple|background-color=yellow|nodivisor=y}}
350 / 630

Color marc caixa elecció (paràmetre ''border-color'')
{{#invoke:Composition bar|full_bar|350|630|green|width=200 |color=purple|background-color=yellow|border-color=red}}
350 / 630

Gruix marc caixa elecció (paràmetre ''border-width'')
{{#invoke:Composition bar|full_bar|350|630|green|width=200 |color=purple|background-color=yellow|border-color=red|border-width=3px}}
350 / 630

Mida de 10
{{#invoke:Composition bar|full_bar|150|630|blue|height=20|width=300|valuestyle=font-size:10px}}
150 / 630

Mida de 20
{{#invoke:Composition bar|full_bar|150|630|blue|height=40|width=300|valuestyle=font-size:20px}}
150 / 630

Mida de 40
{{#invoke:Composition bar|full_bar|150|630|blue|height=60|width=300|valuestyle=font-size:40px}}
150 / 630

Mida de 40
{{#invoke:Composition bar|full_bar|150000|630000|blue|height=60|width=600|valuestyle=font-size:40px}}
150.000 / 630.000

Elections bar[modifica]

Syntax[modifica]

Correspon a una versió preparada de l'anterior:

{{#invoke:Composition bar|Elections|obtained_votes|total_votes|bar_color|lang=}}

Els tres primers paràmetres són obligatoris.

|lang= és opcional i sols s'utilitza per demostracions.

Exemples[modifica]

En altres idiomes[modifica]

{{#invoke:Composition bar|Elections|30000|51111|red|lang=en}}
30,000 / 51,111
{{#invoke:Composition bar|Elections|30000|51111|red|lang=ar}}
٣٠٬٠٠٠ / ٥١٬١١١
{{#invoke:Composition bar|Elections|30000|51111|red|lang=he}}
30,000 / 51,111

Segons lluminositat del color[modifica]

Lluminositat intermitja -> Opacitat 0.5:
{{#invoke:Composition bar|Elections|30000|51111|red}}
30.000 / 51.111
{{#invoke:Composition bar|Elections|3000000|5000000|#49fffe}}
3.000.000 / 5.000.000
Colors foscos -> Opacitat 0.8:
{{#invoke:Composition bar|Elections|1000000|15000000|blue}}
10.000.000 / 15.000.000
{{#invoke:Composition bar|Elections|3000|5000|black}}
3.000 / 5.000
En ser color molt lluminós, sols la ratlleta:

{{#invoke:Composition bar|Elections|2000000|5000000|yellow}}

2.000.000 / 5.000.000
{{#invoke:Composition bar|Elections|2000000|5000000|white}}
2.000.000 / 5.000.000



local p = {}

local SA = require "Module:SimpleArgs"
local SD = require "Module:SimpleDebug"
local MLMT = require "Module:Multilang module tools/prova"
local CBi = require "Module:Composition bar/items" 
local CBi18n = require "Module:Composition bar/i18n" 

local ModuleName = 'Composition bar'
local items = {
	[MLMT.k.Args] = {
		[CBi.k.width] 				= 'width',
		[CBi.k.height] 				= 'height',
		[CBi.k.background_color] 	= 'background-color',
		[CBi.k.border_color] 		= 'border-color',
		[CBi.k.border_width] 		= 'border-width',
		[CBi.k.color] 				= 'color',
		[CBi.k.style] 				= 'style',
		[CBi.k.valuestyle] 			= 'valuestyle',
		[CBi.k.per] 				= 'per',
		[CBi.k.parenthesis] 		= 'parenthesis',
		[CBi.k.perstyle] 			= 'perstyle',
		[CBi.k.bold]				= 'bold',
		[CBi.k.round] 				= 'round',
		[CBi.k.nodivisor] 			= 'nodivisor',
		[CBi.k.void] 				= 'void',
		[CBi.k.txt_end] 			= 'txt_end',
	},	
	[MLMT.k.Errors] = {
		[CBi.k.InvalNum]			= "Invalid number",
		[CBi.k.InvalParamNum]		= "Invalid parameter number in style item",
	},	
}

function p._formatNum (num, lang, round_num)
	res = mw.language.new(lang):formatNum(num)
	if (round_num > 0) and (num == math.floor(num)) then
		res = res..mw.ustring.sub (mw.language.new(lang):formatNum(0.001), 2, 2+round_num)
	end	
	return res
end	--formatNum

function p._color_black_contrast (color)
	local colors = {}
	local j = 1
	for i = 1, 3 do
		local s = string.sub (color, j, j+1)
		table.insert (colors, tonumber(s,16))
		j = j + 2
	end
	local dif = math.max (colors[1], colors[2], colors[3]) - math.min (colors[1], colors[2], colors[3])
	--local val = 0.5*colors[1] + 0.419*colors[2] + 0.081*colors[3]
	local val = 0.45*colors[1] + 0.45*colors[2] + 0.1*colors[3]
	local to_subtract = math.abs(dif-255)
	local to_dif = 128-math.abs(val-128)
	local to_subtract2 = to_subtract * to_dif * 0.0018 
	local res = math.floor ((val - to_subtract2) + 0.5)
	return res
end --_color_black_contrast

function p.color_black_contrast (frame)
	local args = SA.GetArgs (frame)
	local color = SA.RColor_Par (args, 1)
	return p._color_black_contrast (color)
end --color_black_contrast

local function SizeStrToPx (s)
	local n = tonumber (s)
	if n == nil then
		local l = string.len (s)
		n = tonumber (string.sub (s, 1, l-2))
		local t = string.sub (s, l-1, l)
		if t == 'px' then
		elseif t == 'em' then	
			n = n * 16
		else
			error ('Invalid size:'..s)
		end	
	end	
	return n
end --SizeStrToPx

function Size_Par (Args, ParId, Default)
	res = SA.Str_Par (Args, ParId, Default) 
	return SizeStrToPx (res)
end	

local function round (num, PercDecimimalPlaces)
	local mult = 10^(PercDecimimalPlaces or 0)
	return math.floor(num * mult + 0.5) / mult
end

function p.full_bar (frame)
	local args, NArgs = SA.GetArgs (frame)
	if NArgs == 0 then 
		return ''
	end	
	local itemsM = MLMT.tableMerge (ModuleName, items, CBi18n.items)

	--BEGIN--
	local res = MLMT.ItemList_or_TempData (args, {MLMT.LOpt.params,MLMT.LOpt.template,MLMT.LOpt.errors},
		'CB', ModuleName, items, CBi18n.items, 
		CBi.idxArgs, CBi.arg_lims, 
		nil, --labels
		nil, --messages
		CBi.idxErrors)
	if res == nil then --main
		SA.OKEmptyVal = false
		local total = SA.Num_Par (args, 2)
		local amount = SA.Num_Par (args, 1, nil, 0, total)
	
		function Arg (key)
			return itemsM[MLMT.k.Args][key]
		end	
		function Error (key)
			return error (itemsM[MLMT.k.Errors][key],0)
		end	
		
		function GetColor (par_name, required, Default)
			local color, color_sent
			if required then
		    	color = SA.RStr_Par (args, par_name)
		    else	
		    	color = SA.Str_Par (args, par_name)
		    end	
		    if color == nil then
		    	color = Default
		    	color_sent = Default
		    else 
		    	local c = string.sub (color, 1,3)
		    	if c ~= 'rgb' then
			    	color = SA.RColor_Par (args, par_name)
			    	color_sent = '#'..color
			    else
			    	color = string.sub (color, 5, string.len(color)-1)
			    	local color_array =  mw.text.split (color, ',')
			    	for i, n in ipairs(color_array) do
			    		color_array[i] = tonumber(n)
			    	end	
			    	color_sent = SA.rgbToHex (color_array)
			    	color = string.sub (color_sent, 2)
			    end	
		    end
		    return color, color_sent
		end	--GetColor
		local bar_color = GetColor (3, true)
		
		local height = Size_Par (args, Arg(CBi.k.height), '1.5em')
		local width = Size_Par (args, Arg(CBi.k.width), '180px')
	    local background_color = SA.Color_Par (args, Arg(CBi.k.background_color), '#f0f0f0')
	    local border_color = SA.Str_Par (args, Arg(CBi.k.border_color))
	    if border_color ~= 'none' then
	    	border_color = GetColor (Arg(border_color), false, '#c0c0c0')
	    end
	    local border_width = Size_Par (args, Arg(CBi.k.border_width), '1px')
	    local txt_color, txt_color_sent = GetColor (Arg(color), false, 'black')
	
	    local round_num = SA.Int_Par (args, Arg(CBi.k.round), 1, 0, 3)
	    local per = SA.Int_Par (args, Arg(CBi.per), nil, 1, 2)
		local bar_ratio = nil
		local ratio = nil 
		local per_ratio = nil 
		local low_ratio = nil
		if (amount == nil) or (total == nil) then
		else	
			bar_ratio = amount / total
			if per ~= nil then
				if per == 1 then
					ratio = bar_ratio
				else --if per == 2 then
					ratio = (total-amount)/total
				end
				per_ratio = round (ratio*100, round_num)
				low_ratio = per_ratio < 10
			end	
		end	
	    local parenthesis = SA.Bool_Par (args, Arg(CBi.parenthesis), true)
	    local nodivisor = SA.Bool_Par (args, Arg(CBi.nodivisor), false)
	    local txt_end = SA.Bool_Par (args, Arg(CBi.txt_end), true) 
	    local style = SA.Str_Par (args, Arg(CBi.style))
	    local valuestyle = SA.Str_Par (args, Arg(CBi.valuestyle))
	    local perstyle = SA.Str_Par (args, Arg(CBi.perstyle))
	    local bold = SA.Bool_Par (args, Arg(CBi.bold), true)
	    
	    function get_h_txt (style, new_h_txt, global)
	    	local new_par = nil
	    	local items_style = {}
	    	local has_font_size, has_color = false, false
	    	if style ~= nil then
	    		new_par = mw.text.split (style, ';')
	    		for i, k in ipairs (new_par) do
	    			local par2 = mw.text.split (k, ':')
	    			if #par2 == 2 then
		    			par2[1] = mw.text.trim (par2[1])
		    			par2[2] = mw.text.trim (par2[2])
		    			items_style[par2[1]] = par2[2]
				    	if par2[1] == 'font-size' then
				    		has_font_size = true
				    		local s = par2[2]
							local l = string.len (s)
							local end_s = string.sub (s, l)
							if end_s == '%' then
								local n = tonumber (string.sub (s, 1, l-1))
								if n == nil then
									error (Error(CBi.k.InvalNum)..': '..s)
								else
									new_h_txt = new_h_txt * n/100
								end
							else
								new_h_txt = SizeStrToPx (s)
							end	
				    	elseif par2[1] == 'color' then
							has_color = true
				    	end	
	    			elseif (#par2 ~= 0) and (k ~= '') then	
	    				error (Error(CBi.k.InvalNum)..': '..k)
	    			end	
	    		end	
		    end	
		    if global and (not has_font_size) then
	    		items_style['font-size'] = (new_h_txt)..'px'
		    end	
		    if global and (not has_color) then
	    		items_style['color'] = tostring (txt_color_sent)
		    end	
		    return new_h_txt, items_style
	    end --get_h_txt	
	    local h_txt, par = get_h_txt (style, 13, true)
	    local h_txt_val, par_val = get_h_txt (valuestyle, h_txt, false)
	    local h_txt_per, par_per = get_h_txt (perstyle, h_txt, false)
	    local lang = SA.Str_Par (args, 'lang', mw.language.getContentLanguage().code) 
		local IsRTL = mw.getLanguage(lang):getDir() == 'rtl'
	    local dif_styles = IsRTL
	    if (per ~= nil) and (not dif_styles) then
		    for k, i in pairs(par_val) do 
		    	if par_per[k] ~= i then
		    		dif_styles = true
		    		break
		    	end	
		    end	
		    if not dif_styles then
			    for k, i in pairs(par_per) do 
			    	if par_val[k] ~= i then
			    		dif_styles = true
			    		break
			    	end	
			    end	
		    end
	    end   
		local h_txt_max
		if per == nil then
			h_txt_max = h_txt_val
		else	
	    	h_txt_max = math.max (h_txt_val, h_txt_per)
	    end	
	    local void = SA.Bool_Par (args, 'void', false)
	    local above_text = SA.Bool_Par (args, 'above_text', false)
	    if above_text then
	    	void = true
	    end	
	
		local lum = p._color_black_contrast (bar_color)
		local trans = 0.25
		local use_trans = true
		local use_bar_border = false
		if lum > 200 then
			use_trans = false
			if lum > 220 then
				use_bar_border = true
			end	
		elseif lum < 100 then
			trans = 0.4
		end	
		local width_px = width..'px' 
		local height_px = height..'px' 
		local bar = mw.html.create('div')
		bar:css ('margin-top', '0.1em')
		bar:css ('margin-bottom', '0.3em')
		bar:css ('width', width_px)
		bar:css ('height', height_px)
		bar:css ('background-color', '#'..background_color)
		if border_color ~= 'none' then
			bar:css ('border', border_width..'px')
			bar:css ('border-style', 'solid')
			bar:css ('border-color', '#'..border_color)
		end	
		
			local bar2 = bar:newline():tag('div')
			bar2:css ('position', 'relative')
			bar2:css ('height', '100%')
			bar2:css ('width', '100%')
			
			function AddStyles (lab, par, curr_par)
				for k, i in pairs(par) do
					lab:css (k, i)
				end					
				for k, i in pairs(curr_par) do
					lab:css (k, i)
				end					
			end	--AddStyles
				
				if bar_ratio ~= nil then
					local res = bar2:newline():tag('div')
					res:css ('position', 'absolute')
					local l
					if IsRTL then
						l = width - (width * bar_ratio)
					else
						l = 0
					end	
					res:css ('left', (l)..'px')
					if use_bar_border then
						local b
						if IsRTL then
							b = 'left'
						else
							b = 'right'
						end	
						res:css ('border-'..b, '1px solid silver')
					end	
					res:css ('height', height_px)
					res:css ('width', (width * bar_ratio)..'px')
					res:css ('background-color', '#'..bar_color)
					res:done ()
				end
				local snum1, snum2, snum, sper
				local l_per, l_num, l_tot
				if above_text or (not void) then
					function nodata ()
						local s = mw.message.new('Wikibase-snakview-snaktypeselector-novalue'):inLanguage(lang):plain()
						local s2 = ''
						local len = mw.ustring.len (s)
						for i = 1, len do
							c = mw.ustring.sub (s, i, i)
							if c == ' ' then
								c = '&nbsp;'
							end
							s2 = s2..c
						end 
						return s2
					end	--nodata
					function int_to_str (num)
						if num == nil then
							return nodata ()
						else	
							return mw.language.new(lang):formatNum(num)
						end	
					end -- int_to_str	
					function width_str (text)
						len = mw.ustring.len (text)
						local l = 0
						for i = 1, len do
							c = mw.ustring.sub (text, i, i)
							if (c == '.') or (c == ',') or 
								(c == '٫') or (c == '٬') --Arabic
							then
								l = l + 0.53  --0.48
							elseif c == '1' then	
								l = l + 0.92  --0.86
							else 
								l = l + 1
							end
						end
						return l
					end --width_str
					
					if (amount == nil) and (nodivisor == false) and (total == nil) then
						snum = nodata ()
						l_num = width_str (snum)
					else	
						snum1 = int_to_str (amount)
						snum = snum1
						if nodivisor == false then
							snum2 = int_to_str (total)
							snum = snum1..' / '..snum2
						end	
						l_num = width_str (snum)
						if nodivisor == false then
							snum = snum1..'&nbsp;/&nbsp;'..snum2
						end	
					end
					sper = ''
					if per ~= nil then
						if per_ratio == nil then
							sper = '&nbsp;-'
							if round_num > 0 then
								sper = sper .. mw.ustring.sub (mw.language.new(lang):formatNum(0.1), 2, 2)..string.rep ('-',round_num)
							end	
						else	
							sper = p._formatNum (per_ratio, lang, round_num)
						end	
						sper = sper..'٪' 
						if parenthesis then
							sper = '('..sper..')'
						end	
						l_per = width_str (sper)
					end	
					l_tot = l_num
					if (per ~= nil) and (not dif_styles) then
						local s_space = '&nbsp;&nbsp;'
						local n_spaces = 2
						if txt_end and low_ratio then
							s_space = s_space..'&nbsp;'
							n_spaces = 3
						end
						snum = snum..s_space..sper
						l_tot = l_num + n_spaces + l_per
					end	
				end	
				if void then
					if above_text then
					end	
				else	
					local fact = 0.5
					local maxtop = (height - h_txt_max) / 2
					function a_trans (l, left, curr_h_txt, text, curr_par)
						local l_txt = (l+1)*curr_h_txt*fact
						local top1 = maxtop + (((h_txt_max * 1.595) - (curr_h_txt * 1.595))/2)
						top1 = math.floor (top1)
						function a_trans2 (h, w, t, l, atext, apar_val)
							local text_bg = bar2:newline():tag('div')
							text_bg:css ('position', 'absolute')
							text_bg:css ('height', h..'px')
							text_bg:css ('width', w..'px')
							text_bg:css ('top', t..'px')
							text_bg:css ('left', l..'px')
							if use_trans then
								text_bg:css ('background-color', 'rgba(255,255,255,'..trans..')')
							end	
							--text_bg:css ('background-color', 'fuchsia')
							if atext ~= nil then
								local lab = text_bg:newline():tag('span')
								AddStyles (lab, par, curr_par)
								lab:css ('position', 'absolute')
								lab:css ('top', '50%')
								lab:css ('left', '50%')
								lab:css ('-ms-transform', 'translate(-50%,-50%)')
								lab:css ('transform', 'translate(-50%,-50%)')
								if bold then
									text = "'''"..text.."'''"
								end	
								lab:wikitext (text)
								lab:done ()
							end
							text_bg:done ()
						end	
						if use_trans then
							a_trans2 (curr_h_txt+2, l_txt, top1, left)
						end	
						a_trans2 (curr_h_txt, l_txt-2, top1+1, left+1, text, curr_par)
					end --a_trans
					local left
					local allw = 0
					function getleft ()
						if IsRTL then
							if txt_end then
								left = h_txt_val * fact
							else	
								left = (width-allw) / 2
							end	
						else	
							if txt_end then
								left = (width-allw) - (h_txt_val * fact)
							else	
								left = (width-allw) / 2
							end	
						end
					end	--getleft
					if dif_styles then
						if per == nil then
							allw = (l_num+1) * h_txt_val * fact
						else	
							allw = ((l_num+1.5) * h_txt_val * fact) + ((l_per+2) * h_txt_per * fact) 
						end	
						getleft ()
						if IsRTL then
							if per ~= nil then
								a_trans (l_per, left, h_txt_per, sper, par_per)
								left = left + ((l_num+2) * h_txt_per * fact)
							end	
							a_trans (l_num, left, h_txt_val, snum, par_val)
						else	
							a_trans (l_num, left, h_txt_val, snum, par_val)
							if per ~= nil then
								left = left + ((l_num+2) * h_txt_val * fact)
								a_trans (l_per, left, h_txt_per, sper, par_per)
							end	
						end	
					else
						if per ~= nil then
							l_tot = l_tot + 2
						end	
						allw = (l_tot+1) * h_txt_val * fact
						getleft ()
						a_trans (l_tot, left, h_txt_val, snum, par_val)
					end	
				end
				
			bar2:done ()
		bar:done ()
		local res = tostring(bar)	
		if above_text then
			local txt_above = ''
			function Add (text, curr_par)
				local lab = mw.html.create('span')
				AddStyles (lab, par, curr_par)
				if bold then
					text = "'''"..text.."'''"
				end	
				lab:wikitext (text)
				lab:done ()
				return tostring(lab)	
			end	
			txt_above = Add (snum, par_val)
			if dif_styles then
				txt_above = txt_above..'&nbsp;&nbsp;'..Add (sper, par_per)
			end	
			res = txt_above..res
		end	
	    return res
	else
		return res		
	end
end --full_bar

function p.Elections (frame)
	local args = SA.GetArgs (frame)
	return p.full_bar ({
		args[1] or nil,
		args[2] or nil,
		args[3],
		['lang'] = args['lang'],
		['txt_end'] = args['txt_end'],
		['style'] = 'font-size:85%',
		['nodivisor'] = 'y',
		['height'] = '18',
		['width'] = '160',
		['per'] = 1,
		['parenthesis'] = 'n'
	})
end --Elections

return p