{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "width": 600,
  "height": 600,
  "autosize": "fit",
  "signals": [
    {
      "name": "signal_startAngle",
      "value": 0
    },
    {
      "name": "signal_endAngle",
      "value": 6.29
    },
    {
      "name": "signal_padAngle",
      "value": 0
    },
    {
      "name": "signal_innerRadius",
      "value": 150
    },
    {
      "name": "signal_cornerRadius",
      "value": 0
    },
    {
      "name": "signal_sort",
      "value": false
    },
    {
      "name": "signal_radius",
      "update": "(width/100)*(height/100)*10"
    }
  ],
  "data": [
    {
      "name": "data_tree",
      "url": "<%= absolute_url %>data/sunburst-1.json",
      "transform": [
        {
          "type": "stratify",
          "key": "id",
          "parentKey": "parent"
        },
        {
          "type": "partition",
          "field": "size",
          "sort": {
            "field": "value"
          },
          "size": [
            {
              "signal": "2 * PI"
            },
            {
              "signal": "width / 2"
            }
          ],
          "as": [
            "a0",
            "r0",
            "a1",
            "r1",
            "depth",
            "children"
          ]
        }
      ]
    },
    {
      "name": "data_total",
      "from": {
        "data": "data_tree"
      },
      "transform": [
        {
          "type": "aggregate",
          "groupby": [
            "parent"
          ],
          "fields": [
            "size"
          ],
          "ops": [
            "sum"
          ],
          "as": [
            "total"
          ]
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "scales_color",
      "type": "ordinal",
      "domain": {
        "data": "data_tree",
        "field": "size"
      },
      "range": [
        "#5d5b5b",
        "#eb8c56",
        "#fdfebf",
        "#90b976"
      ]
    }
  ],
  "marks": [
    {
      "name": "marks_arc",
      "type": "arc",
      "from": {
        "data": "data_tree"
      },
      "encode": {
        "enter": {
          "stroke": {
            "value": "white"
          },
          "strokeWidth": {
            "value": 1
          },
          "zindex": {
            "value": 1
          }
        },
        "update": {
          "x": {
            "signal": "width / 2"
          },
          "y": {
            "signal": "height / 2"
          },
          "startAngle": {
            "field": "a0"
          },
          "endAngle": {
            "field": "a1"
          },
          "innerRadius": {
            "field": "r0"
          },
          "outerRadius": {
            "field": "r1"
          },
          "fill": {
            "scale": "scales_color",
            "field": "size"
          },
          "tooltip": {
            "signal": "datum.name + (datum.size ? ', ' + datum.size + ' bytes' : '')"
          }
        }
      }
    },
    {
      "name": "marks_center_circle",
      "type": "symbol",
      "encode": {
        "enter": {
          "shape": {
            "value": "circle"
          },
          "size": {
            "value": 5000
          },
          "fill": {
            "value": "white"
          }
        },
        "update": {
          "x": {
            "signal": "width/2"
          },
          "y": {
            "signal": "height/2"
          }
        }
      }
    },
    {
      "name": "marks_label_text",
      "type": "text",
      "from": {
        "data": "data_tree"
      },
      "encode": {
        "enter": {
          "fontWeight": {
            "value": "bold"
          },
          "baseline": {
            "value": "middle"
          },
          "align": {
            "value": "center"
          },
          "limit": {
            "value": 100
          }
        },
        "update": {
          "x": {
            "signal": "width/2"
          },
          "y": {
            "signal": "height/2"
          },
          "theta": {
            "signal": "(datum.a0+datum.a1)/2"
          },
          "radius": {
            "signal": "datum.r0 + 50"
          },
          "text": {
            "signal": "datum.name"
          },
          "fill": {
            "signal": "datum.size != null ? 'black' : 'white'"
          }
        }
      }
    },
    {
      "name": "marks_percent_text",
      "type": "text",
      "from": {
        "data": "data_tree"
      },
      "encode": {
        "enter": {
          "fontWeight": {
            "value": "bold"
          },
          "baseline": {
            "value": "middle"
          },
          "align": {
            "value": "right"
          },
          "limit": {
            "value": 100
          }
        },
        "update": {
          "x": {
            "signal": "width/2"
          },
          "y": {
            "signal": "height/2 - 10"
          },
          "theta": {
            "signal": "(datum.a0+datum.a1)/2"
          },
          "radius": {
            "signal": "datum.r0 + 50"
          },
          "text": {
            "signal": "datum.size != null ? datum.size +'%': ''"
          },
          "fill": {
            "signal": "datum.size != null ? 'black' : 'white'"
          }
        }
      }
    }
  ]
}