Difference between revisions of "Template:Graph:PieChart/doc"

From Salem Wiki
Jump to: navigation, search
(Created page with "{{Documentation subpage}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see Wikipedia:Wikidata) --> == Pie charts ==...")
 
m
 
Line 1: Line 1:
{{Documentation subpage}}
 
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
  

Latest revision as of 22:42, 3 October 2021


Pie charts

You can add a pie chart with a call to this template. This template uses the Vega version 2 JSON specification. An older template {{Pie chart}} is based on CSS rendering. The template GraphChart allows adding of map, line, bar and area charts, as well as stacked line, stacked bar and stacked area charts, but no pie charts. The template GraphChart also uses Vega version 2 and uses Module:Graph with Scribunto/Lua programming. This Template:Graph:PieChart doesn't use Lua.

Parameters

  • radius specifies the radius of the pie chart in pixels, default is 100
  • legend specifies the title to be displayed above the legend, default is "Legend". To hide legend, set it to a "-" value without quotes.
  • values this is a list between square brackets of comma separated label value pairs between single curly braces like [ {"x": "Peaches","y": 100}, {"x": "Plums","y": 32}]
  • rangeliteral this can be one of the Vega specified rangeliterals, default is "category10", but can also be a list like ["red", "green"]

Examples

Example usage:

{{Graph:PieChart|legend=Fruits|radius=125|values= [
      {"x": "Peaches","y": 100},
      {"x": "Plums","y": 32},
      {"x": "Blueberries","y": 80},
      {"x": "Strawberries","y": 46},
      {"x": "Bananas","y": 41}
    ] 
}}

TemplateData

Template:TemplateData header <templatedata> { "params": { "radius": { "label": "Radius", "description": "Specify the radius of the pie in number of pixels", "example": "100", "default": "100", "type": "number", "suggested": true }, "legend": { "label": "Legend Title", "description": "The title that will appear above the legend, or '-' to hide it", "example": "\"Fruits\"", "type": "string", "default": "\"Legend\"", "suggested": true }, "innerradius": { "label": "Inner Radius", "description": "To create a doughnut chart specify an inner radius", "example": "0", "type": "number", "default": "0" }, "values": { "aliases": [ "data" ], "label": "Values", "description": "Specify the label value pairs", "required": true, "example": "[ {\"x\": \"Peaches\",\"y\": 100}, {\"x\": \"Plums\",\"y\": 32}, {\"x\": \"Blueberries\",\"y\": 80}, {\"x\": \"Strawberries\",\"y\": 46}, {\"x\": \"Bananas\",\"y\": 41} ] " }, "rangeliteral": { "aliases": [ "colors" ], "label": "The colors of the slices", "description": "The colors of the slices, specified as Vega defined rangeliteral. This can also be a list like [ \"red\", \"green\" ]", "example": "\"category10\"", "type": "string", "default": "\"category10\"" } }, "description": "This template adds a pie chart to the page using Graph extension", "format": "inline" } </templatedata>