块图是将矩形化为多个块表示比例的图形。

字段说明

编辑
  • value1-value9 – 每个块的值,可以是整数、小数、公式或者用“+”连接整数和分数来表示带分数
  • label1-label9 – 每个块的标签,显示在图例中
  • color1-color9 – 每个块的颜色
  • caption – 图例的标题
  • total   – 块的总数(默认100)
  • stride – 每行最多有几个块(默认10)
  • unit   – 块的单位(默认为%)
  • width – 表宽
  • brick_size - 每块代表的值(默认为1)
  • align  – 左对齐或者右对齐(left/right,默认为右对齐)
  • legend_margin=0 0 0 6px – 指左边沿偏移6px (默认为3px 0 0 10px).

示例

编辑
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example of 6 amounts

  one - 42 %
  two - 32 %
  three - 12 %
  four - 3 %
  five - 2 %
  six - 0.4 %
  其他 - 8.6 %

The following 2 examples have numbers in the range of 0-100 units, as percentages. The total is assumed as total=100, to calculate the "other" amount by subtracting all brick values from 100.

{{Brick chart
| caption=Example of 6 amounts
| value1=42 | label1=one
| value2=32 | label2=two
| value3=12 | label3=three
| value4=3 | label4=four
| value5=2 | label5=five
| value6=0.4 | label6=six
}}

Note how the bottom value, value6=0.4, generates a "tiny sliver" of a brick, and the calculated remainder, the "other" value is also a decimal amount as 8.6.

The brick colours use the defaults: red, dark green, blue, yellow, purple, and cyan, as the first 6 hues. The next example, below, shows use of some colour parameters by setting: color1, color2, color3.


 
 
 
 
 
 
 

Religion in the Czech Republic

  无神论s / 不可知论s - 59 %
  天主教會s - 26.8 %
  新教 - 2.5 %
  其他 - 11.7 %
{{Brick chart
| caption=Religion in the Czech Republic
| label1 = [[无神论]]s / [[不可知论]]s
  | value1 = 59 | color1 = silver
| label2 = [[天主教會]]
  | value2 = 26.8 | color2 = #008
| label3 = [[新教]]
  | value3 = 2.5 | color3 = #08f
| legend_margin=0 0 0 6px
}}

The 2nd example, for Religion in the Czech Republic, shows the use of indented parameters for the value/color under each label phrase. The color #008 (for "Catholic") is a hexadecimal code for dark blue, using RGB notation, where the 3rd digit "8" is half of blue intensity levels, 0-F.

It is customary to list the larger percentages first, in a table; however, the numbers can be displayed in any order as needed for the text on a page. A small decimal amount, such as 0.4, will show a tiny sliver among the various brick bars.

The option "legend_margin=0 0 0 6px" resets the alignment of the legend boxes, as only 6 pixels from the left margin (default: 3px 0 0 10px).

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

德国国会议席分布

Larger amounts: The following example has numbers in the range of 0-300 units, as counts. The total is set to total=614. The options stride=20 and brick_size=2.6 scale the bar line segments to fit within the box, rather than 6x times larger, as 614 compared to 100.

{{Brick chart
|caption = 德国国会议席分布
|total = 614
|unit = 席
|stride = 20
|brick_size=2.6
|label1=[[基督教民主联盟党]]
  | color1=black
  | value1=180
|label2=[[巴伐利亚基督教社会联盟]]
  | color2=#ccf
  | value2=46
|label3=[[德国社会民主党]]
  | color3=red
  | value3=222
|label4={{tsl|en|Free Democratic Party|}}
  | color4=yellow
  | value4=61
|label5=[[民主社会主义党 (德国)]]
  | color5=#800
  | value5=54
|label6=[[联盟90/绿党]]
  | color6=green
  | value6=51
}}

程序效率

编辑

The Template:Brick_chart draws the chart by using div-tags ("<div>") to show colored bars for line segments of the calculated length. The template can format a brick chart within 1/6 second, so 3 brick charts could appear within a page and add only 1/2 second to reformat, or edit-preview. The initial creation of the template occurred in August 2009; however, the alignment for display problems with overlapped bars was fixed in September 2012, over 3 years later.

参见

编辑