VEGA Sunburst 在圆弧上显示标签名称

VEGA Sunburst display label name on arcs

有人知道如何在 https://vega.github.io/vega/examples/sunburst/ 示例的弧上显示标签名称吗? 谢谢

织女星 text mark has properties radius and theta that can show text in polar coordinates. For example see Vega radial tree example

对于朝阳图,此文本块呈现类似于放射状树示例的文本:

{
  "type": "text",
  "from": {"data": "tree"},
  "encode": {
    "enter": {
      "text": {"field": "name"},
      "fontSize": {"value": 9},
      "baseline": {"value": "middle"},
      "align": {"value": "center"}
    },
    "update": {
      "x": {"signal": "width / 2"},
      "y": {"signal": "height / 2"},

      "radius": {"signal": "(datum['r0'] == 0 ? 0 : datum['r0'] + datum['r1']) / 2"},

      "theta": {"signal": "(datum['a0'] + datum['a1']) / 2"},

      "angle": {"signal": "datum['r0'] == 0 ? 0 : ((datum['a0'] + datum['a1']) / 2) * 180 / PI + (inrange(((datum['a0'] + datum['a1']) / 2) % (2 * PI), [0, PI]) ? 270 : 90)"},

      "tooltip": {"signal": "datum.name + (datum.size ? ', ' + datum.size + ' bytes' : '')"}
    }
  }
}

注意:theta 以弧度为单位,但 angle 以度为单位。

View in Vega online editor