Module:Demographics Religion

require "Module:Demographics Basics" require "Module:Demographics Database" local querier = mw.loadData( 'Module:Demographics/PopQuery' )

local p={} function p.total(frame) return total_table(demographics.religion,frame.args[1]) end function p.main(frame) return fetch_table(demographics.religion,frame.args[1],frame.args[2]) end function p.generate(frame) local groups = querier.query(religion, religionName, 0, 0, 0, 0, 0, frame.args[1], 0, 0) local total = 0 for _,v in pairs(groups) do   	total = total + v    end local tab = mw.html.create( 'table' ) tab:addClass( 'wikitable sortable' ) tab:tag( 'tr' ) :tag( 'th' ):wikitext( 'Religion' ):done :tag( 'th' ):wikitext( 'Quantity' ):done :tag( 'th' ):wikitext( 'Percentage' ):done

for i, row in ipairs( groups ) do		tab:tag( 'tr' ) :tag( 'td' ):wikitext( i ):done :tag( 'td' ):wikitext( row ):done :tag( 'td' ):wikitext( (math.floor(row/total*10000) / 100) .. '%' ):done end return tab end function p.generate_bar(frame) return generate_bar(demographics.religion,frame.args[1],frame.args[2]) end return p