Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Search
Editing
Template:Bar chart/doc
From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
Namespaces
Template
Discussion
More
More
Page actions
Read
Edit source
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Documentation subpage}} <!-- Categories where indicated at the bottom of this page, please --> {{notice|{{tl|Bar chart}} handles up to 4 columns and 25 rows of data.}} {{notice|[[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|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. <pre style="overflow: auto;"> {{Bar chart | title = <!-- Title bolded above table; defaults to "List of cities by population" in {bar_chart}. --> | class = <!-- Adds a class= parameter after the {| wikitable header --> | table_width = <!-- Sets the overall table width in width_units (or em if width_units is not present) --> | table_style = <!-- Additional parameters to be added to the table's style parameter --> | bar_width = <!-- uses 30 by default. Must be an unformatted number --> | width_units = <!-- uses 'em' units by default --> | label_type = <!-- Title for the label column; defaults to "City". --> | label1 = <!-- Row 1 label --> | label2 = <!-- Row 2 label --> ... | label25 = <!-- Row 25 label --> | data_type = <!-- Title for column 1 data. In {{Bar chart}}, defaults to "Population". --> | data_max = <!-- Upper bound on the values in column 1 data fields (uses data1 if not present) --> | data1 = <!-- Row 1, Column 1 data --> | comment1 = <!-- Row 1, Column 1 comment --> | data2 = <!-- Row 2, Column 1 data --> | comment2 = <!-- Row 2, Column 1 comment --> ... | data25 = <!-- Row 25, Column 1 data. {{Bar chart 4x9}} only supports up to data9. --> | comment25 = <!-- Row 25, Column 1 comment. {{Bar chart 4x9}} only supports up to comment9. --> | col2_data_type= <!-- Title for column 2 data --> | col2_data_max = <!-- Upper bound on the values in column 2 data fields (uses col2_data1 if not present) --> | col2_data1 = <!-- Row 1, Column 2 data --> | col2_comment1 = <!-- Row 1, Column 2 comment --> | col2_data2 = <!-- Row 2, Column 2 data --> | col2_comment2 = <!-- Row 2, Column 2 comment --> ... | col2_data25 = <!-- Row 25, Column 2 data. {{Bar chart 4x9}} only supports up to col2_data9. --> | col2_comment25= <!-- Row 25, Column 2 comment. {{Bar chart 4x9}} only supports up to col2_comment9. --> }} </pre> == Alignment == To float the bar chart on the right of the page, use <pre> | float = right </pre> To float the bar chart on the left of the page, use <pre> | float = left </pre> To float the bar chart to the center of the page, use <pre> | float = center </pre> The default is none. == Caption == To add a caption to the bottom of the chart, use <pre> | caption = </pre> == Example == {{Bar chart | title = Largest cities of Foo | caption = Source: 2009 Census | label_type = City | data_type = Population | bar_width = 35 | width_units = em | data_max = 600000 | label1 = City1 | data1 = 540,921 | label2 = City2 | data2 = 194,343 | label3 = City3 | data3 = 190,414 | label4 = City4 | data4 = 134,669 | label5 = City5 | data5 = 114,983 }} <pre style="overflow: auto"> {{Bar chart | title = Largest cities of Foo | caption = Source: 2009 Census | label_type = City | data_type = Population | bar_width = 35 | width_units = em | data_max = 600000 | label1 = City1 | data1 = 540,921 | label2 = City2 | data2 = 194,343 | label3 = City3 | data3 = 190,414 | label4 = City4 | data4 = 134,669 | label5 = City5 | data5 = 114,983 }} </pre> == Example with comments == {{Bar chart | title = Annual revenue passenger statistics | label_type = Year | data_type = Passengers (% change from prior year) | data_max = 170,000 | label3 = 2003-04 | data3 = 110,649 | comment3 = +17.8% | label4 = 2004-05 | data4 = 130,429 | comment4 = +17.9% | label5 = 2005-06 | data5 = 138,547 | comment5 = +6.2% | label6 = 2006-07 | data6 = 138,844 | comment6 = +0.2% | label7 = 2007-08 | data7 = 149,544 | comment7 = +7.7% | label8 = 2008-09 | data8 = 148,435 | comment8 = -0.7% | label9 = 2009-10 | data9 = 168,147 | comment9 = +13.3% }} <pre style="overflow: auto"> {{Bar chart | title = Annual revenue passenger statistics | label_type = Year | data_type = Passengers (% change from prior year) | data_max = 170,000 | label3 = 2003-04 | data3 = 110,649 | comment3 = +17.8% | label4 = 2004-05 | data4 = 130,429 | comment4 = +17.9% | label5 = 2005-06 | data5 = 138,547 | comment5 = +6.2% | label6 = 2006-07 | data6 = 138,844 | comment6 = +0.2% | label7 = 2007-08 | data7 = 149,544 | comment7 = +7.7% | label8 = 2008-09 | data8 = 148,435 | comment8 = -0.7% | label9 = 2009-10 | data9 = 168,147 | comment9 = +13.3% }} </pre> == Example with two data columns == {{Bar chart | title = Annual passenger and aircraft statistics | bar_width = 20 | width_units = em | label_type = Fiscal year | label1 = 2001-02 | label2 = 2002-03 | label3 = 2003-04 | label4 = 2004-05 | label5 = 2005-06 | label6 = 2006-07 | label7 = 2007-08 | label8 = 2008-09 | label9 = 2009-10 | data_type = Revenue passengers | data_max = 66,000 | data1 = 20,194 | data2 = 22,057 | data3 = 34,794 | data4 = 49,234 | data5 = 57,732 | data6 = 64,881 | data7 = 63,904 | data8 = 54,718 | data9 = 52,210 | col2_data_type = Aircraft movements | col2_data_max = 3,200 | col2_data1 = 2,281 | col2_data2 = 2,633 | col2_data3 = 2,664 | col2_data4 = 2,754 | col2_data5 = 3,004 | col2_data6 = 2,956 | col2_data7 = 2,912 | col2_data8 = 2,811 | col2_data9 = 2,791 }} <pre style="overflow: auto"> {{Bar chart | title = Annual passenger and aircraft statistics | bar_width = 20 | width_units = em | label_type = Fiscal year | label1 = 2001-02 | label2 = 2002-03 | label3 = 2003-04 | label4 = 2004-05 | label5 = 2005-06 | label6 = 2006-07 | label7 = 2007-08 | label8 = 2008-09 | label9 = 2009-10 | data_type = Revenue passengers | data_max = 66,000 | data1 = 20,194 | data2 = 22,057 | data3 = 34,794 | data4 = 49,234 | data5 = 57,732 | data6 = 64,881 | data7 = 63,904 | data8 = 54,718 | data9 = 52,210 | col2_data_type = Aircraft movements | col2_data_max = 3,200 | col2_data1 = 2,281 | col2_data2 = 2,633 | col2_data3 = 2,664 | col2_data4 = 2,754 | col2_data5 = 3,004 | col2_data6 = 2,956 | col2_data7 = 2,912 | col2_data8 = 2,811 | col2_data9 = 2,791 }} </pre> == See also == * {{tl|Bar box}}, shows bar chart with a text column after the bars or bar-pairs * {{tl|Bartable}} * {{tl|Composition bar}} * {{tl|Pie chart}}, shows pie wedges in a circular pie chart * {{tl|Vertical bar chart}} (does not meet [[MEpedia:accessibility|accessibility guidelines]] due to the lack of alternative text) * [[Help:Charts]] {{Template:Graph, chart and plot templates}} <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | <!-- Categories below this line, please: --> [[Category:Bar chart templates]] [[Category:Graph, chart and plot templates]] }}</includeonly>
Summary:
Please make sure your edits are consistent with
MEpedia's guidelines
.
By saving changes, you agree to the
Terms of use
, and you irrevocably agree to release your contribution under the
CC BY-SA 3.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:!!
(
edit
)
Template:Bar chart
(
edit
)
Template:Bar chart/bar
(
edit
)
Template:Category other
(
edit
)
Template:Documentation subpage
(
edit
)
Template:Graph, chart and plot templates
(
edit
)
Template:MEActionBlue
(
edit
)
Template:Mbox
(
edit
)
Template:Navbox
(
edit
)
Template:Notice
(
edit
)
Template:Nowrap
(
edit
)
Template:Strong
(
edit
)
Template:Terminate sentence
(
edit
)
Template:Tl
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Navbar
(
edit
)
Module:Navbox
(
edit
)
Module:No globals
(
edit
)
Module:Text
(
edit
)
Module:Yesno
(
edit
)
Navigation
Navigation
Skip to content
Main page
Browse
Become an editor
Random page
Popular pages
Abbreviations
Glossary
About MEpedia
Links for editors
Contents
Guidelines
Recent changes
Pages in need
Search
Help
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs