Template:OWID/doc

From wikiNonStop
Jump to navigation Jump to search

Use this template to load interactive charts from Our World in Data. The charts will only be loaded after a popup asking the user for consent to share their IP address with Our World in Data.

This template is a template gadget that requires the OWIDPopup gadget to work. Follow the installation instructions to get it working in your wiki.

Usage

Minimal

Markup Renders as
{{OWID
| owid = grapher/adolescent-fertility
}}

Full

Markup Renders as
{{OWID
| owid = grapher/adolescent-fertility
| title = Adolescent birth rate
| image = Adolescent birth rate, OWID.svg
| width = 400px
| float = none
| caption = Adolescent birth rate according to Our World in Data.
| alt = World heat map showing adolescent birth rate with a play button to make it more interactive
}}
World heat map showing adolescent birth rate with a play button to make it more interactive
Adolescent birth rate according to Our World in Data.

Installation

To install this template in your wiki:

  1. Create a template with the following markup. You can choose the template name, parameter names and defaults to suit your wiki.
    <includeonly><div class="OWIDPopup" style="float:{{{float|right}}}" data-owid="{{{owid}}}" data-title="{{{title|}}}">[[File:{{{image|Line chart icon Noun 70892 cc.svg}}}|thumb|{{{float|right}}}|{{{width|220px}}}|alt={{{alt|}}}|{{{caption|}}}]]</div>[[Category:Gadget:OWIDPopup]]</includeonly>
    
  2. Create MediaWiki:Gadget-OWIDPopup.js with the following code:
    /**
     * OWIDPopup embeds interactive charts from Our World in Data
     * Documentation: https://www.mediawiki.org/wiki/Template:OWIDPopup
     * Source code: https://www.mediawiki.org/wiki/MediaWiki:Gadget-Global-OWIDPopup.js
     */
    mw.loader.load( '//www.mediawiki.org/w/load.php?modules=ext.gadget.Global-OWIDPopup' );
    
  3. Add the following gadget to MediaWiki:Gadgets-definition:
    * OWIDPopup[ResourceLoader|hidden|default|categories=Gadget:OWIDPopup]|OWIDPopup.js
    

Done! Add your template to any page to verify that the installation was successful.

Categorization

All the articles will be included in a category called OWIDPopup.js. You can create that category and use it for tracking.

Template data

Use this template to insert interactive charts from Our World in Data.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
OWIDowid

Identifier of the chart to embed from Our World in Data

Example
grapher/adolescent-fertility
Stringoptional
Titletitle

Title of the chart

Example
Adolescent birth rate
Stringoptional
Imageimage

Name of the image

Example
Adolescent birth rate, OWID.svg
Stringoptional
Floatfloat

Position of the image

Suggested values
left right none
Default
right
Example
none
Stringoptional
Widthwidth

Width of the image

Default
220px
Example
400px
Stringoptional
Alternative text alt

Alternative text for the image

Stringoptional
Captioncaption

Caption of the image

Example
Adolescent birth rate according to Our World in Data
Stringoptional

See also