User:McBayne/Template:Json2table/doc: Difference between revisions – Wikipedia

From Wikipedia, the free encyclopedia

Content deleted Content added


 

Line 70: Line 70:

* [[Template:Wikidata list]]

* [[Template:Wikidata list]]

<!–

<includeonly>

<includeonly>

[[Category:Lua-based templates]]

[[Category:Lua-based templates]]

[[Category:Table templates]]

[[Category:Table templates]]

</includeonly>

</includeonly>

–>


Latest revision as of 17:29, 10 January 2026

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).

{{User:McBayne/Template:Json2table|dataset=...}}
  • dataset – **required**. Page name in the Commons “Data:” namespace, omitting both the “Data:” prefix and the “.tab” suffix, e.g. for c:Data:Area of Glacier de la Plaine Morte by year.tab, this would be Area of Glacier de la Plaine Morte by year.tab.
  • row_header – (default true) make the first column header-styled (bold).
  • col_header – (default true) use the column names as table headers.
  • caption – (default true) use the dataset’s description as the table caption.
  • empty_cell – (default ” “) text to show when the JSON value is null.
  • columns – (default *all*) list of column keys (defined in schema.fields.name) to include, separated with “/”.
  • table_format – (default class="wikitable") extra wikitext for the opening <table> tag.
  • bare – (default false) output only the table’s rows and cells (wrap them yourself).
  • nowiki – (default false) 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.

Using c:Data:Chart Example Data.tab. (Note that the “pencil” icon after the table caption provides a link to the raw data.)

{{User:McBayne/Template: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 c:Data:Area of Glacier de la Plaine Morte by year.tab. Note that the table caption, column labels, and dates are all rendered in Swedish.

{{User:McBayne/Template:Json2table|dataset=Area of Glacier de la Plaine Morte by year.tab}} produces

Area of Plaine Morte Glacier by year
year Area in km²
1850 11.4
1973 9.1
1999 7.8
2023 6.78

Selecting columns and other customizations

[edit]

Using c:Data:Area of Glacier de la Plaine Morte by year.tab. Now the column labels and dates are rendered in Danish.

{{User:McBayne/Template:Json2table|dataset=Area of Glacier de la Plaine Morte by year.tab
|columns=a0/a1
|caption=false |row_header=false
|lang=de
|table_format=class="wikitable sortable"
|output=chart
|template=Area of Vadret da Tschierva by year.tab
|template_x=1
|chart_source=[[c:Data:Area of Glacier de la Plaine Morte by year.tab]]
|chart_y2=8,8,8,8
|chart_y2Title=Example_RefLine
|chart_xType=string}}
produces

67891011121850197319992022Fläche in km²Example_RefLine

{{User:McBayne/Template:Json2table|dataset=Chart Example Data|output=chart|chart_xType=date|chart_type=area}} produces

0204060801009/9/19939/26/199310/8/199310/22/1993ElvesEntsOrcsHobbitsTrolls

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version