Template:Bartable/doc
< Template:Bartable
Jump to navigation
Jump to search
Revision as of 20:06, 2 June 2011 by imported>Timwi (Add wiki mark-up for the real-world example)
| This is a documentation subpage for Template:Bartable. It contains usage information, categories and other content that is not part of the original template page. |
This template adds an inline bar graph to tables with numeric (including negative) values that a reader may wish to compare. It takes up 3 columns of a table, so headers should have colspan="3" (or similar combination) to correctly span the columns.
Notes:
- A "negative" bars column is created even if there are no negative values (and vice versa); if anyone knows how to collapse the column (zero width/padding/margins), please help.
- A negative value of scale will not change the side of the bar.
Usage
{{bartable|value|unit|scale|height|style}}
- value (mandatory) is any real number or math expression that evaluates to a number.
- unit (default: empty string) is a suffix to be appended to value. If unit starts with "/", the convert template is used as follows: "/unit1/unit2/round" is translated to "{{convert|value|unit1|unit2|round|abbr=on}}. (Note: unit1 and unit2 cannot contain "/" or "=". If anyone knows how to allow it (or translate other characters to it), please help.)
- scale (default: "1") is a positive factor multiplied by value to give the width of the bar in pixels.
- height (default: "2ex") is the height of the bar as a CSS measurement e.g. "1em" or "16px".
- style (default: empty string) is the content of a CSS style string to apply to the bar e.g. "background:red;".
Examples
Click Edit to view source.
| Example | Rendering | ||
|---|---|---|---|
| No parameters | — | ||
| Only value | 272 | ||
| Negative value | -72 | ||
| Math expression | exp(1)*1e2 | ||
| Value and ordinary unit | 272km/h | ||
| Value and convert unit | 272 km (147 nmi) | ||
| Value and scale | 272 | ||
| Value and height | 272 | ||
| Value and style | 272 | ||
| The full monty | −72 km (−39 nmi) | ||
Real-world example
{| class="wikitable"
|+ Melting point at 1 atmosphere
! Substance !! Temperature !! colspan="2" | Relative size
|-
| Mercury || {{bartable| -38.72|/C/F|2|1em|background:silver}}
|-
| Bromine || {{bartable| -7.10|/C/F|2|1em|background:brown}}
|-
| Water || {{bartable| 0|/C/F|2|1em}}
|-
| Phosphorus || {{bartable| 44.10|/C/F|2|1em|background:red}}
|-
| Iodine || {{bartable| 113.50|/C/F|2|1em|background:indigo}}
|-
| Sulphur || {{bartable| 115.36|/C/F|2|1em|background:yellow}}
|}
|
| ||||||||||||||||||||||