Template:Graph:PieChart: Difference between revisions

From IxWiki
Jump to navigation Jump to search
mNo edit summary
Tags: Reverted 2017 source edit
mNo edit summary
Tag: Manual revert
 
Line 1: Line 1:
{{Documentation subpage}}
<noinclude>{{Documentation}}</noinclude><includeonly>{{#tag:graph| {
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
  "version": 2,
 
  "height": {{{radius|100}}},
== Pie charts ==
  "width": {{{radius|100}}},
You can add a pie chart with a call to this template. This template uses the Vega version 2 JSON specification. [[:template:Pie chart|An older template]] <nowiki>{{Pie chart}}</nowiki> 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 [https://www.mediawiki.org/wiki/Template:Graph:Chart template GraphChart] also uses Vega version 2 and uses Module:Graph with Scribunto/Lua programming. This Template:Graph:PieChart doesn't use Lua.
{{#ifeq: {{{legend|}}} | - |
 
| "legends": [{"title": "{{{legend|Legend}}}","fill": "color"}], }}
== Parameters ==
  "padding": "auto",
*'''radius''' specifies the radius of the pie chart in pixels, default is 100
  "marks": [
*'''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}]
      "properties": {
*'''rangeliteral''' this can be one of the Vega specified rangeliterals, default is "category10", but can also be a list like ["red", "green"]
        "enter": {
 
          "innerRadius": {"value": {{{innerradius|0}}} },
== Examples ==
          "stroke": {"value": "white"},
'''Example usage''':
          "startAngle": {"field": "layout_start"},
<pre><nowiki>{{Graph:PieChart|legend=Fruits|radius=125|values= [
          "outerRadius": {"value": {{{radius|100}}} },
      {"x": "Peaches","y": 100},
          "endAngle": {"field": "layout_end"},
      {"x": "Plums","y": 32},
          "fill": {"field": "x","scale": "color"},
      {"x": "Blueberries","y": 80},
        }
      {"x": "Strawberries","y": 46},
      },
      {"x": "Bananas","y": 41}
      "from": {
    ]
        "data": "table",
}}</nowiki></pre>
        "transform": [{"field": "y","type": "pie"}]
{{Graph:PieChart|legend=Fruits|radius=100|values= [
      },
      {"x": "Peaches","y": 100},
      "type": "arc"
      {"x": "Plums","y": 32},
    }
      {"x": "Blueberries","y": 80},
  ],
      {"x": "Strawberries","y": 46},
  "data": [
      {"x": "Bananas","y": 41}
    {
     ]
      "name": "table", "values": {{{values| [
}}
       {"x": "peaches","y": 100},
 
       {"x": "plums","y": 32},
== TemplateData ==
       {"x": "blueberries","y": 180},
{{TemplateData header}}
       {"x": "strawberries","y": 46},
<templatedata>
       {"x": "bananas","y": 21}
{
     ] }}}
"params": {
    }
"radius": {
  ],
"label": "Radius",
  "scales": [
"description": "Specify the radius of the pie in number of pixels",
    {
"example": "100",
      "name": "color",
"default": "100",
      "range": {{{rangeliteral|"category10"}}},
"type": "number",
      "domain": {"data": "table","field": "x"},
"suggested": true
      "type": "ordinal"
},
    }
"legend": {
  ]
"label": "Legend Title",
} }}</includeonly>
"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>
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<!-- Categories below this line, please; interwikis at Wikidata -->
 
}}</includeonly>

Latest revision as of 14:05, 10 March 2022