Template:Bar chart
City | Population |
---|
{{Bar chart}} handles up to 4 columns and 30 rows of data. |
Template:Graph:Chart is an alternative template that may produce higher-quality charts and has more functions in it |
This template can be used to create a horizontal bar chart, scrolling down a page, in a format which can be parsed by text-based web browsers. The data items can be simple numbers, or the result of calculations based on template parameters.
Each data number (data1=7, data2=23...), in column 1, is scaled to parameter "data_max=" and the bars are sized by width in units, such as "bar_width=16" and "width_units=em". By default, the data numbers are shown within each bar, but might display outside a bar when a relatively small number generates a short bar. Each bar can also have a comment, such as "comment7=xx" to show "(xx)" after the number in bar 7.
For a 2-column bar chart, the 2nd column items have prefix "col2_" such as scale maximum, col2_data_max=110, and col2_data3=67 with col2_comment3=zz. See below: "Example with two data columns". Each bar chart can be formatted typically within 1/5 second.
Usage and parameters
- The use of text other than numbers and proper punctuation in a data field will result in an Expression error.
<syntaxhighlight lang="wikitext" style="overflow: auto;">
City | Population |
---|
</syntaxhighlight>
Alignment
To float the bar chart on the right of the page, use <syntaxhighlight lang="wikitext"> | float = right </syntaxhighlight> To float the bar chart on the left of the page, use <syntaxhighlight lang="wikitext"> | float = left </syntaxhighlight> To float the bar chart to the center of the page, use <syntaxhighlight lang="wikitext"> | float = center </syntaxhighlight> The default is none.
Caption
To add a caption to the bottom of the chart, use <syntaxhighlight lang="wikitext"> | caption = </syntaxhighlight>
Empty cells
Use – or — (or a similar dash character) as a placeholder in a cell where there is no data available. Leaving a cell completely blank can sometimes cause columns to be misaligned.
Example
City | Population |
---|---|
City1 | 540,921
|
City2 | 194,343
|
City3 | 190,414
|
City4 | 134,669
|
City5 | 114,983
|
<syntaxhighlight lang="wikitext" style="overflow: auto">
City | Population |
---|---|
City1 | 540,921
|
City2 | 194,343
|
City3 | 190,414
|
City4 | 134,669
|
City5 | 114,983
|
</syntaxhighlight>
Example with comments
Year | Passengers (% change from prior year) |
---|---|
2003-04 | 110,649(+17.8%)
|
2004-05 | 130,429(+17.9%)
|
2005-06 | 138,547(+6.2%)
|
2006-07 | 138,844(+0.2%)
|
2007-08 | 149,544(+7.7%)
|
2008-09 | 148,435(-0.7%)
|
2009-10 | 168,147(+13.3%)
|
<syntaxhighlight lang="wikitext" style="overflow: auto">
Year | Passengers (% change from prior year) |
---|---|
2003-04 | 110,649(+17.8%)
|
2004-05 | 130,429(+17.9%)
|
2005-06 | 138,547(+6.2%)
|
2006-07 | 138,844(+0.2%)
|
2007-08 | 149,544(+7.7%)
|
2008-09 | 148,435(-0.7%)
|
2009-10 | 168,147(+13.3%)
|
</syntaxhighlight>
Example with two data columns
Fiscal year | Revenue passengers | Aircraft movements |
---|---|---|
2001-02 | 20,194 |
2,281
|
2002-03 | 22,057 |
2,633
|
2003-04 | 34,794 |
2,664
|
2004-05 | 49,234 |
2,754
|
2005-06 | 57,732 |
3,004
|
2006-07 | 64,881 |
2,956
|
2007-08 | 63,904 |
2,912
|
2008-09 | 54,718 |
2,811
|
2009-10 | 52,210 |
2,791
|
<syntaxhighlight lang="wikitext" style="overflow: auto">
Fiscal year | Revenue passengers | Aircraft movements |
---|---|---|
2001-02 | 20,194 |
2,281
|
2002-03 | 22,057 |
2,633
|
2003-04 | 34,794 |
2,664
|
2004-05 | 49,234 |
2,754
|
2005-06 | 57,732 |
3,004
|
2006-07 | 64,881 |
2,956
|
2007-08 | 63,904 |
2,912
|
2008-09 | 54,718 |
2,811
|
2009-10 | 52,210 |
2,791
|
</syntaxhighlight>
See also
- {{Historical populations}} (meets accessibility guidelines)
- {{Bar box}}, shows bar chart with a text column after the bars or bar-pairs
- {{Bartable}}
- {{Composition bar}}
- {{Pie chart}}, shows pie wedges in a circular pie chart
- {{Brick chart}}, shows brick segments in a rectangular "pie chart"
- {{Vertical bar chart}} (does not meet accessibility guidelines due to the lack of alternative text)
- {{Data bars}}
- WP:Graphs