Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Swpb/NPVIC chart old
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 getArgs = require('Module:Arguments').getArgs p = {} --3 function p.main(frame) local args = getArgs(frame, { trim = false, removeBlanks = false }) return p._main(args) end --11 function p._main(args) local updated = args['updated'] local size = args['size'] or 500 local vert_interval = args['vert-interval'] or 25 local year_interval = args['year-interval'] or 1 local num_named_args = 1 if args['size'] then num_named_args = num_named_args + 1 end if args['vert-interval'] then num_named_args = num_named_args + 1 end if args['year-interval'] then num_named_args = num_named_args + 1 end --23 Get number of annotations and items local num_anns = 0 --25 Get annotations local note_dates = {} local note_texts = {} for i = 1, 5, 1 do if args['note-date' .. i] then num_anns = num_anns + 1 note_dates[i] = args['note-date' .. i] note_texts[i] = args['note-text' .. i] end end num_named_args = num_named_args + 2*num_anns --36 Get items local items = {} local totals = {} local num_items = 10 --FIX!!!!!!!!!! -- local num_items = #args - num_named_args for i = 1, num_items, 1 do items[i] = args[i] totals[i] = mw.getCurrentFrame():getParent():expandTemplate{ title = 'component' , args = { items[i] , 3 } } end --45 Determine totals local curr_tot = totals[#totals] local max_tot = math.max(unpack(totals)) --48 vert_legend = '<div style=\"position: absolute; top: 25%; height: 50%; left: 110%; display: table; text-align:center;\">' .. '<div style=\"display:table-cell; vertical-align: middle; font-size: {{#expr: 90*{{{size|500}}}/500 }}%; line-height: 125%;\">' .. '\'\'\'Total<br/>Electoral<br/>Votes of<br/>Adoptive<br/>States\'\'\'</div>' .. '</div>' time_axis = 'num_args = ' .. table.maxn(args) .. '. ' stripes = 1 vert_axis = 1 --56 bars = '' for i=1, num_items, 1 do bars = bars .. mw.getCurrentFrame():getParent():expandTemplate{ title = 'NPVIC chart/bar' , args = { size = size, max_tot = max_tot, updated = updated, items[i] } } end curr_tot_ann = 1 finish_line = 1 opt_anns = 1 census_anns = 1 as_of = mw.getCurrentFrame():getParent():preprocess( '{{as of|{{JULIANDAY.YEAR|{{MDY to Julian|' .. updated .. '}}}}|{{JULIANDAY.MONTH|{{MDY to Julian|' .. updated .. '}}}}|lc=y}}' ) chart = mw.getCurrentFrame():getParent():preprocess( '{{image frame|width=' .. size+50 .. '|caption=History of state participation in the NPVIC ' .. as_of .. '|link=File:NPVIC participants.svg<!--SVG image is likely to be outdated-->' .. '|content=' .. '<div style=\"width: ' .. size .. 'px; height: ' .. 0.75*size .. 'px; position: relative;' .. 'padding: ' .. size/100 .. 'px; ' .. size/100 .. 'px; ' .. size/100 .. 'px; ' .. size/13 .. 'px;\">' .. '<div style=\"border:1px solid; width:80%; height:81%; position: relative; box-sizing: border-box;\">' .. vert_legend .. time_axis .. stripes .. vert_axis.. bars .. curr_tot_ann .. finish_line .. opt_anns .. census_anns .. -- '(' .. max_tot .. curr_tot .. ')' .. -- '(' .. num anns .. ' ' .. num_items .. ')' .. '</div></div>}}' ) return chart end function p.bar(args) end function p.x_marker(args) end function p.y_marker(args) end function p.stripe(args) end function p.annotation(args) end function p.percent(args) end return p
Summary:
Please note that all contributions to Stockhub 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
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Swpb/NPVIC chart old/doc
(
edit
)