Template:Change/doc

使用方法

该模板可计算两个实数之间的百分比变化,并将结果直观的用颜色表示。

该模板的完整语法如下:

{{change|1st No.|2nd No.|dec=rounding|pre=prefix|suf=suffix|sort=on/off|italics=on/off|bold=on/off|invert=on/off|disp=row/out|rowspan=rowspan|align=alignment|bgcolour=background colour}}

参数 解释
1 表示基准值。
2 表示对象值。
dec 参数可表示表示小数点位数。例如dec=3表示四舍五入至小数点后三位。
pre 在两数值上增加前缀。
suf 在两数值上增加后缀。
sort 该参数将增加或移除{{nts}},即对表格进行排序。 默认为开启(注意:仅当需要时)
italics 参数可填入on or offitalics=on可使其字体斜体,默认为italics=off
bold 参数可填入on or offbolds=on可使其字体斜体,默认为bold=off
invert 参数可填入onoffinvert=on为开启,可反转基准值与对象值。默认为invert=off
align 调整文本、数值在单元格中的对齐方式,可填入align=centeralign=left默认为右对齐(align=right)。
rowspan 向下合并的单元格数,默认值为rowspan=1
bgcolour 调整单元格的背景颜色,默认为bgcolour=#F9F9F9(亮灰色)。
disp 作用为控制输出方式,可填入disp=out表示只输出百分比变化一行的单元格。(对齐方式align、合并单元格rowspan和背景颜色bgcolour不在disp=out作用范围内。)默认值disp=row作用于表格中的三行单元格。

下表就是该模板的一个例子:

维基语法 表格
{|class="wikitable sortable"
!地区
!数值1
!数值2
!变化
|-
|Big Meadow
|{{change|1830000|1900679.75}}
|-
|Little Meadow
|{{change|400000|500000}}
|-
|Mount Acme
|{{change|2450000|2205678.37}}
|-
|Acmevale North
|{{change|1250000|1000000|rowspan=2}}
|-
|Acmevale South
|-
|Homeport
|{{change|5120000|5589462.60|dec=0}}
|-
|Longwood
|{{change|930000|930027.92|dec=3}}
|-
|Meadowbrook
|{{change|2450000|2450000.00|pre=$}}
|-
|Johnstown
|{{change|3400000|3902340.05|suf= kg}}
|-
|Lakewood
|{{change|2250000|2236005.56|align=center}}
|-
|bgcolor=lightblue|Fox Hollow
|{{change|1180000|1190345.32|bgcolour=lightblue}}
|-
|Riverton
|{{change|10550000|11236005.55|bold=on}}
|-
|Timber Creek
|{{change|1360000|1310948.30|italics=on}}
|-
|Terminated
|{{change|1500|0.00|bold=on|italics=on}}
|-
|Upstart
|{{change|0|26250.50|align=left}}
|-
|}
若为默认值:
地区 数值1 数值2 变化
Big Meadow 1,830,000 1,900,679.75 +3.86%
Little Meadow 400,000 500,000 +25.00%
Mount Acme 2,450,000 2,205,678.37 −9.97%
Acmevale North 1,250,000 1,000,000 −20.00%
Acmevale South
Homeport 5,120,000 5,589,462.6 +9%
Longwood 930,000 930,027.92 +0.003%
Meadowbrook $2,450,000 $2,450,000 0.00%
Johnstown 3,400,000 kg 3,902,340.05 kg +14.77%
Lakewood 2,250,000 2,236,005.56 −0.62%
Fox Hollow 1,180,000 1,190,345.32 +0.88%
Riverton 10,550,000 11,236,005.55 +6.50%
Timber Creek 1,360,000 1,310,948.3 −3.61%
Terminated 1,500 0 −100.00%
Upstart 0 26,250.5 NA
With |disp=out
地区 变化
Big Meadow +3.86%
Little Meadow +25.00%
Mount Acme −9.97%
Acmevale North −20.00%
Acmevale South
Homeport +9%
Longwood +0.003%
Meadowbrook 0.00%
Johnstown +14.77%
Lakewood −0.62%
Fox Hollow +0.88%
Riverton +6.50%
Timber Creek −3.61%
Terminated −100.00%
Upstart NA
With |invert=on
地区 数值1 数值2 变化
Big Meadow 1,830,000 1,900,679.75 −3.72%
Little Meadow 400,000 500,000 −20.00%
Mount Acme 2,450,000 2,205,678.37 +11.08%
Acmevale North 1,250,000 1,000,000 +25.00%
Acmevale South
Homeport 5,120,000 5,589,462.6 −8%
Longwood 930,000 930,027.92 −0.003%
Meadowbrook $2,450,000 $2,450,000 0.00%
Johnstown 3,400,000 kg 3,902,340.05 kg −12.87%
Lakewood 2,250,000 2,236,005.56 +0.63%
Fox Hollow 1,180,000 1,190,345.32 −0.87%
Riverton 10,550,000 11,236,005.55 −6.11%
Timber Creek 1,360,000 1,310,948.3 +3.74%
Terminated 1,500 0 NA
Upstart 0 26,250.5 −100.00%
With |invert=on and |disp=out
地区 变化
Big Meadow −3.72%
Little Meadow −20.00%
Mount Acme +11.08%
Acmevale North +25.00%
Acmevale South
Homeport −8%
Longwood −0.003%
Meadowbrook 0.00%
Johnstown −12.87%
Lakewood +0.63%
Fox Hollow −0.87%
Riverton −6.11%
Timber Creek +3.74%
Terminated NA
Upstart −100.00%

此模板调用模块:MathTemplate:ntsh,并兼容Template:ntsTemplate:ntsh