== Functions for templates ==
=== <code>map</code> ===
Creates a JSON object for <code><nowiki><graph></nowiki></code> to display a political map with colored highlights. In the article namespace the template [[Template:Graph:Map]] should be used instead. See its page for use cases.
Maps can be found at [[Special:Prefixindex/Module:Graph/]] (for example [[Module:Graph/WorldMap-iso2.json|WorldMap-iso2.json]] with country borders) and new maps should also be saved under Module:Graph/.
'''Parameters:'''
}}{{#ifeq:{{{1|map}}}|map|<!-- Parts to be transcluded from the wrapper Template:Graph:Map -->
* '''basemap''': Sets the base map. The map definitions must follow the [https://github.com/mbostock/topojson/wiki TopoJSON] format and if saved in Wikipedia are available for this module. Maps in the default directory [[Special:Prefixindex/Module:Graph/]] such as [[Module:Graph/WorldMap-iso2.json|WorldMap-iso2.json]] should only be referenced by their name while omitting the Module:Graph/ prefix to allow better portability. The parameter also accepts URLs, e.g. maps from other Wikipedia versions (the link should follow the scheme of <code>//en.wikipedia.org/w/index.php?title=''mapname''&action=raw</code>, i.e. protocol-relative without leading http/s and a trailing action=raw to fetch the raw content only). <small>URLs to maps on external sites should be avoided for the sake of link stability, performance, security, and she be assumed to be blocked by the software or browser anyway.</small>
* '''scale''': the scaling factor of the map (default: 100)
* '''projection''': the [[map projection]] to use. Supported values are listed at https://github.com/mbostock/d3/wiki/Geo-Projections. The default value is <code>equirectangular</code> for an [[equirectangular projection]].
* ids of geographic entities: The actual parameter names depend on the base map. For example, for the above mentioned world map the ids are [[ISO country codes]]. The values can be either colors or numbers in case the geographic entities should be associated with numeric data: <code>DE=lightblue</code> marks Germany in light blue color, and <code>DE=80.6</code> assigns Germany the value 80.6 (population in millions). In the latter case, the actual color depends on the following parameters.
** '''colorScale''': the color palette to use for the color scale. The palette must be provided as a comma-separated list of color values. The color values must be given either as <code>#rgb</code>/<code>#rrggbb</code> or by a [[Web colors#X11 colour names|CSS color name]]. Instead of a list, the built-in color palettes [https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors <code>category10</code> and <code>category20</code>] can also be used.
** '''scaleType''': supported values are <code>linear</code> for a linear mapping between the data values and the color scale, <code>log</code> for a log mapping, <code>pow</code> for a power mapping (the exponent can be provided as <code>pow 0.5</code>), <code>sqrt</code> for a square-root mapping, and <code>quantize</code> for a quantized scale, i.e. the data is grouped in as many classes as the color palette has colors.
** '''domainMin''': lower boundary of the data values, i.e. smaller data values are mapped to the lower boundary
** '''domainMax''': upper boundary of the data values, i.e. larger data values are mapped to the upper boundary
** '''legend''': show color legend (does not work with <code>quantize</code>)
* '''defaultValue''': default value for unused geographic entities. In case the id values are colors the default value is <code>silver</code>, in case of numbers it is 0.
}}{{#if:{{{1|}}}||
* '''formatjson''': format JSON object for better legibility
=== <code>chart</code> ===
Creates a JSON object for <code><nowiki><graph></nowiki></code> to display charts. In the article namespace the template [[Template:Graph:Chart]] should be used instead. See its page for use cases.
|