'Is there a way to create a half pie chart with Vega-Lite?

I have a pie chart which I would like to convert to a half pie chart. I have tried different settings but I cannot get it to work. Is it possible?



Solution 1:[1]

You need a scale.

{
  "$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}}
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David