Difference between revisions of "Template:Data bars/doc"
Jump to navigation
Jump to search
imported>Jonathan Lane Studeman (→Usage) |
imported>Jonathan Lane Studeman (→Usage) |
||
| Line 2: | Line 2: | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
== Usage == | == Usage == | ||
| − | This is a template for displaying a bar chart. | + | |
| + | This is a template for displaying a bar chart.<!---------------------- | ||
: Advantages are that it is easy to build and displays a complex, color-keyed chart. | : Advantages are that it is easy to build and displays a complex, color-keyed chart. | ||
: A disadvantage is that the size is limited to a maximum of sixteen bars, each containing a maximum of 8 colored elements. | : A disadvantage is that the size is limited to a maximum of sixteen bars, each containing a maximum of 8 colored elements. | ||
| − | : If you need a larger chart, you might use sub-template <nowiki>{{</nowiki>[[Template:Data bars/bar|Data bars/bar]]<nowiki>}}</nowiki> to build your own chart table manually, or see other [[:Category:Bar chart templates|Bar chart templates]] such as <nowiki>{{</nowiki>[[Template:Bar box|Bar box]]<nowiki>}}</nowiki> and <nowiki>{{</nowiki>[[Template:Bar chart|Bar chart]]<nowiki>}}</nowiki> . | + | : If you need a larger chart, you might use sub-template <nowiki>{{</nowiki>[[Template:Data bars/bar|Data bars/bar]]<nowiki>}}</nowiki> to build your own chart table manually, or see other [[:Category:Bar chart templates|Bar chart templates]] such as <nowiki>{{</nowiki>[[Template:Bar box|Bar box]]<nowiki>}}</nowiki> and <nowiki>{{</nowiki>[[Template:Bar chart|Bar chart]]<nowiki>}}</nowiki> .--------> |
{| cellpadding="0" cellspacing="0" | {| cellpadding="0" cellspacing="0" | ||
Revision as of 07:46, 19 January 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 and Source
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.
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Styles
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 with 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.
- Template:Data bars/bar draws each vertical or horizontal rectangle optionally colored and labeled with a name and/or a value.
- Template:Data bars/column handles one column of data.
Template:Data bars/bar is used again to create the color key unless the style is > 8, in which case all of the data is passed along to other sub-templates to display averages instead of totals.
- Template:Data bars/averages calculates the averages of all the rows of data.
- Template:Data bars/averages/display assigns the averages to named parameters for display as a single complex bar.
- Template:Data bars/averages/column does the same thing as Template:Data bars/column, but only vertical and always labeled.