Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Croatian population data graph
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} -- ako je u predlošku popisi=HRV prikazat će sve poznate popise od 1857. do 2021. -- bez obzira na to postoji li u članku podatak -- bez tog parametra u predlošku, prikazat će samo godine upisane u članku local godine_hr = {1857, 1869, 1880, 1890, 1900, 1910, 1921, 1931, 1948, 1953, 1961, 1971, 1981, 1991, 2001, 2011, 2021, } local izvori_hr = "[[Template:Croatian population data graph/Sources|Croatian Bureau of Statistics publications]]" local max_visina = 8 -- 8 em; podesiti i visinu ćelije u css-u predloška function p.dijagram(frame) local podatci = {} local targs = frame:getParent().args --template arguments in template call local margs = frame.args --module arguments in #invoke --prođi kroz sve parametre; većinom su to parametri oblika pGGGG ili parovi aN/pN for k, v in pairs(targs) do local g = tonumber(string.match(k, "^p(%d%d%d%d)$")) -- parametri oblika p2021 if g then local p = tonumber(v) --mw.log(g,p) if p then podatci[g] = p end end local n = string.match(k, "^a(%d%d?)$") -- do 99 parova parametara godina/populacija: a1/p1 … a99/p99 if n then local g = tonumber(v) local p = tonumber(targs["p"..n]) --mw.log(g,p) if g and p then podatci[g] = p end end end --godine prisutne u predlošku; trebamo ih u tablici radi sortiranja local godine = {} local podatci_max = 0 for k, v in pairs(podatci) do table.insert(godine, k) if podatci[k]>podatci_max then podatci_max=podatci[k] end end table.sort(godine) --html tablica u kojoj će svaka ćelija sadržavati jedan stupac (div) stupčastog dijagrama --ovdje stvaramo ćelije u dvama retcima local tr1 = mw.html.create( 'tr' ) tr1 : tag("td") : addClass("kbs_ordinata") : tag("span") : addClass("kbs_ordinata") : wikitext("population") : done() local tr2 = mw.html.create( 'tr' ) tr2 : tag("td") : done() if (targs["popisi"]=="HRV") or (margs["popisi"]=="HRV") then prikazi = godine_hr else prikazi = godine end local prva, zadnja = Nil, Nil for _, g in ipairs(prikazi) do if godine[1]<=g and g<=godine[#godine] then --ne prikazuj lijevo i desno od jedinih poznatih, ali prikaži između prva = prva or g zadnja = g local podatak = podatci[g] or 0 local biljeg = (podatak>0 and podatak) or "" -- do not show 0 or Nil tr1 : tag("td") : addClass("kbs_za_stupce") : tag("div") : addClass("kbs_podatci") : wikitext(biljeg) : done() : tag("div") : addClass("kbs_stupci") : cssText("height:"..0.01*math.floor(100*podatak*max_visina/podatci_max).."em;") : done() tr2 : tag("td") : addClass("kbs_godine") : wikitext(g) : done() end end -- naslov iznad tablice s dijagramom -- u predlošku: Naselje X ili Općina Y ili Grad Z local podatci_za = targs["područje"] and (targs["područje"] ~= "") and ("'''" .. targs["područje"] .. "''': ") or "" local kbs = "Population trends " .. prva .."–"..zadnja local naslov = podatci_za .. (targs["naslov"] and (targs["naslov"] ~= "") and targs["naslov"] or kbs) -- tablica za stupčasti dijagram local tbl = mw.html.create( 'table' ) tbl : addClass("kbs_tablica") : node(tr1) : node(tr2) local ttl = mw.html.create( 'div' ) ttl : addClass("kbs_naslov") : wikitext(naslov) local tbl_ttl = mw.html.create( 'div' ) tbl_ttl : addClass("kbs_tablica_scrollable") : tag("div") : addClass("kbs_tablica") : node(ttl) : node(tbl) : done() -- Napomena:… i Izvori:… ispod dijagrama local napomena = targs["napomena"] or "" local izvori = "" if (targs["popisi"]=="HRV") or (margs["popisi"]=="HRV") then izvori = izvori_hr end izvori = targs["izvor"] or izvori local nte = mw.html.create( 'div' ) : addClass("kbs_napomena") if napomena ~="" then nte : wikitext("'''Note''': " .. napomena .. " ") end if izvori ~="" then nte : wikitext("'''Sources''': " .. izvori) end local nap_izv = mw.html.create( 'div' ) nap_izv : addClass("kbs_napomena_nonscrollable") : node(nte) local vte_div = mw.html.create( 'div' ) : addClass("kbs_vte") local vte = frame : expandTemplate{title = 'vte', args = { 'Croatian population data graph' } } vte_div : node(vte) nap_izv : node(vte_div) local sve = mw.html.create() : node(tbl_ttl) : node(nap_izv) return sve end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Dated maintenance category
(
edit
)
Template:FULLROOTPAGENAME
(
edit
)
Template:Improve documentation
(
edit
)
Template:Not English
(
edit
)
Template:Ns has subpages
(
edit
)
Template:Ombox
(
edit
)
Template:Subpage other
(
edit
)
Module:Croatian population data graph/doc
(
edit
)
Module:Message box
(
edit
)
Module:Unsubst
(
edit
)