Wikipedia:Lua/Modul/Vorlage:plebiscite-graph/en

Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English Modul: Dokumentation

Usage

This module generates horizontal, stacked bar charts within a right-aligned, grey infobox. It is designed to provide a clear visualization of the overall results of plebiscites in the lead section of a Wikipedia article. The chart displays the number of valid votes cast, invalid votes, and non-voters. It consistently indicates the required majority threshold and can optionally display a voting quorum.

The module can generate up to 99 stacked bars if multiple proposals were voted on simultaneously. Each bar can represent up to 10 active voting options (plus invalid and non-voters), though two to three options are typically sufficient. The module includes an automatically generated legend and an optional field for sourcing.

Integration

The module is usually not called directly, but via a template: Skriptfehler: Ein solches Modul „ModuleName“ ist nicht vorhanden.

Parameters

General Settings

ParameterDescription
titleThe main title of the chart (required).
subtitleA smaller subtitle text below the main title.
sourceCitation appearing at the bottom of the chart. Supports templates like Template:Cite web.
legend_typeBy setting this parameter to "common" (gemeinsam), individual legends per bar are replaced by a single shared legend. Use this only if the same quorum/threshold types apply to all bars.

Data per Bar

The module supports up to 10 bars (b1 to b10). Parameters for the first bar can be specified without a prefix (e.g., `votes1`) or with `b1_` (e.g., `b1_votes1`). From the second bar onwards, the `bX_` prefix is mandatory.

ParameterDescriptionExample
bN_btitleTitle of the individual bar.b1_btitle = Adoption of Constitution
bN_optionNShort label for voting option N.option1 = Yes
bN_votesNNumber of votes for option N (1 to 20).votes1 = 450
bN_colorNHexadecimal color for option N. Defaults: #006600 (dark green) for option1, #CC0000 (red) for option2.color1 = #00FF00
bN_eligibleTotal number of eligible voters. If provided, the number of non-voters is calculated and displayed as "Abstention". This is mandatory if a quorum is to be displayed.eligible = 1000
bN_castTotal number of votes cast.cast = 800
bN_validNumber of valid votes. Note: If this value is set manually, only the first two vote groups (bN_votes1 and bN_votes2) will be included when displaying the valid votes in the chart. If there were more than two voting options, this parameter must not be set to ensure correct display.valid = 780
bN_invalidNumber of invalid votes.invalid = 20
bN_invalid_nameLabel for invalid votes. Defaults to "invalid" (ungültig).invalid_name = Abstention
bN_invalid_colorColor for invalid votes. Defaults to #FFFF66 (yellow).invalid_color = #99FFFF
bN_nonvoters_nameLabel for non-voters. Defaults to "Abstention" (Stimmverzicht).nonvoters_name = Non-voters
bN_nonvoters_colorColor for non-voters. Defaults to #333333 (dark grey).nonvoters_color = #FFFFFF

Thresholds and Quorums

ParameterDescriptionValues/Options
bN_thresholdThe value for the required majority marker line. Usually 50 for a simple majority or 66.66 for a two-thirds majority.threshold = 50
bN_threshold_typeDetermines if the majority is calculated based on votes "cast" (abgegeben) or "valid" (gültig) votes. Defaults to "valid".threshold_type = valid
bN_threshold_modeDetermines if the threshold value is relative (50 = 50%) or absolute (50 = 50 votes). Defaults to "relative".threshold_mode = relative
bN_threshold_legendSets a label for the threshold in the legend. If this parameter is not set, the threshold label is automatically generated from the other threshold details.threshold_legend = This is a custom legend text for the threshold.
bN_quorumEnables a second dashed marker for a voting quorum. Requires "present" (vorhanden) to activate.quorum = vorhanden
bN_quorum_valueSets the height/value of the quorum. Required if `quorum` is set.quorum_value = 25
bN_quorum_typeSets the type of quorum: Participation ("Beteiligung"), Approval ("Zustimmung"), or Veto ("Veto"). A Veto quorum swaps the display order to show "No" votes (votes2) first.quorum_type = Zustimmung
bN_quorum_modeDetermines if the quorum value is relative or absolute. Defaults to "relative".quorum_mode = relative
bN_quorum_legendSets a label for the quorum in the legend. If this parameter is not set, the quorum label is automatically generated from the other quorum details.quorum_legend = This is a custom legend text for the quorum.

Example

{{#invoke:ModuleName|bars
| title = 2100 Referendum
| subtitle = Official final result for the constitutional draft
| eligible = 1000
| cast = 600
| valid = 580
| votes1 = 400 | option1 = Yes | color1 = #006600
| votes2 = 180 | option2 = No | color2 = #CC0000
| threshold = 50
| quorum = vorhanden
| quorum_value = 25
| source = Official Election Commission
}}

Logic and Functionality

Dependencies

None.