Difference between revisions of "Template:Data bars/doc"
Jump to navigation
Jump to search
imported>Jonathan Lane Studeman (→Method) |
imported>WOSlinker (tidy style for better HTML5 compatibility) |
||
| Line 9: | Line 9: | ||
{| cellpadding="0" cellspacing="0" | {| cellpadding="0" cellspacing="0" | ||
| − | |- | + | |- style="vertical-align:top;" |
| | | | ||
{| | {| | ||
| Line 24: | Line 24: | ||
| blue|Berries| 65| 38| 72| 47| 20| 30 | | blue|Berries| 65| 38| 72| 47| 20| 30 | ||
}} | }} | ||
| − | |- | + | |- style="vertical-align:top;" |
| | | | ||
{| | {| | ||
| Line 45: | Line 45: | ||
{| cellspacing="0" cellpadding="o" | {| cellspacing="0" cellpadding="o" | ||
| − | |- | + | |- style="vertical-align:bottom;" |
| Given multiple data rows that look like this: | | Given multiple data rows that look like this: | ||
|- | |- | ||
| − | | | + | | style="text-align:right;padding-right:48px;" | <big>'''↔'''</big> '''Max. data columns:''' 16 <big>'''↔'''</big> |
|- | |- | ||
| | | | ||
| Line 59: | Line 59: | ||
}} | }} | ||
</pre> | </pre> | ||
| − | | | + | | style="vertical-align:middle;padding-left:16px;" | <big>'''↕'''</big> '''Max. data rows:''' 8 <big>'''↕'''</big> |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
| Line 89: | Line 89: | ||
{| | {| | ||
| − | |- | + | |- style="vertical-align:top;" |
| | | | ||
{| | {| | ||
| Line 105: | Line 105: | ||
</pre> | </pre> | ||
|- | |- | ||
| − | | | + | | style="text-align:center;" | |
{{Data bars | {{Data bars | ||
| title = Small numbers, large scale | | title = Small numbers, large scale | ||
| Line 172: | Line 172: | ||
For example, here's one using <tt>'''style=8'''</tt>: | For example, here's one using <tt>'''style=8'''</tt>: | ||
{| cellspacing="0" cellpadding="0" | {| cellspacing="0" cellpadding="0" | ||
| − | | | + | | style="text-align:center;" | Horizontal, with borders, shading and visible detail. |
|- | |- | ||
| | | | ||
| Line 178: | Line 178: | ||
| | | | ||
{| align="center" | {| align="center" | ||
| − | |- | + | |- style="vertical-align:bottom;" |
<pre> | <pre> | ||
{{Data bars | {{Data bars | ||
| Line 212: | Line 212: | ||
| style="padding-top:32px;" | And here's the exact same data in '''style=13''', showing '''averages''' on the right instead of totals: | | style="padding-top:32px;" | And here's the exact same data in '''style=13''', showing '''averages''' on the right instead of totals: | ||
|- | |- | ||
| − | | | + | | style="text-align:center;" | |
{{Data bars | {{Data bars | ||
| style = 13 | | style = 13 | ||
Revision as of 23:30, 27 February 2015
| 40px | This is a documentation subpage for Template:Data bars. It contains usage information, categories and other content that is not part of the original template page. |
Contents
Usage
This is a template for displaying a bar chart.
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| Given multiple data rows that look like this: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ↔ Max. data columns: 16 ↔ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{Data bars
| columns = 12 |Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
| green| Apples| 60| 70| 90| 30| 50| 30|100|130|120| 90| 50|110
|yellow| Bananas| 90| 80|110| 60| 70| 80| 70| 70| 40| 50| 50| 60
|orange| Oranges| 50| 40| 60|110| 90| 60| 30| 60| 70| 60| 80| 40
}}
|
↕ Max. data rows: 8 ↕ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Title, Scale, Source and Alignment
Optional named parameters include title, scale and source.
- A title appears bolded and centered above the chart.
- A scale is needed for handling very small or large numbers.
- A source tells the viewer where the data came from.
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Also, to center or to float a chart left or right, specify center, right or left in parameter align (aka float). For example:
| Berries | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Total: 272 |
{{Data bars
| align = right
| columns = 6 | Jan| Feb| Mar| Apr| May| Jun
| blue|Berries| 65| 38| 72| 47| 20| 30
}}
|
Orientation, Borders, Details and Averages
There are sixteen styles to choose from.
- Odd numbered styles are vertical.
- Even numbered styles are horizontal.
- Styles 3 and 4 have borders and shading.
- Styles 5 thru 8 are the same as 1 thru 4, but show additional detail.
- Styles 9 thru 16 are the same as 1 thru 8, but averages are displayed with the color key, instead of totals.
For example, here's one using style=8:
| Horizontal, with borders, shading and visible detail. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| And here's the exact same data in style=13, showing averages on the right instead of totals: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Method
This template employs five "sub-templates." A table is created using the columns and rows of data.
- {{Data bars/bar}} draws each vertical or horizontal rectangle optionally colored and labeled with a name and/or a value.
- {{Data bars/column}} handles one column of data.
If style is > 8, the data is passed along to other sub-templates to display averages instead of totals with the color key.
- {{Data bars/averages}} calculates the averages of all the rows of data.
- {{Data bars/averages/display}} assigns the averages to named parameters for display as a single complex bar.
- {{Data bars/averages/column}} draws a vertical labeled bar of averages serving as a color key.