Template:Change2/doc
40px | This is a documentation subpage for Template:Change2. It contains usage information, categories and other content that is not part of the original template page. |
Contents
Use
This template calculates the percent change between two real number values and displays the result in a selectable format.
The syntax for this template is:
{{change2|old|new|years=|dec=2|color=yes|sort=yes}}
where:
- old = the required nonzero real number representing the base value
- new = the required real number representing the object value
- years = the optional real number of years from the base value to the object value
- dec = integer number of decimal places to display in percent change (default=2)
- color=yes — display percent change in the following colors: (default)
- gain in green
- no change in default color
- loss in red
- color=no — display percent change in default color
- sort=yes — add a hidden sort key prefix (default)
- sort=no — don't add a hidden sort key prefix
Parameters
<templatedata>{ "description": "Calculate and display the percent change between two real number values", "params": { "old": {"label": "Base", "description": "nonzero real number representing the base value", "type": "number", "required": true, "aliases": ["1"]}, "new": {"label": "Object", "description": "real number representing the object value", "type": "number", "required": true, "aliases": ["2"]}, "years": {"description": "real number of years from the base value to the object value", "type": "number", "required": false}, "dec": {"label": "Precision", "description": "integer number of decimal places to display in percent change", "type": "number", "default": "2"}, "color": {"label": "Color switch", "description": "display percent change in green (gain), default (no change) and red (loss)", "type": "string", "default": "yes"}, "sort": {"label": "Sort switch", "description": "add a hidden sort key prefix", "type": "string", "default": "yes"} }}</templatedata>
Example
The following sortable table illustrates the use of this template.
Region | Wikitext | default | dec=0 | color=no | sort=no | years=5 |
---|---|---|---|---|---|---|
Big Meadow | {{change2|1830000|1900679.75}} | !D0032539121354 +3.86% | !D0032539121354 +4% | !D0032539121354 +3.86% | +3.86% | !D0032539121354 +3.86% |
Mount Acme | {{change2|2450000|2205678.37}} | !H9976946422094 −9.97% | !H9976946422094 −10% | !H9976946422094 −9.97% | −9.97% | !H9976946422094 −9.97% |
Homeport | {{change2|5120000|5589462.60}} | !D0023893210817 +9.17% | !D0023893210817 +9% | !D0023893210817 +9.17% | +9.17% | !D0023893210817 +9.17% |
Longwood | {{change2|930000|930027.92}} | !D0104135965872 +0.00% | !D0104135965872 +0% | !D0104135965872 +0.00% | +0.00% | !D0104135965872 +0.00% |
Meadowbrook | {{change2|2450000|2450000.00}} | !F 0.00% | !F 0% | !F 0.00% | 0.00% | !F 0.00% |
Johnstown | {{change2|3400000|3902340.05}} | !D0019122534297 +14.77% | !D0019122534297 +15% | !D0019122534297 +14.77% | +14.77% | !D0019122534297 +14.77% |
Lakewood | {{change2|2250000|2236005.56}} | !H9949199746126 −0.62% | !H9949199746126 −1% | !H9949199746126 −0.62% | −0.62% | !H9949199746126 −0.62% |
Fox Hollow | {{change2|1180000|1190345.32}} | !D0047367354739 +0.88% | !D0047367354739 +1% | !D0047367354739 +0.88% | +0.88% | !D0047367354739 +0.88% |
Riverton | {{change2|10550000|11236005.55}} | !D0027329954208 +6.50% | !D0027329954208 +7% | !D0027329954208 +6.50% | +6.50% | !D0027329954208 +6.50% |
Timber Creek | {{change2|1360000|1310948.30}} | !H9966776348651 −3.61% | !H9966776348651 −4% | !H9966776348651 −3.61% | −3.61% | !H9966776348651 −3.61% |
Terminated | {{change2|1500|0.00}} | !I −100.00% | !I −100% | !I −100.00% | −100.00% | !I −100.00% |