This site is supported by donations to The OEIS Foundation.

Template:Bar graph/doc

From OeisWiki
Jump to: navigation, search

This documentation subpage contains instructions, categories, or other information for Template:Bar graph. [<Edit> Template:Bar graph]

[⧼Purge⧽ Template:Bar graph/doc]

The {{Bar graph}} bar chart template can be used to create a single or dual horizontal bar graphs in a format which can be parsed by text-based web browsers. The single or dual horizontal bar graphs may have up to 32 (0 to 31) data entries each, with shared horizontal label entries, but with their own column data_type and data_max for column 1, col2_data_type and col_2_data_max for column 2. Note that {{Bar graph from lists}} is more convenient than {{Bar graph}} to generate horizontal bar graphs.

Note that negative values are not currently displayed with {{bar graph}} (you may use {{vertical bar graph}} for this purpose.)

Usage

{{Bar graph
| float            = <!-- left, right, center or none (default) -->
| border_width     = <!-- default 1px -->
| border_color     = <!-- default #c0c0c0 -->
| background_color = <!-- default #f9f9f9 -->
| title       = 
| bar_width   = <!-- default 30, must be an unformatted number (use {{formatnum: 6,500|R}} to remove formatting from numbers, e.g. 6,500 to get 6500) -->
| width_units = <!-- default em, uses 'em' units by default -->
| bar_color   = <!-- default rgb(206, 223, 242) -->
| bars_border_color  = <!-- optional, no bar border if not given (shared by dual bar graph) -->
| boxes_border_color = <!-- optional, no box border if not given (a box corresponds to the 100% potential length of a bar) (shared by dual bar graph) -->
| label_type  = <!-- title for the label column -->
| data_type   = <!-- title for the data column -->
| data_max    = <!-- upper bound on the values in the data fields (default data0) -->
| label0      = 
| data0       =
| comment0    = <!-- optional --> 
| label1      = 
| data1       =
| comment1    = <!-- optional -->  
| ...
| label30     = 
| data30      = 
| comment30   = <!-- optional --> 
| label31     = 
| data31      = 
| comment31   = <!-- optional --> 
| col2_bar_color   = <!-- bar color for column 2 (default rgb(206, 223, 242)) -->
| col2_data_type   = <!-- title for the data column 2 -->
| col2_data_max    = <!-- upper bound on the values in the data fields of column 2 (default col2_data0) -->
| col2_label0      = 
| col2_data0       =
| col2_comment0    = <!-- optional --> 
| col2_label1      = 
| col2_data1       =
| col2_comment1    = <!-- optional -->  
| ...
| col2_label30     = 
| col2_data30      = 
| col2_comment30   = <!-- optional --> 
| col2_label31     = 
| col2_data31      = 
| col2_comment31   = <!-- optional --> 
}}

  • float to position the bar graph to the left, right, center or none (default)
  • border_width is the border with of the bar graph (default 1px)
  • border_color is the border color of the bar graph (default #c0c0c0, i.e.    ).
  • background_color is the background color of the bar graph (default #fdfdfd, i.e.    ).
  • title is the title of the single or dual horizontal bar graphs
  • bar_width is a number which determines the maximum width of the bar.
  • width_units are the units associated with the width (em, px, or %). The default is em.
  • bar_color is used to override the default bar color (rgb(206, 223, 242), i.e.    .
  • bars_border_color is optional, no bar border if not given (shared by dual bar graph)
  • boxes_border_color is optional, no box border if not given (a box corresponds to the 100% potential length of a bar) (shared by dual bar graph)
  • label_type title for the label column
  • data_type title for the data column
  • data0 ... data31 and data_max are used to determine the width of the bars using data0/data_max ... data31/data_max to compute a percentage of bar_width.
  • data0 ... data31 followed by (comment0) ... (comment31) are shown on each bar.
  • col2_data_type title for the data column 2
  • col2_data0 ... col2_data31 and col2_data_max are used to determine the width of the bars using col2_data0/col2_data_max ... col2_data31/col2_data_max to compute a percentage of bar_width.
  • col2_data0 ... col2_data31 followed by (col2_comment0) ... (col2_comment31) are shown on each bar of column 2.

Alignment

To float the bar graph on the right of the page, use

| float       = right

To float the bar graph on the left of the page, use

| float       = left

To float the bar graph to the center of the page, use

| float       = center

The default is none.

Examples

Example with default style

Annual revenue passenger statistics
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%)
{{Bar graph
| float      = left
| title      = Annual revenue passenger [[statistics]]
| label_type = {{underline|Year}}
| data_type  = {{underline|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%
}}

Examples with non default style

Largest cities of Foo, 2009 Census
City Population
City1
540,921
City2
194,343
City3
190,414
City4
134,669
City5
114,983
{{Bar graph
| float            = left
| border_width     = 4px
| border_color     = black
| background_color = grey 
| title       = Largest cities of Foo, 2009 Census
| label_type  = {{underline|City}}
| data_type   = {{underline|Population}}
| bar_width   = 35
| width_units = em
| bar_color   = red    
| bars_border_color = yellow
| 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
}}

Sine function
0
0
1
0.25881904510252
2
0.5
3
0.70710678118655
4
0.86602540378444
5
0.96592582628907
6
1
7
0.96592582628907
8
0.86602540378444
9
0.70710678118655
10
0.5
11
0.25881904510252
12
1.2246467991474E-16
13
-0.25881904510252
14
-0.5
15
-0.70710678118655
16
-0.86602540378444
17
-0.96592582628907
18
-1
19
-0.96592582628907
20
-0.86602540378444
21
-0.70710678118655
22
-0.5
23
-0.25881904510252
24
-2.4492935982947E-16
{{Bar graph
| float            = right
| border_width     = 1px
| border_color     = black
| background_color = #ccccee 
| title            = Sine function
| label_type  = <math>n \,</math>
| data_type   = <math>\scriptstyle \sin\big(\tfrac{2 \pi n}{30}\big) \,</math>
| bar_width   = 35
| width_units = em
| bar_color   = white    
| bars_border_color   = black  
| boxes_border_color  = red  
| data_max    = 1
| label0    = 0
| data0     = {{sin| 2*pi*0/24 }}
| label1    = 1
| data1     = {{sin| 2*pi*1/24 }}
| label2    = 2
| data2     = {{sin| 2*pi*2/24 }}
| label3    = 3
| data3     = {{sin| 2*pi*3/24 }}
| label4    = 4
| data4     = {{sin| 2*pi*4/24 }}
| label5    = 5
| data5     = {{sin| 2*pi*5/24 }}
| label6    = 6
| data6     = {{sin| 2*pi*6/24 }}
| label7    = 7
| data7     = {{sin| 2*pi*7/24 }}
| label8    = 8
| data8     = {{sin| 2*pi*8/24 }}
| label9    = 9
| data9     = {{sin| 2*pi*9/24 }}
| label10   = 10
| data10    = {{sin| 2*pi*10/24 }}
| label11   = 11
| data11    = {{sin| 2*pi*11/24 }}
| label12   = 12
| data12    = {{sin| 2*pi*12/24 }}
| label13   = 13
| data13    = {{sin| 2*pi*13/24 }}
| label14   = 14
| data14    = {{sin| 2*pi*14/24 }}
| label15   = 15
| data15    = {{sin| 2*pi*15/24 }}
| label16   = 16
| data16    = {{sin| 2*pi*16/24 }}
| label17   = 17
| data17    = {{sin| 2*pi*17/24 }}
| label18   = 18
| data18    = {{sin| 2*pi*18/24 }}
| label19   = 19
| data19    = {{sin| 2*pi*19/24 }}
| label20   = 20
| data20    = {{sin| 2*pi*20/24 }}
| label21   = 21
| data21    = {{sin| 2*pi*21/24 }}
| label22   = 22
| data22    = {{sin| 2*pi*22/24 }}
| label23   = 23
| data23    = {{sin| 2*pi*23/24 }}
| label24   = 24
| data24    = {{sin| 2*pi*24/24 }}
}}

Example with two data columns

Annual passenger and aircraft statistics
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
{{Bar graph
| float            = center
| border_width     = 1px
| background_color = #dddddd  
| title            = Annual passenger and aircraft statistics
| bar_width        = 25
| width_units      = em
| label_type       = {{underline|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 = {{underline|Revenue passengers}}
| bar_color = yellow
| bars_border_color = black
| boxes_border_color = #eeeeee
| 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 = {{underline|Aircraft movements}}
| col2_bar_color = orange
| 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
}}

See also