Template:Composition bar/doc: Difference between revisions

m
60 revisions imported from wikipedia:Template:Composition_bar/doc
(update to High use template)
m (60 revisions imported from wikipedia:Template:Composition_bar/doc)
 
(15 intermediate revisions by 8 users not shown)
Line 1:
{{Documentation subpage}}
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE -->
{{high-use| +3,5004913 }}
 
This template displays the numeric composition of a thing in terms of its sub-units. For example, it is frequently used as part of {{tl|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]]. A textless, single line, flexible width version of this template is available at [[Template:Composition bar textless]].
 
== Usage ==
:<code> <nowiki>{{</nowiki>Composition bar|''amount''|''total''|''bar-color''|color=''coloroptions...''|background-color=''background-color''|per=0/1<nowiki>}}</nowiki></code>
 
; amount
:<code><nowiki>{{</nowiki>Composition bar|''amount''|''total''|''bar-color''|color=''color''|background-color=''background-color''|per=0/1<nowiki>}}</nowiki></code>
*: ''amount''The first parameter is the number of sub-units.
; total
*: ''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 colors|web color]], which can be specified by name, as a [[hex triplet]] (#rrbbgg), or rgb triplet (rgb(0–255,0–255,0–255)).<br />In the case of political parties, most will have their logo color available in {{tlc|political party/meta/color}} templates.
 
Additional display options:
* ''amount'' is the number of sub-units
; background-color=...
* ''total'' is the total number of sub-units possible
* ''bar-color'': (default is light greytransparent) is the background color of the leftright part of the bar - a valid [[web colors|web color]], which can be specified by name, as a [[hex triplet]] (#rrbbgg), or rgb triplet (rgb(0–255,0–255,0–255)).<br />In the case of political parties, most will have their logo color available in {{tld|political party/meta/color}} templates.
; border=...
* ''color'' (default is black) is the text colour - a valid [[web colors|web color]].
* ''background-color'': (default is very lightmedium grey) is the background color of the rightborder, partor of"none" thefor barno - a valid [[web colors|web color]].border
; width=...
* ''width'' is the width of the bar in px.
* ''per'': (default is false100px), whena setwidth tovalue 1for (true)the bar, addssuch aas percentage"100%" toor the"8em" bar(unitless numbers are interpreted as well.px)
; per=...
 
: (default is false), when set to any value (true), adds a percentage to the bar as well
If the bar-colour is dark, then the text may have insufficient contrast to show clearly for some readers. The text colour may be changed to white by specifying the color parameter. The background colour for the right part of the bar may then be too light to give sufficient contrast with white text, in which case the background-color parameter may be used to provide a dark background for that part of the bar. See the first three examples below. [http://snook.ca/technical/colour_contrast/colour.html Snook's Colour Contrast Check] may be used to check compliance with [[WCAG]] guidelines for contrast.
; ref=...
: (default is blank), may be used to add a reference/citation for the numbers.
 
== Examples ==
 
{|
|-
Line 28 ⟶ 35:
| {{Composition bar|50|100|red}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|50|100|red|background-color=#FFFDDD|border=none}}</nowiki></code>
| {{Composition bar|50|100|red|background-color=#FFFDDD|border=none}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|50|100|red|color=#FFF99F|background-colorwidth=#00085%}}</nowiki></code>
| {{Composition bar|50|100|red|color=#FFF99F|background-colorwidth=#00085%}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|50|100|#99F}}</nowiki></code>
| {{Composition bar|50|100|#99F}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|50|100|{{Green Party (UK)/meta/color}}}}</nowiki></code>
Line 43 ⟶ 47:
| {{Composition bar|50|100|rgb(255,255,16)}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|75|100|#FF0|width=250}}</nowiki></code>
| {{Composition bar|75|100|#FF0|width=250}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|40|100|#F00|width=300|per=1}}</nowiki></code>
| {{Composition bar|40|100|#F00|width=300|per=1}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|90|100|#F0F0F0|width=300|per=21|background-color=#F00}}</nowiki></code>
| {{Composition bar|90|100|#F0F0F0|width=300|per=21|background-color=#F00}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|90|100|#F0C|width=300|per=1|color=#FFF}}</nowiki></code>
| {{Composition bar|90|100|#F0C|width=300|per=1|color=#FFF}}
|-
| style="font-size: 95%"| <code><nowiki>{{Composition bar|500|10026|hex=#99F00BFFF|per=1}}</nowiki></code>
| {{Composition bar|500|10026|hex=#99F00BFFF|per=1}}
|}
 
Line 60 ⟶ 67:
 
<templatedata>
 
{
"description": "A composition bar.",
Line 79 ⟶ 85:
"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 {{political party/meta/color}} templates.",
"default": "#CCCCCCCCC",
"type": "string/line",
"required": false,
"aliases": ["hex"],
},
"Text background-color": {
"label": "Background color",
"description": "The textbackground colourcolor of the right part of the bar - a valid web color.",
"default": "#000transparent",
"type": "string/line",
"required": false
},
"Background colorborder": {
"label": "background-Border color",
"description": "The background color of the rightborder, partor of'none' thefor barno - a valid web color.border",
"default": "#F0F0F0AAAAAA",
"type": "string/line",
"required": false,
"labelaliases": ["border-color",]
},
"Widthwidth": {
"label": "widthWidth",
"description": "The width of the bar inwith units, such as 100% or 10em (unitless numbers are interpreted as px.)",
"default": "100px",
"type": "string/line",
"required": false
},
"Show Percentper": {
"label": "perShow percent",
"description": "When set to 1 (true), adds a percentage to the bar as well.",
"default": "0",
"type": "string/line",
"required": false
},
"Border width": {
"label": "border-width",
"description": "Determines the thickness of the border around the box in px.",
"default": "1px",
"type": "string/line",
"required": false
},
"Border color": {
"label": "border-color",
"description": "Determines the color of the border around the box - a valid web color.",
"default": "#C0C0C0",
"type": "string/line",
"required": false
Line 128 ⟶ 121:
}
}
 
</templatedata>
 
Line 138 ⟶ 130:
 
<includeonly>{{When on basepage
| <!-- CATEGORIESCategories BELOWbelow THISthis LINE,line; PLEASE:interwikis at Wikidata -->
[[Category:Chart, diagram and graph templates]]
[[Category:Wikipedia progress templates]]