Jump to content

Template talk:Election results/Archive 2

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Archive 1Archive 2

Width parameter

Hi, I very much love this template and prefere it over Election boxes:))). However one thing Election boxes get right is the consistent overall width of the rendered tables. It would be great to be able to set the width of {{Election results}} to create clear, consistent articles, e.g. when using multible {{Election results}} one below the other in one article, like here in Senate Constituency no. 2. Setting the width parameter for the same value in all templates would resolve the issue of visually unpleasing tables with different widths. — Antoni12345 (talk) 18:54, 11 November 2023 (UTC)

Is this what you had in mind (i.e. being able to set a defined width for candidates and party columns)? Cheers, Number 57 14:16, 13 November 2023 (UTC)

Need Percentage of Total Electors

Add an additional value for the percentage (+/-) of Total Electors, calculated from the electors in the Previous Election. Make it simple.


|previouselectors=

and its not recommended for First elections of every state IJohnKennady (talk) 15:16, 26 November 2023 (UTC)

I don't think this is necessary, and it wouldn't fit in the table. Number 57 16:03, 26 November 2023 (UTC)

Inaccessible text in new night (dark) theme

If you visit https://en.m.wiki.x.io/wiki/2024_South_Korean_legislative_election?minervanightmode=1 you'll see Registered voters/turnout and Total votes display as gray text on a black background.

Could the following diff please be applied to fix this ?

http://en.wiki.x.io/w/index.php?title=Special%3AComparePages&page1=Module%3AElection+results&page2=Module%3AElection+results%2Fsandbox

Thanks in advance! 🐸 Jdlrobson (talk) 06:17, 13 April 2024 (UTC)

Module:Election results is fully protected. I've updated the request template from {{TPER}}.
I've tested {{Election results/sandbox}} in a preview in Minerva night mode and it seems to work for me. Plus the proposed change makes sense with regard to the neighboring code :css('background', 'inherit') and the page mw:Help:Lint errors/night-mode-unaware-background-color. —⁠andrybak (talk) 15:27, 13 April 2024 (UTC)
 Done For what it's worth I am not convinced this page really needs to be full protected. * Pppery * it has begun... 15:35, 13 April 2024 (UTC)
With <9k transclusions, I generally agree. Primefac (talk) 14:53, 15 April 2024 (UTC)
I've seen template-confirmed editors mess up other widely-used templates because they don't properly check the outcomes of their changes (it's amazing how many people don't check their changes in the sandbox) – for example, someone made a mess of {{Infobox election}} around a month ago. Due to the relatively high complexity of this module, a large number of testcases need to be checked when changes are made to make sure they don't inadvertently affect certain types of tables. With all this in mind, I would prefer this to remain fully-protected to make sure there is less chance of a big cock-up being made. Number 57 15:17, 15 April 2024 (UTC)
Hrm... that's a reasonable argument. Primefac (talk) 15:19, 15 April 2024 (UTC)

Showing alliance on constituency elections

in some countries, the larger alliance is as important as the original party. One example is Malaysia, the Nordic countries, India and the Philippines. Would it be possible to add a separate column for alliance? I hacked this by using parenthesis, such as "Nationalist People's Coalition (UniTeam Alliance)" in Template:2022 Philippine Senate election results. Ideally a possible "Alliance" column is beside the "Party" column, either before or after. Howard the Duck (talk) 13:19, 2 May 2024 (UTC)

You can already do this – see below. Cheers, Number 57 00:10, 4 May 2024 (UTC)
Thanks! Would it be possible, if alliances are used, to default to the party if left blank? Howard the Duck (talk) 17:41, 4 May 2024 (UTC)
Yes, if you use the alliance field but not party (you can put either a party or an alliance in the alliance field), it will appear as the second table below. Number 57 20:18, 4 May 2024 (UTC)
Great. This should work and would align this with the actual per party results table. Howard the Duck (talk) 05:03, 5 May 2024 (UTC)
CandidateAlliance and partyVotes%
Robin PadillaUniTeam AlliancePDP–Laban26,612,43452.31
Loren LegardaMP3 AllianceNationalist People's Coalition24,264,96947.69
Total50,877,403100.00
CandidateAlliance and/or partyVotes%
Robin PadillaUniTeam AlliancePDP–Laban26,612,43452.31
Loren LegardaNationalist People's Coalition24,264,96947.69
Total50,877,403100.00

Possible bug when votes against are unknown

In the 1986 Czechoslovak parliamentary election article, the table seems to add an extra column when the number of votes against, using the row2 and votes2 fields, is unknown. --Minoa (talk) 19:50, 19 May 2024 (UTC)

Sorted. Cheers, Number 57 20:52, 19 May 2024 (UTC)

Adding # (ranks)

This would be hanby for multiple winner elections. I just dunno how it should be done as the color column is at the leftmost corner. Just make it optional, as the default should be the unnumbered version. Howard the Duck (talk) 13:19, 6 January 2024 (UTC)

So I tried this out at Template:1946 Philippine Senate election results (sorry guys I know you wanted that to be deleted LOL) and there seems to be something missing for this type of election:

  1. It doesn't show you who won. Let's imagine the reader knows nothing about this election. Okay, I suppose the candidate at the top won, but if this was a single-winner election, how come there are so many votes, with more votes than the people who voted?
  2. I suppose the percentages should be based on the turnout and not on the total votes, but I've seen similar elections use the total votes as the dividend.
  3. For these types of elections, the top x candidates win, so having a "Rank" column is a good visual cue.

I know there's a two-seat variant of this template but it doesn't work for 3+ winners in an election. Howard the Duck (talk) 21:21, 1 September 2021 (UTC)

You can add background colours for rows – see e.g. 1990 Slovenian presidential election#Presidency, and you can manually add bolding to candidate and party names.
There may be a way to refactor percentages for candidate elections where people can vote for more than one, but what would the total figure for use of calculation be – would it be total votes cast for candidates or total number of voters casting valid votes (some voters may not use all their votes)? The total as it appears at the bottom would still be the total of votes cast for candidates, but I don't think this is an issue if you've got the valid votes line – there are many countries where the vote totals for parties are far larger than the electorate as voters have multiple votes (e.g. this or this). Not sure about adding a ranking column – potentially quite a bit of extra coding.
Ultimately it won't be possible or worth it to adjust the template for every possible layout – while going through different countries to convert to this template, I've formatted some using wikitables because only a tiny number of tables would look like that and it's not worth the extra coding. Cheers, Number 57 21:41, 1 September 2021 (UTC)
Background colors: I know you guys are talking about changing up the party color templates, but that Slovenian example has the same exact similar color to Template:Nacionalista Party/meta/color (LOL), and I've been trying to change that but the last time I did that, someone reverted because "We're using it here everywhere".
Also, I tried these out, and it doesn't work unless you change |cand to |row, but that got rid of the party column. Howard the Duck (talk) 22:04, 1 September 2021 (UTC)
It depends per election authority. I checked out Manx elections, which used an identical format, and they divided by total number of votes cast (therefore the current setup should give out the same results). On Philippine elections interestingly, these are normally not presented with percentages. I suppose there can be a way to turn off this feature? Here at Wikipedia, Philippine Senate elections have always been presented with percentages, but are never presented that way elsewhere. I'm actually interested on how election authorities do this. Howard the Duck (talk) 21:55, 1 September 2021 (UTC)
The row background colour is your choice; it isn't hardcoded to be that shade of green, I've just input that because that's what was used on the previous wikitable version. But good point re it only working on rows – that can be fixed. The percentage column could be hidden; I'll have a look at how much code that would take if you want. Number 57 22:23, 1 September 2021 (UTC)
Yeah, I was more gunning on a yellow color, as that what is being used. Just keep us updated once this is fixed up. Howard the Duck (talk) 22:32, 1 September 2021 (UTC)
Related question: For "partyx", is it supposed to be the full name of the party, the short name, or wherever the article name is at (except for disambiguation). Howard the Duck (talk) 21:59, 1 September 2021 (UTC)
You can pipe in whatever name you like; the meta color is called using the link, so as long as that is correct, how you pipe it is irrelevant (Zimbabwe African National Union – Ndonga and ZANU–Ndonga both call the meta color). However, if you're not linking, then you need the full party name to get the meta color to work. Number 57 22:23, 1 September 2021 (UTC)
Is there like a rule, or is it totally upon the discretion of anybody who's editing? If we're using US parties, is it recommended to be as "Democratic" or "Democratic Party" (or even "D")? Howard the Duck (talk) 22:32, 1 September 2021 (UTC)
There isn't a rule as far as I'm aware. There may be consensus for individual countries in their respective politics projects. Personally I would always go for the full name of the party unless it's significantly longer than the others and distorts the table. 'Democratic' is fine for an infobox summary, but I don't think is appropriate in a table.
Separately I've fixed the background colour for rows using 'cand1' etc. Will try and do the hiding percentages thing soon. Number 57 13:40, 11 September 2021 (UTC)

@Howard the Duck: The functionality to refactor percentages for elections where voters can cast multiple ballots has now been added. If you use the 'divisor' function, it will refactor the percentage column into a % of valid votes cast (rather than total votes cast for all candidates). See an example at 1866 Surinamese general election. Cheers, Number 57 21:50, 6 February 2024 (UTC)

Thanks. Can we add an optional "#" leftmost column? In MNTV elections, the percentages or vote totals don't really matter, but on how you ranked in the tally. Howard the Duck (talk) 22:02, 6 February 2024 (UTC)
I'd suppose there can also be an option to remove percentage column entirely. Howard the Duck (talk) 23:15, 6 February 2024 (UTC)
Just to clarify, would the rank column be before the party colour one like this? It somehow seems a bit disjointed. Also, given tables are already ranked in order of votes received, what would be the purpose of the rank column?
# Candidate Party Votes %
1 Bill Jones Conservative Party 13,000 51.00
2 Eric Smith Independent 12,000 49.00
Separately, removing the percentage column would potentially require quite a lot of code to be added to hide the columns in multiple parts of the table (as currently the % column automatically appears if the votes column is used). However, you can effectively do the same thing already by hacking the template slightly, as below. Number 57 16:26, 7 February 2024 (UTC)
Yeah, I thought about the color column and the rank column and yes, it does look disjointed. However, I'd be ok with this if only we'd only show the rank column on multiple winner elections like MNTV and SNTV. I've peeked at WP:FLs, and the colour column, if there's a rank column, is quite far away from it; one colors the "#" column with the party color, but I won't recommend this. One more way is to put the color and the party columns together, but I've seen several election results tables that indeed show the color as the leftmost column (then again, those are single-winner elections), so people may be used to it, and expect it to be within that area of the results table.
Re: The purpose -- for MNTV and SNTV, the winners are for the top X positions; the rank column allows the reader to visually know who among the top X are; in jurisdictions where this type of election is being used, the specific value of X has become somewhat drilled into brains of voters, like "I need X names for this position".
One another way is boldfacing entire rows in results tables, like the old election tables, but it doesn't give you at first glance how many seats are contested in this "district". In cases such as 2023 Amber Valley Borough Council election, this is rather easy, as the winners are the top 2-3. In cases such as 2022 Calamba City Council elections, it's not readily apparent (I think it's 12, and I wasted 10 seconds of life counting it). Howard the Duck (talk) 22:12, 7 February 2024 (UTC)
Re hack: This hack removes the party column, which is pretty essential. If hiding the % is too hard to do, I'd be ok with keeping it. Howard the Duck (talk) 22:12, 7 February 2024 (UTC)
The hack doesn't get rid of the party column – I just didn't include it in the example – now added in to demonstrate it works.
It is also possible to add background colour to rows (like in 2004 Norfolk Island legislative election) to demonstrate who was elected (which I think is much clearer way of demonstrating who was successful than bolding). But I will have a go at adding a # column in the near future. Cheers, Number 57 22:20, 7 February 2024 (UTC)
i'd prefer bolding or even a checkmark than coloring an entire row (considering I've done that before lol) as we already color a cell for the party. This isn't like sports tables where we don't color an entire column.
I like how the hack looks like now tho. Let me know how you want this done (by numbers, bolding or coloring then let's see how it works in actual usage. Howard the Duck (talk) 00:13, 8 February 2024 (UTC)
It's in the code below. I used the seats function for the votes (and changed the title of the column using the |seatstitle parameter). Cheers, Number 57 23:00, 8 February 2024 (UTC)
Is there a way to have the winners be made to stand out other than manually boldfacing every entry? Howard the Duck (talk) 22:52, 10 February 2024 (UTC)
CandidatePartyVotes
Candidate AParty A34,390
Candidate BParty B25,440
Candidate CParty C10,101
Total69,931

Alliance

Hello, I was wondering if some change could be done to make the table less bulky when there's alliance. Currently, the tables look like this :

Party or allianceVotes%Seats
Union for the HomelandUnion for the Homeland8,252,35736.5948
Civic Front for Santiago378,2461.684
Más para Entre Ríos293,6051.302
Front for the Renewal of Concord252,3351.123
Unión por San Luis83,1780.371
Renewal Front38,7700.170
Total9,298,49141.2358
La Libertad AvanzaLa Libertad Avanza5,804,50225.7428
Ahora Patria305,3971.352
Republican Force286,5941.271
Federal Renewal Party152,8530.681
Arriba Neuquén136,2900.601
Faith Party126,8790.561
Republicanos Unidos [es]30,5340.141
Total6,843,04930.3435
Juntos por el CambioJuntos por el Cambio5,519,16524.4727
Cambia Mendoza [es]287,0201.271
Juntos por Entre Ríos269,1891.191
ECO [es]–Vamos Corrientes222,0060.981
Cambia Jujuy [es]96,1580.431
Cambia Santa Cruz18,5950.080
Total6,412,13328.4331
Total22,553,673100.00124

Don't you think the tables would look better like this ?

Party or alliance Votes % Seats
Union for the Homeland 8,252,357 33.62 48
Civic Front for Santiago 378,246 1.54 4
Más para Entre Ríos 293,605 1.20 2
Front for the Renewal of Concord 252,335 1.03 3
Unión por San Luis 83,178 0.34 1
Renewal Front 38,770 0.16 0
Total Union for the Homeland 9,298,491 37.88 58
La Libertad Avanza 5,804,502 23.65 28
Ahora Patria 305,397 1.24 2
Republican Force 286,594 1.17 1
Federal Renewal Party 152,853 0.62 1
Arriba Neuquén 136,290 0.56 1
Faith Party 126,879 0.52 1
Republicanos Unidos [es] 30,534 0.12 1
Total La Libertad Avanza 6,843,049 27.88 35
Juntos por el Cambio 5,519,165 22.48 27
Cambia Mendoza [es] 287,020 1.17 1
Juntos por Entre Ríos 269,189 1.10 1
ECO [es]–Vamos Corrientes 222,006 0.90 1
Cambia Jujuy [es] 96,158 0.39 1
Cambia Santa Cruz 18,595 0.08 0
Total Juntos por el Cambio 6,412,133 26.12 31
Total' 22,553,673 100.00 124

I feel like this would be even more needed when in many countries, alliances often have quite long names, like the french New Ecological and Social People's Union. But I aknowledge that I wouldn't know how to implement this change even if it get approved here. Cordially. Aréat (talk) 01:50, 8 March 2024 (UTC)

These tables aren't that wide, so I don't really see the need to remove an entire column. It's also somewhat confusing with the two bars of colour, especially if you're not reading a "here's what I changed" description right before. Also slightly concerned about how clear this is for screen readers.
On the other hand, backend code wouldn't be too difficult to rearrange. Primefac (talk) 15:51, 8 March 2024 (UTC)
In the second version, I don't think the arrangement of alliances is clear enough. The double column of colours is quite confusing, and only at the bottom do you find out that there is a total (and it's still not clear there that this is an alliance). Number 57 15:57, 8 March 2024 (UTC)

STV elections example

Hi, I'm happy to help with the coding (I know Julia, which is pretty similar to Lua), but I'm not familiar with this template or how it works.

Could the template be modified to handle STV elections? I think Template:STV Election box begin &co were used for this a few times, but they're a mess (everything strewn around 4 or 5 different templates and with none of the features of the election box template).

An STV template would need to:

  1. Allow for >2 rounds,
  2. Keep the total number of votes fixed across rounds (because the total number of ballots doesn't change),
  3. Indicate eliminations (e.g. with a red X mark),
  4. Indicate transfers (i.e. the change in each candidate's vote total from round-to-round).

Closed Limelike Curves (talk) 20:29, 20 March 2024 (UTC)

I don't think so as adding additional rounds requires a large amount of additional code and STV elections can go on for well over ten rounds. It would likely be easier to create a separate module that mirrors the style of this one, but only has the code for multiple vote rounds and doesn't have to factor in multiple combinations of seats/alliances/DSV etc. Number 57 20:53, 20 March 2024 (UTC)
Makes sense, thanks! Closed Limelike Curves (talk) 00:39, 21 March 2024 (UTC)
Oh, hmm, wait; it looks like it can already handle 3 rounds, so isn't it possible to just extend whatever loop generates the second/3rd/etc. rounds?
I'm interested in smaller elections (>10 round elections shouldn't really be displayed in a table like this, which will just get cluttered or confusing). I'm really just looking for something that can handle maybe 5 or 6 rounds. Closed Limelike Curves (talk) 15:48, 21 March 2024 (UTC)
It doesn't work on a loop basis. Every round has to have its own coding, and it's not just for the candidate rows, but also the headings, total votes, invalid votes, blank votes, electorate etc. Also, what you're proposing would require the existing round rows to be modified, which would add even more code.
If you're going to have a results template that works for STV, it should be done properly and be able to cover all sizes of STV elections, not just ones that one particular editor is interested in. Number 57 18:06, 21 March 2024 (UTC)

I also think a separate template would be better. I don't know how to do the template code, but I did some manual code tables for such election on the french speaking wiki, for example here and here, if it may help. One particularity that shouldn't be forgotten is the existence of the cumulative exhausted votes, starting with the second "round". Cordially. --Aréat (talk) 09:48, 4 May 2024 (UTC)

I've started developing {{Election results-STV}}. See how it works here - there are options to include or exclude percentages. There is one last thing I need to fix (the 'Total' row not appearing properly on the version without party names), otherwise I think it is nearly ready to go (the other thing I have not decided on is whether to include gridlines on exhausted rows. Comments welcome of course! Number 57 13:44, 4 May 2024 (UTC)
Oh, that's awesome, I didn't knew a template was already done this far. Well done!
If you wan't feedback, I find it clearer to understand the results when the rows of eliminated candidates just end and then are empty on their right side while the rows of the candidates still "in" continue to be filled. But that's just my two cents.
More importantly, from your example, it seem to me the fist count column should have the exchausted row filled with a "–" on both Votes and % subcolumns, not just %, so that it doesn't feel like the data is missing (by definition there can't be exhausted ballots in the first count).
And I'm a bit wary of your decision to show percentages with the exhausted. It really should have a "–" as well. As far as I know, exhausted votes are never part of the percentage calculation for the remaining candidates. They're out of the count. That's why on my manual tables I even placed them under the total of remaining votes. (They're still included in the total of valid votes anyways).
Finally, if you keep it above, I believe you will have to make the exhausted votes row be cumulative and indicate it as such, otherwise the total won't hold. Cordially.--Aréat (talk) 23:30, 4 May 2024 (UTC)
I hadn't done any special code for the exhausted row as I am not sure how it is normally shown. In the testcase I just created a normal row with the name 'Exhausted'. I'm open to ideas about how it could work, or whether it's even needed. Number 57 01:12, 5 May 2024 (UTC)
Wow, that looks amazing @Number 57! Thank you so much for all your hard work on this :)
From what I can tell, exhausted ballots are typically included in English Wikipedia infoboxes and IRV election results. Examples include 2009 Burlington mayoral election (disclosure: I made this one) along with 2018 Irish presidential election (I didn't make that one, and the rule is applied consistently across Irish elections).
Exhausted ballots are typically "out of the count" in that they can't affect the results anymore, but still meaningful in that they usually indicate "dissatisfied voters" (ones who are unhappy with all remaining candidates).–Maximum Limelihood Estimator 02:44, 5 May 2024 (UTC)
I'm a bit confused about what you say, as there were no exhausted ballots in the 2018 Irish presidential election as Higgins won on the first count, while for 2011 Irish presidential election (in which there were), they are not listed. From the STV election articles I've seen, exhausted ballots are not generally included. Number 57 02:55, 5 May 2024 (UTC)
I don't doubt many STV pages don't have exhausted votes, the same way many STV pages don't even have the different counts, only the first and last ones. Compare the table in the Huon consistency on the 2022 Tasmanian Legislative Council periodic election and its page on the french wiki. That's why a proper table is needed, to make it easy to actually add all the right info. Another example showing exhausted row done right, in my opinion, would be 2018 Guernsey electoral system referendum. The amount of such votes show why the percentage isn't included toward the percentages of the actual options. Cordially. --Aréat (talk) 11:00, 5 May 2024 (UTC)
In the context of Australian elections, ballots can't become exhausted during the count, because Australia requires full rankings (so the number of exhausted ballots is 0).
The main issue with excluding exhausted ballots from the percentages is that, depending on context and rules for counting, exhausted ballots can affect the results. This is especially true in STV elections (where they can affect the quota), and is also true of voting systems other than IRV. –Maximum Limelihood Estimator 16:12, 5 May 2024 (UTC)
Sorry, I meant the 2011 one!
WRT the 2011 election, I was referring to the infobox. –Maximum Limelihood Estimator 14:38, 5 May 2024 (UTC)
Exhausted votes definitely exist in Australia. In the example used above, Tasmania, many elections have exhausted votes, for example here in 2018. Not all states require full ranking. New South Wales, for example, doesn't require it for its legislative council. The election of 21 of its members only require voters to mark up to 15 candidates [1], [2]. Anyways, it's important to have a row. I go back on my previous statement, though, as there do seem to be some place like Ireland where indeed they're included in the count. In 2011, a candidate had to gain half of 1,771,762 valid votes, so 885,882. A candidate could thus have 50 % of the remaining non exhausted votes and not be elected until getting that number in a further round. So, the template should simply allow for exhausted votes to be included in the percentages, or not be included. It all depend on the voting system, which varies. Cordially.--Aréat (talk) 19:18, 5 May 2024 (UTC)
Manually, the table for the irish 2011 election look like this, for example.--Aréat (talk) 19:40, 5 May 2024 (UTC)
Ooh, I really like this. Thanks! :) –Maximum Limelihood Estimator 19:55, 5 May 2024 (UTC)
Do you happen to have time to test Number57 template above on the irish election results to see how it compare? :] --Aréat (talk) 14:41, 10 May 2024 (UTC)
Apologies, I will try and sort it this weekend. Just moved house and well behind on my watchlist! Number 57 22:59, 10 May 2024 (UTC)
I was asking Maximum! Since he seemed very enthusiasmed by it. You already did a great job as far as I can see. No problem, take your time. --Aréat (talk) 12:14, 11 May 2024 (UTC)