Template:Composition bar: Difference between revisions

From CivWiki
Jump to navigation Jump to search
Content added Content deleted
(Use neutral default)
m (80 revisions imported from wikipedia:Template:Composition_bar)
 
(47 intermediate revisions by 17 users not shown)
Line 1: Line 1:
<div style="{{#ifeq:{{{width|}}}|auto||width: {{#iferror:{{#expr:{{{width|}}}}}|{{{width}}}|{{{width|100}}}px}};}}"><span class="nowrap">{{formatnum:{{{1|50}}}}} / {{formatnum:{{{2|100}}}}}{{#if:{{{per|}}}|&emsp;({{#expr:(({{{1|50}}}/{{{2|100}}})*100) round (-1*{{min|0|{{Order of magnitude|{{#expr:({{{1|50}}}/{{{2|100}}})*100}}}}}}) }}%)}}{{{ref|}}}</span><div role="img" style="{{#ifeq:{{{border|{{{border-color|}}}}}}|none||box-sizing: border-box; border: 1px solid {{{border|{{{border-color|#aaa}}}}}};}} {{#if:{{{background-color|}}}|background-color: {{{background-color}}};}} height: 1.15em; position: relative;"><div style="background-color: {{#if:{{Both|{{{4|}}}|{{{5|}}}}}
<div style="border-style:solid;border-width:1px;border-color:#c0c0c0;background-color:#f0f0f0;width:100px;height:1.5em;"><div style="position: absolute; background-color:{{#if:{{both|{{{4|}}}|{{{5|}}}}}
|rgb({{#expr:255*{{{3|255}}}}},{{#expr:255*{{{4|0}}}}},{{#expr:255*{{{5|0}}}}})
| rgb({{#expr:255*{{{3|255}}}}}, {{#expr:255*{{{4|0}}}}}, {{#expr:255*{{{5|0}}}}})
| {{{hex|{{{3|#CCCCCC}}}}}}
|{{{hex|{{{3|#CCCCCC}}}}}} }};width:{{#expr:floor(100*{{{1|50}}}/{{{2|100}}})}}px;height:1.5em;"></div><div style="position: absolute; font-weight:bold;width:100px;height:1.5em;text-align:center;z-index: 10;">{{formatnum:{{{1|50}}}}}&nbsp;/&nbsp;{{formatnum:{{{2|100}}}}}</div></div>{{#if:{{{4|}}}{{{5|}}}|[[Category:Political party article using RGB]]}}<noinclude>
}}; width: {{#expr:(({{{1|50}}}/{{{2|100}}})*100) round (-1*{{min|0|{{Order of magnitude|{{#expr:({{{1|50}}}/{{{2|100}}})*100}}}}}}) }}%; height: 100%;"></div></div></div><noinclude>
{{Documentation}}
</noinclude>
{{Documentation}}</noinclude>

Latest revision as of 21:10, 19 May 2021

50 / 100
Template documentation[view] [edit] [history] [purge]

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 (40%)
{{Composition bar|90|100|#F0F0F0|per=1|background-color=#F00}}
90 / 100 (90%)
{{Composition bar|90|100|#F0C|per=1}}
90 / 100 (90%)
{{Composition bar|0|26|hex=#00BFFF|per=1}}
0 / 26 (0%)

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Composition bar

A composition bar.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
11

The number of sub-units.

Linerequired
22

The total number of sub-units possible.

Linerequired
33 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.

Default
#CCCCCC
Lineoptional
Background colorbackground-color

The background color of the right part of the bar - a valid web color.

Default
transparent
Lineoptional
Border colorborder border-color

The color of the border, or 'none' for no border

Default
#AAAAAA
Lineoptional
Widthwidth

The width of the bar with units, such as 100% or 10em (unitless numbers are interpreted as px)

Default
100px
Lineoptional
Show percentper

When set to 1 (true), adds a percentage to the bar as well

Default
0
Lineoptional

See also