Content deleted Content added
No edit summary |
No edit summary |
||
Line 3:
{{Lua sidebar}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
Module with helper functions for the [[Help:Graph|Graph]] extension to display graphs and maps. From [[:de:Modul:Graph]].
== Functions for templates ==
=== <tt>map</tt> ===
Creates a JSON object for <tt><nowiki><graph></nowiki></tt> to display a political map with colored highlights. In the article namespace the template {{Vorlage|Graph:Map}} should be used instead. See its page for use cases.
Maps can be found at [[Special:Prefixindex/Template:Graph:Map/Inner/]] (for example [[Template:Graph:Map/Inner/Worldmap2c-json|Worldmap2c-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/Template:Graph:Map/Inner/]] like [[Template:Graph:Map/Inner/Worldmap2c-json|Worldmap2c-json]] should only be referenced by their name while omitting the Modul: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 <tt>//en.wikipedia.org/w/index.php?title=''mapname''&action=raw</tt>, 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>
{{Special:
* '''scale:''' the scaling factor of the map (default: 100)
* '''projection:''' the [[:en:map projection|map projection]] to use. Supported values are listed at https://github.com/mbostock/d3/wiki/Geo-Projections. The default value is <tt>equirectangular</tt> for an [[:en:equirectangular projection|equirectangular projection]].
* '''center:''' map center (corresponds in the map data to both comma-separated values of the <tt>scale</tt> field)
* '''feature:''' which geographic objects should be displayed (corresponds in the map data to the name of the field under the <tt>objects</tt> field). The default is value <tt>countries</tt>.
* '''ids of geographic entities''': The actual parameter names depend on the base map and the selected feature. For example, for the above mentioned world map the ids are [[:en:ISO country codes|ISO country codes]]. The values can be either colors or numbers in case the geographic entities should be associated with numeric data: <tt>DE=lightblue</tt> marks Germany in light blue color, and <tt>DE=80.6</tt> 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 <tt>#rgb</tt>/<tt>#rrggbb</tt> or by a [[:en: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 <tt>category10</tt> and <tt>category20</tt>] can also be used.
* '''scaleType:''' supported values are <tt>linear</tt> for a linear mapping between the data values and the color scale, <tt>log</tt> for a log mapping, <tt>pow</tt> for a power mapping (the exponent can be provided as <tt>pow 0.5</tt>), <tt>sqrt</tt> for a square-root mapping, and <tt>quantize</tt> 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 <tt>quantize</tt>)
* '''defaultValue:''' default value for unused geographic entities. In case the id values are colors the default value is <tt>silver</tt>, 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.
|