Template:Composition bar/doc

From HasanistanPedia
< Template:Composition bar
Revision as of 14:22, 16 January 2022 by OIMGov (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This template displays the numeric composition of a thing in terms of its sub-units. For example, it is frequently used as part of {{Infobox political party}} to show the number of seats a given political party holds in a legislature. A single line, flexible width version of this template is available at Template:Composition bar compact.

Usage

{{Composition bar|amount|total|bar-color|options...}}
amount
The first parameter is the number of sub-units.
total
The second parameter is the total number of sub-units possible.
bar-color
(default is light grey) The third parameter is the background color of the left part of the bar - a valid web color, which can be specified by name, as a hex triplet (#rrbbgg), or rgb triplet (rgb(0–255,0–255,0–255)).
In the case of political parties, most will have their logo color available in {{political party/meta/color}} templates.

Additional display options:

background-color=...
(default is transparent) is the background color of the right part of the bar - a valid web color.
border=...
(default is medium grey) is the color of the border, or "none" for no border
width=...
(default is 100px) a width value for the bar, such as "100%" or "8em" (unitless numbers are interpreted as px)
per=...
(default is false), when set to any value (true), adds a percentage to the bar as well

Examples

Code Result
{{Composition bar|50|100|red}}
<div style="background-color:rgb(Expression error: Unrecognized word "red".,0,0);width:50px;height:20px;">
50 / 100
{{Composition bar|50|100|red|background-color=#DDD|border=none}}
<div style="background-color:rgb(Expression error: Unrecognized word "red".,0,0);width:50px;height:20px;">
50 / 100
{{Composition bar|50|100|#99F|width=85%}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "#".,0,0);width:50px;height:20px;">
50 / 100
{{Composition bar|50|100|{{Green Party (UK)/meta/color}}}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "".,0,0);width:50px;height:20px;">
50 / 100
{{Composition bar|50|100|rgb(255,255,16)}}
<div style="background-color:rgb(Expression error: Unrecognized word "rgb".,0,0);width:50px;height:20px;">
50 / 100
{{Composition bar|75|100|#FF0}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "#".,0,0);width:75px;height:20px;">
75 / 100
{{Composition bar|40|100|#F00|per=1}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "#".,0,0);width:40px;height:20px;">
40 / 100
{{Composition bar|90|100|#F0F0F0|per=1|background-color=#F00}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "#".,0,0);width:90px;height:20px;">
90 / 100
{{Composition bar|90|100|#F0C|per=1}}
<div style="background-color:rgb(Expression error: Unrecognized punctuation character "#".,0,0);width:90px;height:20px;">
90 / 100

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Composition bar in articles based on its TemplateData.

TemplateData for Composition bar

<templatedata> {

   "description": "A composition bar.",
   "params": {
       "1": {
           "label": "1",
           "description": "The number of sub-units.",
           "type": "string/line",
           "required": true
       },
       "2": {
           "label": "2",
           "description": "The total number of sub-units possible.",
           "type": "string/line",
           "required": true
       },
       "3": {
           "label": "3",
           "description": "The background color of the left part of the bar - a valid web color, which can be specified by name, as a hex triplet (#rrbbgg), or rgb triplet (rgb(0–255,0–255,0–255)).  In the case of political parties, most will have their logo color available in Template:Political party/meta/color templates.",
           "default": "#CCCCCC",
           "type": "string/line",
           "required": false,
           "aliases": ["hex"]
       },
       "background-color": {
           "label": "Background color",
           "description": "The background color of the right part of the bar - a valid web color.",
           "default": "transparent",
           "type": "string/line",
           "required": false
       },
       "border": {
           "label": "Border color",
           "description": "The color of the border, or 'none' for no border",
           "default": "#AAAAAA",
           "type": "string/line",
           "required": false,
           "aliases": ["border-color"]
       },
       "width": {
           "label": "Width",
           "description": "The width of the bar with units, such as 100% or 10em (unitless numbers are interpreted as px)",
           "default": "100px",
           "type": "string/line",
           "required": false
       },
       "per": {
           "label": "Show percent",
           "description": "When set to 1 (true), adds a percentage to the bar as well",
           "default": "0",
           "type": "string/line",
           "required": false
       }
   }

} </templatedata>

See also