Vega-Lite - 如何绘制箭头?

Vega-Lite - How to plot an arrow?

我正在尝试绘制有向图。因此,我想从一个节点绘制一个箭头 给另一个。是否可以在 Vega-Lite 上执行此操作?如果是,那又如何呢?

Vega-Lite 不支持线段上的箭头。您可以在此处查看开放功能请求:https://github.com/vega/vega-lite/issues/4270

对于某些应用程序,可能适合使用 unicode 箭头注释图表;这是一个简短的例子 (open in editor):

{
  "data": {
    "values": [{"x": 1, "y": 2}, {"x": 2, "y": 4}]
  },
  "mark": {"type": "text", "angle": -45, "dx": -20, "fontSize": 35},
  "encoding": {
    "text": {"value": "➟"},
    "x": {"field": "x", "type": "quantitative"},
    "y": {"field": "y", "type": "quantitative"}
  }
}