Bản mẫu:NPVIC chart
![]() | Bản mẫu này sử dụng những tính năng phức tạp của cú pháp bản mẫu.
Bạn được khuyến khích làm quen với cấu trúc của bản mẫu này và các hàm cú pháp trước khi sửa đổi bản mẫu. Nếu sửa đổi của bạn gây ra lỗi không mong muốn, hãy sửa chữa hoặc lùi lại nhanh chóng, vì bản mẫu này có thể xuất hiện trên một số lượng lớn trang. |
This template creates a "stacked" timeline chart for the article National Popular Vote Interstate Compact, showing the contributions over time of individual member states to the NPVIC electoral vote total. It allows annotations of key events.
Use
sửaThis template has several named parameters used to set up the chart, and uses unnamed parameters to pass data (in {{item}} frames) to the sub-template {{NPVIC chart/bar}}, which creates the contents of the chart.
Chart parameters
sửaParameter group | Parameter | Purpose | Default value |
---|---|---|---|
Current status (mandatory) | curr_tot | Total number of electoral votes (EVs) currently controlled by NPVIC member states | - |
updated | Date of last update to the chart, in MM/DD/YYYY format | - | |
Bar segments (as many as needed1) | [unnamed] | Defines an individual bar segment in the chart, using the {{item}} template (See bar segment syntax below) |
- |
Display parameters (optional) | width | Width of the displayed table, in pixels | 750 |
height | Height of the displayed table, in pixels (also determines font sizes) | 450 | |
max_tot | Maximum number of EVs ever controlled by NPVIC member states (Controls scale of vertical axis; use when EV total has decreased) |
{{{curr_tot}}} | |
vert-interval | Interval of the vertical axis, in EVs | 25 | |
year-interval | Interval of the horizontal axis, in years | 1 | |
Annotations (optional, up to five2) | note-date[n] | Date of event | - |
note-text[n] | Annotation text | - |
- 1.^ The template currently supports up to 50 bar segments. If more are needed, the template must be edited to make additional calls to {{NPVIC chart/bar}}.
- 2.^ Census events are automatically annotated and do not count towards the limit
Example
sửa{{NPVIC chart
| curr_tot = 165 | updated = 9/17/2017 <!--Mandatory parameters-->
| size = 500 | max_tot = 165 | vert-interval = 25 | year-interval = 1 <!--Optional display parameters-->
| note-date1 = 1/3/2006 | note-text1 = First<br/>legislative<br/>introduction <!--An annotation-->
| {{item | ... }} <!--First bar segment (see syntax below) -->
| {{item | ... }} <!--Second bar segment (see syntax below) -->
| ...
}}
Bar segment syntax
sửaA bar segment represents a portion of the history of a particular state's participation in the compact, between two events at which the EV total changed:
- The start event may be when the state joined the compact, when a previously-joined state left or rejoined the compact, or at a congressional reapportionment
- The end event may be when the state left the compact, when a previously-joined state left or rejoined the compact, or at a congressional reapportionment
Most states will require multiple segments to span their history in the compact, if intervening events change the EV total. States which leave the compact must continue to be included, with an EV value of zero.
Each bar segment is created with a single unnamed argument, containing a call to the template {{item}} with the parameters outlined below.
Parameter group | Parameter | Purpose | Sample value | Notes |
---|---|---|---|---|
State | 1 | State (two letter abbreviation) | MD | MANDATORY: May be empty, but must be present |
Electoral votes | 2 | Number of EVs controlled by the state | 10 | MANDATORY |
3 | New total EVs of member states listed to this point | 10 | MANDATORY | |
old_tot | Previous total EVs of member states listed to this point | 0 | MANDATORY for start events other than the given state joining the compact. (Makes a continuous line over segments belonging to the same state) | |
Dates (start or end date may be inferred from a signle date parameter as described below.) |
start | Start date of the segment (MM/DD/YYYY) | 04/10/2007 | At least one date parameter is needed; see below |
end | End date of the segment (MM/DD/YYYY) | 01/01/2011 | ||
census | Year of most recent census (YYYY) | 2000 | ||
Label adjustments (optional) | x-offset | Position offsets of the state label, as a percent of the chart width | -1 | Use to avoid overlapping labels |
y-offset | 0.5 |
Sample bar segment
sửa| {{item | MD | 10 | 10 | old_tot = 0 | start = 04/10/2007 | end = 01/01/2011 | census = 2000 | x-offset = -1 | y-offset = 0.5}}
(Note that the bar segment comprises a single argument to the parent template)
Date parameters
sửaBar segments require at least one of the three date parameters. If either the start date or end date is not given, the bar segment will start or end at the previous or the following reapportionment date, respectively. If neither date is specified, a census year must be specified instead, and the segment will span between subsequent reapportionments.
The start and end dates of the segment are set as follows:
Inputs given | Output | |
---|---|---|
segment starts at: | segment ends at: | |
"start" and "end" | specified start date | specified end date |
"start", but not "end" | specified start date | date of the following reapportionment3 |
"end", but not "start" | date of the previous reapportionment3 | specified end date |
"census" only | date of reapportionment for the specified year3 | date of the following reapportionment |
- 3.^ Reapportionment is considered to take place at the end of the census year.
Sub-templates
sửaThe following templates exist for use by this template, and should not be called outside this template.
- {{NPVIC chart/bar}} – creates a bar segment for a given state within a specified date range
- {{NPVIC chart/annotation}} – creates annotations of key events
- {{NPVIC chart/stripe}} – creates gray bars on alternating years
- {{NPVIC chart/x-axis}} – creates horizontal markers
- {{NPVIC chart/y-axis}} – creates vertical markers
- {{NPVIC chart/percent}} – utility template; calculates the horizontal position of a given date as a percentage of the graph's width