powerbidaxpowerbi-desktopvega-litedeneb

Pie chart Vega lite : How to align labels & numbers?


I'm trying to get this look Pie Ideal label and at this point, i get : My try

Labels are not aligned with numbers. When i try "align", everything is going left or right...but not as attended. As a matter of fact, I need labels to be next to the outcircle whatever position it is... and aligned with numbers.

link to my pbix file

Thank you for your help !


Solution

  • I think this should get you close enough.

    enter image description here

    {
      "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
        }
      },
      "layer": [
        {
          "name": "******RING BACKGROUND******",
          "mark": {
            "type": "arc",
            "outerRadius": 100
          }
        },
        {
          "name": "******Name labels******",
          "mark": {
            "type": "text",
            "radius": 110,
            "align": {
              "expr": "scale('theta', ((datum.Points_calculation_end - datum.Points_calculation_start)/2) + datum.Points_calculation_start ) > 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"
            }
          }
        }
      ]
    }