Difference between revisions of "Template:Bartable/doc"

From blackwiki
Jump to navigation Jump to search
imported>Cmglee
(Create documentation)
 
imported>Timwi
(Add wiki mark-up for the real-world example)
Line 47: Line 47:
 
|}
 
|}
  
Real-world example:
+
=== Real-world example ===
  
 +
{|
 +
|
 +
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
 
|+ Melting point at 1 atmosphere
 
|+ Melting point at 1 atmosphere
Line 64: Line 67:
 
|-
 
|-
 
| Sulphur    || {{bartable| 115.36|/C/F|2|1em|background:yellow}}
 
| Sulphur    || {{bartable| 115.36|/C/F|2|1em|background:yellow}}
 +
|}
 +
</pre>
 +
|
 +
{| 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}}
 +
|}
 
|}
 
|}
  

Revision as of 20:06, 2 June 2011

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:

  1. 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.
  2. 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 272
 
Negative value -72
Math expression exp(1)*1e2 271.8281828459
 
Value and ordinary unit 272km/h 272
 
Value and convert unit 272 km (147 nmi) 272
 
Value and scale 272 272
 
Value and height 272 272
 
Value and style 272 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}}
|}
Melting point at 1 atmosphere
Substance Temperature Relative size
Mercury −38.72 °C (−37.70 °F)
Bromine −7.10 °C (19.22 °F)
Water 0 °C (32 °F)
Phosphorus 44.10 °C (111.38 °F) 44.1
 
Iodine 113.50 °C (236.30 °F) 113.5
 
Sulphur 115.36 °C (239.65 °F) 115.36