Template:Composition bar: Difference between revisions
(Undid revision 384099761 by Plastikspork (talk)) |
(rewrite - larger easier to read numbers) |
||
Line 1: | Line 1: | ||
<div style="border-style:solid;border-width:1px;border-color:#c0c0c0;background-color:#f0f0f0;width:100px;height:20px;"><div style="background-color:{{#if:{{{hex|}}} |
|||
{{#tag:timeline | |
|||
|{{{hex|#AFD4F0}}} |
|||
ImageSize = width:100 height:25 |
|||
|rgb({{{3|255}}},{{{4|0}}},{{{5|0}}})}};width:{{#expr:floor(100*{{{1|50}}}/{{{2|100}}})}}px;height:20px;"><div style="font-weight:bold;width:100px;height:22px;" align="center">{{formatnum:{{{1|1}}}}}/{{formatnum:{{{2|100}}}}}</div></div></div><noinclude> |
|||
PlotArea = left:0 bottom:0 top:0 right:0 |
|||
TimeAxis = orientation:horizontal format:yyyy |
|||
DateFormat = x.y |
|||
Period = from:0 till:{{{2|100}}} |
|||
TimeAxis = orientation:horizontal |
|||
AlignBars = early |
|||
Colors = |
|||
id:gray value:rgb(0.85,0.85,0.85) |
|||
id:barcolor value:{{#if:{{{hex|}}} |
|||
|rgb({{#expr:{{Hex2dec|0x{{str sub|{{{hex}}}|1|2}}}}/255 round 4}},{{#expr:{{Hex2dec|0x{{str sub|{{{hex}}}|3|2}}}}/255 round 4}},{{#expr:{{Hex2dec|0x{{str sub|{{{hex}}}|5|2}}}}/255 round 4}}) |
|||
|rgb({{{3|1}}},{{{4|0}}},{{{5|0}}})}} |
|||
BarData = |
|||
bar:Wikipedias |
|||
PlotData= |
|||
bar:Wikipedias from:0 till:{{{2|100}}} color:gray width:0.2in text:/{{{2|100}}} |
|||
bar:Wikipedias from:0 till:{{{1|50}}} color:barcolor width:0.2in text:{{{1|50}}} |
|||
}} |
|||
<noinclude> |
|||
{{Documentation}} |
{{Documentation}} |
||
</noinclude> |
</noinclude> |
Revision as of 20:31, 2 October 2010
This template is used on approximately 7,100 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
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. A textless, single line, flexible width version of this template is available at Template:Composition bar textless.
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
- ref=...
- (default is blank), may be used to add a reference/citation for the numbers.
Examples
Code | Result |
---|---|
{{Composition bar|50|100|red}}
|
50/100 |
{{Composition bar|50|100|red|background-color=#DDD|border=none}}
|
50/100 |
{{Composition bar|50|100|#99F|width=85%}}
|
50/100 |
{{Composition bar|50|100|{{Green Party (UK)/meta/color}}}}
|
50/100 |
{{Composition bar|50|100|rgb(255,255,16)}}
|
50/100 |
{{Composition bar|75|100|#FF0}}
|
75/100 |
{{Composition bar|40|100|#F00|per=1}}
|
40/100 |
{{Composition bar|90|100|#F0F0F0|per=1|background-color=#F00}}
|
90/100 |
{{Composition bar|90|100|#F0C|per=1}}
|
90/100 |
{{Composition bar|0|26|hex=#00BFFF|per=1}}
|
0/26 |
TemplateData
TemplateData for Composition bar
A composition bar.
Parameter | Description | Type | Status | |
---|---|---|---|---|
1 | 1 | The number of sub-units. | Line | required |
2 | 2 | The total number of sub-units possible. | Line | required |
3 | 3 hex | 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.
| Line | optional |
Background color | background-color | The background color of the right part of the bar - a valid web color.
| Line | optional |
Border color | border border-color | The color of the border, or 'none' for no border
| Line | optional |
Width | width | The width of the bar with units, such as 100% or 10em (unitless numbers are interpreted as px)
| Line | optional |
Show percent | per | When set to 1 (true), adds a percentage to the bar as well
| Line | optional |