Template:Json2table - Wikimedia Commons (original) (raw)
| Uses Lua:Module:Json2table |
|---|
Description
[edit]
This template lets you display tabular data stored on Wikimedia Commons as a regular wiki table. It is adapted from the former template at the English Wikipedia (now deleted there and replaced by templates based on en:Module:Tabular data).
Usage
[edit]
{{Json2table|dataset=...}}
dataset– **required**. Page name in the Commons "Data:" namespace, omitting both the "Data:" prefix and the ".tab" suffix, e.g. for Data:COVID-19 hospitalizations in Denmark.tab, this would beCOVID-19 hospitalizations in Denmark.row_header– (defaulttrue) make the first column header-styled (bold).col_header– (defaulttrue) use the column names as table headers.caption– (defaulttrue) use the dataset's description as the table caption.empty_cell– (default " ") text to show when the JSON value isnull.columns– (default *all*) list of column keys (defined inschema.fields.name) to include, separated with "/".table_format– (defaultclass="wikitable") extra wikitext for the opening<table>tag.bare– (defaultfalse) output only the table's rows and cells (wrap them yourself).nowiki– (defaultfalse) show the table's wikitext instead of rendering it (debugging aid).lang– language code to pick the correct translation from multilingual fields; if omitted the site's content language (English on Commons) is used.
Examples
[edit]
Default rendering
[edit]
Using Data:Chart Example Data.tab. (Note that the "pencil" icon after the table caption provides a link to the raw data.)
{{Json2table|dataset=Chart Example Data}} produces
Some meaningless example data about Middle-Earth for showcasing wiki charts. ![]()
| Date | Elves | Ents | Orcs | Hobbits | Trolls |
|---|---|---|---|---|---|
| 1993/09/09 | 35 | 37 | 8 | 8 | 10 |
| 1993/09/14 | 36 | 33 | 8 | 10 | 11 |
| 1993/09/20 | 35 | 35 | 6 | 11 | 11 |
| 1993/09/25 | 30 | 37 | 8 | 10 | 13 |
| 1993/09/26 | 31 | 36 | 7 | 11 | 13 |
| 1993/09/26 | 28 | 34 | 7 | 12 | 15 |
| 1993/09/30 | 25 | 39 | 6 | 12 | 17 |
| 1993/10/02 | 26 | 38 | 8 | 12 | 14 |
| 1993/10/08 | 22 | 37 | 8 | 12 | 18 |
| 1993/10/16 | 22 | 40 | 7 | 13 | 16 |
| 1993/10/19 | 21 | 39 | 6 | 14 | 17 |
| 1993/10/22 | 18 | 43 | 7 | 14 | 18 |
| 1993/10/22 | 16 | 44 | 7 | 12 | 19 |
| 1993/10/25 | 16 | 41 | 6 | 13 | 18 |
Default rendering of multilingual data
[edit]
This uses Data:COVID-19 hospitalizations in Denmark.tab. Note that the table caption, column labels, and dates are all rendered in Swedish.
{{Json2table|dataset=COVID-19 hospitalizations in Denmark}} produces
Sjukhusinlagda för Covid-19 i Danmark, inklusive antal patienter i intensivvård och kritiskt tillstånd ![]()
Selecting columns and other customizations
[edit]
Using Data:COVID-19 hospitalizations in Denmark.tab. Now the column labels and dates are rendered in Danish.
{{Json2table|dataset=COVID-19 hospitalizations in Denmark |columns=date/hospitalizations |caption=false |row_header=false |lang=da |table_format=class="wikitable sortable"}} produces
| Dato | Hospitalsindlæggelser |
|---|---|
| 11. marts 2020 | 10 |
| 13. marts 2020 | 23 |
| 14. marts 2020 | 23 |
| 15. marts 2020 | 28 |
| 16. marts 2020 | 62 |
| 17. marts 2020 | 82 |
| 18. marts 2020 | 129 |
| 19. marts 2020 | 153 |
| 20. marts 2020 | 186 |
| 21. marts 2020 | 206 |
| 22. marts 2020 | 232 |
| 23. marts 2020 | 254 |
| 24. marts 2020 | 301 |
| 25. marts 2020 | 350 |
| 26. marts 2020 | 386 |
| 27. marts 2020 | 430 |
| 28. marts 2020 | 459 |
| 29. marts 2020 | 499 |
| 30. marts 2020 | 533 |
| 31. marts 2020 | 529 |
| 1. april 2020 | 535 |
See also
[edit]