Jump to content

Шаблон:Change2

Мавод аз Википедиа — донишномаи озод
Ҳуҷҷатгузорӣ

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

Calculate and display the percent change between two real number values

Template parameters[Edit template data]

ПараметрТавзеҳотTypeStatus
Baseold 1

nonzero real number representing the base value

Numberrequired
Objectnew 2

real number representing the object value

Numberrequired
yearsyears

real number of years from the base value to the object value

Numberoptional
Precisiondec

integer number of decimal places to display in percent change

Пешфарз
2
Numberoptional
Color switchcolor

display percent change in green (gain), default (no change) and red (loss)

Пешфарз
yes
Stringoptional
Sort switchsort

add a hidden sort key prefix

Пешфарз
yes
Stringoptional

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}} +0% +0% +0% +0% +0%
Mount Acme {{change2|2450000|2205678.37}} −0% −0% −0% −0% −0%
Homeport {{change2|5120000|5589462.60}} +0% +0% +0% +0% +0%
Longwood {{change2|930000|930027.92}} 0% 0% 0% 0% 0%
Meadowbrook {{change2|2450000|2450000.00}} 0% 0% 0% 0% 0%
Johnstown {{change2|3400000|3902340.05}} +0% +0% +0% +0% +0%
Lakewood {{change2|2250000|2236005.56}} −0% −0% −0% −0% −0%
Fox Hollow {{change2|1180000|1190345.32}} +0% +0% +0% +0% +0%
Riverton {{change2|10550000|11236005.55}} +0% +0% +0% +0% +0%
Timber Creek {{change2|1360000|1310948.30}} −0% −0% −0% −0% −0%
Terminated {{change2|1500|0.00}} −0% −0% −0% −0% −0%

See also

  • This template is invoked by {{Change}}, which provides error checking.
  • This template invokes {{nk}} and {{rnd}}.