Difference between revisions of "Template:Graph:CategoryPie"

From Public Play Space Community
 
(37 intermediate revisions by the same user not shown)
Line 1: Line 1:
<graph>
<graph>{
{
   "width": 100,
  "$schema": "https://vega.github.io/schema/vega/v5.json",
   "height": 100,
  "description": "A basic bar chart example, with value labels shown upon mouse hover.",
   "width": 400,
   "height": 200,
  "padding": 5,
 
   "data": [
   "data": [
     {
     {
       "name": "table",
       "name": "table",
       "values": [
       "values": [
        {"category": "A", "amount": 28},
          {"name":"GAME","color":"#2bddff","data":1},
        {"category": "B", "amount": 55},
          {"name":"PLAY","color":"#00d67f","data":1},
        {"category": "C", "amount": 43},
          {"name":"SPACE","color":"#0000ff","data":1}
        {"category": "D", "amount": 91},
      ],
        {"category": "E", "amount": 81},
       "transform": [{"type": "pie", "field": "data"}]
        {"category": "F", "amount": 53},
        {"category": "G", "amount": 19},
        {"category": "H", "amount": 87}
      ]
    }
  ],
 
  "signals": [
    {
      "name": "tooltip",
       "value": {},
      "on": [
        {"events": "rect:mouseover", "update": "datum"},
        {"events": "rect:mouseout",  "update": "{}"}
      ]
     }
     }
   ],
   ],
   "scales": [
   "scales": [
     {
     {
       "name": "xscale",
       "name": "r",
       "type": "band",
       "type": "sqrt",
       "domain": {"data": "table", "field": "category"},
       "domain": {"data": "table", "field": "data"},
       "range": "width",
       "range": [0, 50]
      "padding": 0.05,
      "round": true
    },
    {
      "name": "yscale",
      "domain": {"data": "table", "field": "amount"},
      "nice": true,
      "range": "height"
     }
     }
   ],
   ],
  "axes": [
    { "orient": "bottom", "scale": "xscale" },
    { "orient": "left", "scale": "yscale" }
  ],
   "marks": [
   "marks": [
     {
     {
       "type": "rect",
       "type": "arc",
       "from": {"data":"table"},
       "from": {"data": "table"},
       "encode": {
       "properties": {
         "enter": {
         "enter": {
           "x": {"scale": "xscale", "field": "category"},
           "x": {"field": {"group": "width"}, "mult": 0.5},
           "width": {"scale": "xscale", "band": 1},
           "y": {"field": {"group": "height"}, "mult": 0.5},
           "y": {"scale": "yscale", "field": "amount"},
           "startAngle": {"field": "layout_start"},
           "y2": {"scale": "yscale", "value": 0}
          "endAngle": {"field": "layout_end"},
           "innerRadius": {"value": 0},
          "outerRadius": {"value": 100}
         },
         },
         "update": {
         "update": {
           "fill": {"value": "steelblue"}
           "fill": {"field": "color"}
        },
        "hover": {
          "fill": {"value": "red"}
         }
         }
       }
       }
Line 77: Line 41:
     {
     {
       "type": "text",
       "type": "text",
       "encode": {
       "from": {"data": "table"},
      "properties": {
         "enter": {
         "enter": {
          "x": {"field": {"group": "width"}, "mult": 0.5},
          "y": {"field": {"group": "height"}, "mult": 0.5},
          "radius": {"scale": "r", "field": "data", "offset": 8},
          "angle": {"value": 25},
          "theta": {"field": "layout_mid"},
          "fill": {"value": "white"},
           "align": {"value": "center"},
           "align": {"value": "center"},
           "baseline": {"value": "bottom"},
           "baseline": {"value": "middle"},
           "fill": {"value": "#333"}
           "text": {"field": "name"},
        },
           "font": {"value": "Bebas Neue Bold"},
        "update": {
           "fontSize": {"value": 25},
           "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
           "fontWeight": {"value": "bold"}
           "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
           "text": {"signal": "tooltip.amount"},
          "fillOpacity": [
            {"test": "datum === tooltip", "value": 0},
            {"value": 1}
          ]
         }
         }
       }
       }
Line 96: Line 61:
   ]
   ]
}
}
</graph>


</graph>
<noinclude>
<templatedata>
{
"params": {
"GAME":{
"type": "boolean",
"default": "1",
"required": true,
"suggested": true,
"description": "State whether this type of parameter is used by the project."},
"PLAY":{
"type": "boolean",
"default": "1",
"required": true,
"suggested": true,
"description": "State whether this type of parameter is used by the project."},
"SPACE":{
"type": "boolean",
"default": "1",
"required": true,
"suggested": true,
"description": "State whether this type of parameter is used by the project."}
},
"paramOrder": [
"GAME",
"PLAY",
"SPACE"
],
"description": "Template for selecting a parameter to the pie",
"format": "block"
}
</templatedata>
</noinclude>

Latest revision as of 07:38, 20 May 2020


Template for selecting a parameter to the pie

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
GAMEGAME

State whether this type of parameter is used by the project.

Default
1
Booleanrequired
PLAYPLAY

State whether this type of parameter is used by the project.

Default
1
Booleanrequired
SPACESPACE

State whether this type of parameter is used by the project.

Default
1
Booleanrequired