| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
| Modul | Deutsch | English | Modul: | Dokumentation | ||
Module with helper functions for the Graph extension.
mapCreates a JSON object for <graph> to display a political map with colored highlights. In the article namespace the template {{Graph:Map}} should be used instead. See its page for use cases.
Maps can be found at Spezial:Präfixindex/Modul:Graph/ (for example WorldMap-iso2.json with country borders) and new maps should also be saved under Modul:Graph/.
Parameters:
//en.wikipedia.org/w/index.php?title=mapname&action=raw, i.e. protocol-relative without leading http/s and a trailing action=raw to fetch the raw content only). 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.equirectangular for an equirectangular projection.scale field)objects field). The default is value countries.DE=lightblue marks Germany in light blue color, and DE=80.6 assigns Germany the value 80.6 (population in millions). In the latter case, the actual color depends on the following parameters.#rgb/#rrggbb or by a CSS color name. Instead of a list, the built-in color palettes category10 and category20 can also be used.linear for a linear mapping between the data values and the color scale, log for a log mapping, pow for a power mapping (the exponent can be provided as pow 0.5), sqrt for a square-root mapping, and quantize for a quantized scale, i.e. the data is grouped in as many classes as the color palette has colors.quantize)silver, in case of numbers it is 0.chartCreates a JSON object for <graph> to display charts. In the article namespace the template {{Graph:Chart}} should be used instead. See its page for use cases.
Parameters:
line for line charts, area for area charts, and rect for (column) bar charts, and pie for pie charts. Multiple series can stacked using the stacked prefix, e.g. stackedarea.monotone for a monotone cubic interpolation – further supported values are listed at https://github.com/vega/vega/wiki/Marks#area.#rgb/#rrggbb/#aarrggbb or by a CSS color name. For #aarrggbb the aa component denotes the alpha channel, i.e. FF=100% opacity, 80=50% opacity/transparency, etc. (The default color palette is category10).% can be used to output percentages.integer for integers, number for real numbers, date for dates (e.g. YYYY/MM/DD), and string for ordinal values.\,)y2 denotes the radiuses of the corresponding sectors.name1:value1, name2:value2:
midangle this also defines if the text is inside or outside the chart.midangle (default) for dynamic angles based on the mid-angle of the pie sector.The functions mapWrapper and chartWrapper are wrappers to pass all parameters of the calling template to the respective map and chart functions.
Note: In the editor preview the graph extension creates a canvas element with vector graphics. However, when saving the page a PNG raster graphics is generated instead.
Note to developers: New functionality can be tested with the Vega Editor, that also contains a large amount of example code.