Template:Bartable/doc

From blackwiki
< Template:Bartable
Revision as of 12:33, 2 June 2011 by imported>Cmglee (Create documentation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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:

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