Template:Canadian election result/doc

The template Canadian election result is intended to create tables showing the election or by-election results in one riding. It can be used on the pages of the ridings, of the candidates, or on template pages that are transcluded onto both. It works in conjunction with five other templates: Canadian election result/top, Canadian election result/total, Canadian election result/gain, Canadian election result/hold, and Canadian election result/source. This template can duplicate the functions of all of the 53 existing federal and provincial CanElec templates.

/top template
Begin each table with Canadian election result/top.

The first thing that needs to be specified is whether this is a federal election, or provincial or territorial.

Use the standard two-letter codes for postal abbreviations or second-level domains of the  country-code domain. A table is given at the bottom of this page.

General format
Use. The jurisdiction field should be the two-letter code and the election field should be the year.
 * Basic form

For example,  gives:

Use. The  field can be omitted when the riding's article name does not contain disambiguation.
 * With riding name

For example,  gives:

Extra columns can be added to provide additional dato. For example,  gives:
 * With extra data columns:

General parameters

 * first unnamed parameter; or
 * This is a two-letter code. Valid two-letter codes correspond to the standard postal abbreviations or second-level domains of . Note that for Newfoundland and Labrador elections before 2001, the code is   rather than.


 * second unnamed parameter or
 * This is the four-digit year for a general election, or some other text (for example a full date) for a by-election.


 * third unnamed parameter or
 * This is the full title of a Wikipedia article about a riding. For example:
 * Note that Canadian federal ridings often use an em dash naming convention (for example: Brome—Missisquoi). Other jurisdictions may have different conventions; for instance, Quebec provincial ridings use an en dash instead, and only if hyphens already occur elsewhere in the name (eg, Drummond–Bois-Francs, but Brome-Missisquoi).


 * (optional) fourth unnamed parameter or
 * This is the displayed text for the riding name, if different from the above. For example:

Optional parameters

 * by=yes
 * Use for by-elections. When using this, give the full date of the by-election rather than just the year.


 * reason=
 * Explain the reason for the by-election. For example,.


 * percent=yes
 * Use this parameter to add a column with the heading "%".


 * change=yes
 * Use this parameter to add a column with the heading "∆%".


 * expenditures=yes
 * Use this parameter to add a column with the heading "Expenditures".


 * elected=yes
 * Use for multi-member ridings that elect multiple members off of one ballot to add a column with the heading "Elected".


 * 1st=yes|percent=yes|final=yes|percent2=yes
 * Use these parameters to create columns for multi-round elections.


 * ballot=A or ballot=B or ballot=C
 * Use one of these parameters for multi-member ridings that run multiple ballots each with a different slate of candidates during each election. It will only change the links in the heading.


 * collapsed=
 * The table is by default collapsible. You can set the initial collapsedness as follows: ,  , or  . These correspond to initial states of "collapsed", "autocollapse", or none, as documented at Help:Collapsing. For instance, if an article about a riding has a long list of election results from years past, you may want to have the first one display (for the most recent election) but keep the previous election years collapsed.

Main template
Use a copy of this template, Canadian election result, for each row. The basic version of template is. The jurisdiction must be the two-letter provincial code or "CA" for federal elections. The party name must match the format of party names in the "input text" column of the master list of parties. The candidate name can be wikilinked if the article exists. The full version of this template is. The last three fields are optional, and what should be put in them depends on what headers were used. For multi-member ridings, use  to add a checkmark in the "Elected" column.

/total template
Use a copy of this template, Canadian election result/total, for each total row (for example, Total valid votes, Total rejected ballots, Total turnout). The full version of this template is. The last three fields are optional.

See Canadian election result/total documentation for instructions on how to find the data and complete the various total rows.

/gain and /hold templates
These templates can be used to identify gains and holds for the winning party, together with the swing calculated for the result compared to the previous election. The basic version of template is  and , with the jurisdiction and party input in the same way as in Canadian election result. The /gain template may additionally add the party that the seat was taken from in the third parameter.

Swing calculated using the formula ((∆%₁&minus; ∆%₂) ÷ 2&thinsp;) (i.e. Change in winner's percentage compared to previous year minus change in second place percentage divided by two)

For example,  produces:

/source and /note templates
These templates can be used to add a row to the bottom of the table. For example:. If the line of text contains an equals sign, as many government links do, name the field.

Links to multiple source can be added in an expandable “Source(s)}” section by assigning all the links to the parameter  (create separate lines by separating each source with ).

For example:  in a table produces:


 * }

end template
Finish election boxes with the end template.

Example
Here is an example using the federal riding of Ottawa Centre in the 2011 federal election. The code:

will produce: