Difference between revisions of "Template:Graph:CategoryPie"

From Public Play Space Community
Line 1: Line 1:
  <graph>
  <graph>
{
{
   "$schema": "https://vega.github.io/schema/vega/v4.json",
   "description": "A basic pie chart example.",
   "width": 200,
   "width": 200,
   "height": 200,
   "height": 200,
   "autosize": "fit",
   "autosize": "none",


   "data": [
   "data": [
Line 10: Line 10:
       "name": "table",
       "name": "table",
       "values": [
       "values": [
         {"id": "Check1", "field": 1},
         {"id": 1, "field": 4},
         {"id": "Check2", "field": 1},
        {"id": 2, "field": 6},
         {"id": "Check3", "field": 1}
         {"id": 3, "field": 10},
        {"id": 4, "field": 3},
         {"id": 5, "field": 7},
        {"id": 6, "field": 8}
       ],
       ],
       "transform": [
       "transform": [
Line 18: Line 21:
           "type": "pie",
           "type": "pie",
           "field": "field",
           "field": "field",
           "startAngle": 0,
           "startAngle": {"signal": "startAngle"},
           "endAngle": 6.29,
           "endAngle": {"signal": "endAngle"},
           "sort": true
           "sort": {"signal": "sort"}
         }
         }
       ]
       ]
Line 31: Line 34:
       "type": "ordinal",
       "type": "ordinal",
       "domain": {"data": "table", "field": "id"},
       "domain": {"data": "table", "field": "id"},
       "range": {"scheme": "category20c"}
       "range": {"scheme": "category20"}
     }
     }
   ],
   ],
Line 43: Line 46:
           "fill": {"scale": "color", "field": "id"},
           "fill": {"scale": "color", "field": "id"},
           "x": {"signal": "width / 2"},
           "x": {"signal": "width / 2"},
           "y": {"signal": "height / 2"},
           "y": {"signal": "height / 2"}
        },
        "update": {
           "startAngle": {"field": "startAngle"},
           "startAngle": {"field": "startAngle"},
           "endAngle": {"field": "endAngle"},
           "endAngle": {"field": "endAngle"},
           "innerRadius": {"value": 60},
          "padAngle": {"signal": "padAngle"},
           "innerRadius": {"signal": "innerRadius"},
           "outerRadius": {"signal": "width / 2"},
           "outerRadius": {"signal": "width / 2"},
           "cornerRadius": {"value": 0},
           "cornerRadius": {"signal": "cornerRadius"}
          "tooltip": {"field": "tooltip"}
         }
         }
       }
       }

Revision as of 07:51, 19 May 2020