{
    "$schema": "https://vega.github.io/schema/vega/v4.json",
    "width": 600,
    "height": 360,
    "data": [
        {
            "name": "data_tree",
            "url": "<%= absolute_url %>data/sunburst-4.json",
            "transform": [
                {
                    "type": "stratify",
                    "key": "id",
                    "parentKey": "parent"
                },
                {
                    "type": "partition",
                    "field": "size",
                    "sort": {
                        "field": "value"
                    },
                    "size": [
                        {
                            "signal": "0.5 * PI"
                        },
                        {
                            "signal": "width"
                        }
                    ],
                    "as": [
                        "a0",
                        "r0",
                        "a1",
                        "r1",
                        "depth",
                        "children"
                    ]
                }
            ]
        }
    ],
    "scales": [
        {
            "name": "scales_color",
            "type": "ordinal",
            "domain": {
                "data": "data_tree",
                "field": "size"
            },
            "range": {
                "scheme": "blueorange",
                "count": 10
            }
        }
    ],
    "marks": [
        {
            "name": "marks_arc",
            "type": "arc",
            "from": {
                "data": "data_tree"
            },
            "encode": {
                "enter": {
                    "x": {
                        "value": 0
                    },
                    "stroke": {
                        "value": "white"
                    },
                    "zindex": {
                        "value": 0
                    }
                },
                "update": {
                    "startAngle": {
                        "field": "a0"
                    },
                    "endAngle": {
                        "field": "a1"
                    },
                    "innerRadius": {
                        "field": "r0"
                    },
                    "outerRadius": {
                        "field": "r1"
                    },
                    "y": {
                        "signal": "height"
                    },
                    "fill": {
                        "scale": "scales_color",
                        "field": "size"
                    },
                    "strokeWidth": {
                        "signal": "width/100 * 0.5"
                    },
                    "tooltip": {
                        "signal": "datum.name + (datum.size ? ', ' + datum.size + ' bytes' : '')"
                    }
                }
            }
        },
        {
            "name": "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": "datum.a0"
                    },
                    "y": {
                        "signal": "height"
                    },
                    "theta": {
                        "signal": "(datum.a0+datum.a1)/2"
                    },
                    "radius": {
                        "signal": "datum.r0 * 1.2"
                    },
                    "angle": {
                        "signal": "(datum.a0+datum.a1)*90/PI-90"
                    },
                    "text": {
                        "signal": "datum.parent != null || datum.parent == 1 ? datum.name : ''"
                    },
                    "fill": {
                        "signal": "datum.size != null ? 'black' : 'white'"
                    },
                    "fontSize": {
                        "signal": "width/100 * 2"
                    }
                }
            }
        }
    ]
}