有没有办法用Vega-Lite创建半饼图?

问题描述 投票:0回答:1

我有一个饼图,我想将其转换为半饼图。我尝试了不同的设置,但无法让它工作。可以吗?

json charts visualization vega-lite
1个回答
0
投票

你需要一个秤。

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "mark": {"type": "arc", "radius2": 50},
  "data": {"values": [{"type": "+", "value": 60}, {"type": "-", "value": 40}]},
  "encoding": {
    "theta": {
      "field": "value",
      "type": "quantitative",
      "scale": {
        "type": "linear",
        
        "rangeMax": 1.5708,
        "rangeMin": -1.5708
      }
    },
    "color": {"field": "type", "type": "nominal"}
  },
  "config": {"legend": {"disable": true}}
}
© www.soinside.com 2019 - 2024. All rights reserved.