Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pie Chart Vega Lite : Conditionnal Slice colors

I would like the pie slices to be colored with the powerBi scheme color except for the "other players" section which needs to be always grey.

[My Pbx link]https://1drv.ms/u/s!An2aQoxg76Kv6jnMWzcGS6aWvMr9?e=kEt8cY

Thanks in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

enter image description here

{
  "width": "container",
  "height": "container",
  "data": {"name": "dataset"},
  "encoding": {
    "theta": {
      "field": "Points_calculation",
      "type": "quantitative",
      "stack": true
    },
    "order": {
      "field": "ORDER",
      "type": "quantitative",
      "sort": "descending"
    },
    "color": {
      "field": "Name",
      "type": "nominal",
      "sort": {
        "field": "ORDER",
        "order": "descending"
      },
      "legend": null, 
       "scale": {"scheme": "pbiColorNominal"}
    }
  },
  "layer": [
    {
      "name": "******RING BACKGROUND******",
      "mark": {
        "type": "arc",
        "outerRadius": 100
      }
    },
    {
      "mark": {
        "type": "arc",
        "outerRadius": 100, "fill":{"expr":"datum.Name =='Other players'?'grey':''"}
      }
    },
    {
      "name": "******Name labels******",
      "mark": {
        "type": "text",
        "radius": 115,
        "dy" : 4,
        "fill": "black",
        "align": {
          "expr": "scale('theta', datum.Points_calculation_end) > PI ?'right':'left'"
        }
      },
      "encoding": {
        "text": {
          "field": "Name",
          "type": "nominal"
        }
      }
    },
    {
      "name": "******Values_Labels******",
      "mark": {
        "type": "text",
        "radius": 80,
        "fill": "black"
      },
      "encoding": {
        "text": {
          "field": "Points_calculation",
          "type": "nominal"
        }
      }
    }
  ]
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading