This site is supported by donations to The OEIS Foundation.

Template:Bar graph from lists

From OeisWiki
Jump to: navigation, search

The {{Bar graph from lists}} 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 26 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 negative values are not currently displayed with {{bar graph}} (you may use {{vertical bar graph}} for this purpose.)

Usage


{{Bar graph from lists
| float            = <!-- left, right, center or none (default) -->
| border_width     = <!-- default 1px -->
| border_color     = <!-- default #c0c0c0 -->
| background_color = <!-- default #fdfdfd -->
| title            = <!-- title of the single or dual horizontal bar graphs -->
| label_type       = <!-- title for the label column -->
| 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) -->
| data_type        = <!-- title for the data column -->
| data_max         = <!-- upper bound on the values in the data fields  (default data0) -->
| 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) -->
| labels         =        label0;        label1; ...;        label30;        label31 
| data           =         data0;         data1; ...;         data30;         data31 
| comments       =      comment0;      comment1; ...;      comment30;      comment31  <!-- optional -->  
| col2_data      =    col2_data0;    col2_data1; ...;    col2_data30;    col2_data31 
| col2_comments  = col2_comment0; col2_comment1; ...; col2_comment30; 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.    .
  • label_type title for the label column
  • data_type title for the data column
  • data_i and data_max are used to determine the width of the bars using data_i/data_max to compute a percentage of bar_width.
  • data_i followed by (comment_i) are shown on each bar.
  • col2_data_type title for the data column 2
  • col2_data_i and col2_data_max are used to determine the width of the bars using col2_data_i/col2_data_max to compute a percentage of bar_width.
  • col2_data_i followed by (col2_comment_i) 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 from lists
| float      = left
| title      = Annual [[revenue passenger]] statistics
| label_type = {{underline|Year}}
| data_type  = {{underline|Passengers (% change from prior year)}}
| data_max   = 170,000
| labels   = 2003-04; 2004-05; 2005-06; 2006-07; 2007-08; 2008-09; 2009-10 
| data     = 110,649; 130,429; 138,547; 138,844; 149,544; 148,435; 168,147 
| comments =  +17.8%;  +17.9%;   +6.2%;   +0.2%;   +7.7%;   -0.7%;  +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 from lists
| 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    
| data_max    = 600000
| labels      =   City1;   City2;   City3;   City4;   City5
| data        = 540,921; 194,343; 190,414; 134,669; 114,983 
}}


Sine function
0
0
1
0.2079
2
0.4067
3
0.5878
4
0.7431
5
0.866
6
0.9511
7
0.9945
8
0.9945
9
0.9511
10
0.866
11
0.7431
12
0.5878
13
0.4067
14
0.2079
15
0
16
-0.2079
17
-0.4067
18
-0.5878
19
-0.7431
20
-0.866
21
-0.9511
22
-0.9945
23
-0.9945
24
-0.9511
25
-0.866
26
-0.7431
27
-0.5878
28
-0.4067
29
-0.2079
30
-0

{{Bar graph from lists
| float            = right
| border_width     = 1px
| border_color     = black
| background_color = #aaaadd 
| title            = Sine function
| label_type  = <math>n \,</math>
| data_type   = <math>\scriptstyle \sin\big(\tfrac{2 \pi n}{30}\big) {\rm ~round~} 4 \,</math>
| bar_width   = 35
| width_units = em
| bar_color   = white    
| bar_border_color   = black <!-- not yet implemented -->    
| data_max    = 1
| labels      = {{loop|31|0|n|;}}
| data        = 
{{#expr: sin (2*pi*0/30) round 4 }};
{{#expr: sin (2*pi*1/30) round 4 }};
{{#expr: sin (2*pi*2/30) round 4 }};
{{#expr: sin (2*pi*3/30) round 4 }};
{{#expr: sin (2*pi*4/30) round 4 }};
{{#expr: sin (2*pi*5/30) round 4 }};
{{#expr: sin (2*pi*6/30) round 4 }};
{{#expr: sin (2*pi*7/30) round 4 }};
{{#expr: sin (2*pi*8/30) round 4 }};
{{#expr: sin (2*pi*9/30) round 4 }};
{{#expr: sin (2*pi*10/30) round 4 }};
{{#expr: sin (2*pi*11/30) round 4 }};
{{#expr: sin (2*pi*12/30) round 4 }};
{{#expr: sin (2*pi*13/30) round 4 }};
{{#expr: sin (2*pi*14/30) round 4 }};
{{#expr: sin (2*pi*15/30) round 4 }};
{{#expr: sin (2*pi*16/30) round 4 }};
{{#expr: sin (2*pi*17/30) round 4 }};
{{#expr: sin (2*pi*18/30) round 4 }};
{{#expr: sin (2*pi*19/30) round 4 }};
{{#expr: sin (2*pi*20/30) round 4 }};
{{#expr: sin (2*pi*21/30) round 4 }};
{{#expr: sin (2*pi*22/30) round 4 }};
{{#expr: sin (2*pi*23/30) round 4 }};
{{#expr: sin (2*pi*24/30) round 4 }};
{{#expr: sin (2*pi*25/30) round 4 }};
{{#expr: sin (2*pi*26/30) round 4 }};
{{#expr: sin (2*pi*27/30) round 4 }};
{{#expr: sin (2*pi*28/30) round 4 }};
{{#expr: sin (2*pi*29/30) round 4 }};
{{#expr: sin (2*pi*30/30) round 4 }}
}}


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 from lists
| float            = center
| border_width     = 0px
| background_color = #dddddd 
| title            = Annual passenger and aircraft statistics
| bar_width        = 25
| width_units      = em
| label_type       = {{underline|Fiscal year}}
| data_type        = {{underline|Revenue passengers}}
| bar_color        = yellow
| data_max         = 66,000
| col2_data_type   = {{underline|Aircraft movements}}
| col2_bar_color   = orange
| col2_data_max    = 3,200
| labels    = 2001-02; 2002-03; 2003-04; 2004-05; 2005-06; 2006-07; 2007-08; 2008-09; 2009-10; 
| data      =  20,194;  22,057;  34,794;  49,234;  57,732;  64,881;  63,904;  54,718;  52,210;
| col2_data =   2,281;   2,633;   2,664;   2,754;   3,004;   2,956;   2,912;   2,811;   2,791;
}}

See also