உள்ளடக்கத்துக்குச் செல்

Module:Medical cases chart

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.
Gowtham Sampath (பேச்சு | பங்களிப்புகள்) பயனரால் செய்யப்பட்ட 16:06, 27 மார்ச் 2020 அன்றிருந்தவாரான திருத்தம் ("local p = {} function p.buildBars( frame ) local barwidth = fram..."-இப்பெயரில் புதிய பக்கம் உருவாக்கப்பட்டுள்ளது)

Documentation for this module may be created at Module:Medical cases chart/doc

local p = {}

function p.buildBars( frame )
	local barwidth = frame.args.barwidth
	local data = frame.args.data
	local divisor = frame.args.divisor
	local numwidth = frame.args.numwidth
	local collapsible = frame.args.collapsible

	local lines = mw.text.split( data, '\n' )
	local i = 1

	if divisor == '' then
		local total1, total2 = 0, 0

		for parameter in mw.text.gsplit( lines[#lines], ';' ) do
			if not string.find( parameter, '^ *%a' ) then
				if i == 7 then
					total1 = tonumber( (string.gsub( parameter, '%D', '' )) )
					if not total1 then
						total1 = 0
					end
				elseif i == 9 then
					total2 = tonumber( (string.gsub( parameter, '%D', '' )) )
					if not total2 then
						total2 = 0
					end
					break
				end
				i = i + 1
			end
		end
		divisor = math.max( total1, total2 ) / ( 0.95 * barwidth )
	end
	local bars = ''
	local args

	for k, line in pairs( lines ) do
		args, i = {}, 1

		for parameter in mw.text.gsplit( line, ';' ) do
			if string.find( parameter, '^ *%a' ) then
				parameter = mw.text.split( parameter, '=' )
				args[parameter[1]] = parameter[2]
			else
				args[i] = parameter
				i = i + 1
			end
		end
		args['divisor'] = divisor
		args['numwidth'] = numwidth
		args['collapsible'] = collapsible
		bars = bars .. frame:expandTemplate{ title = 'Medical cases chart/Row', args = args }
	end
	return bars
end
return p
"https://ta.wikipedia.org/w/index.php?title=Module:Medical_cases_chart&oldid=2940146" இலிருந்து மீள்விக்கப்பட்டது