0

I'm currently trying to create a donut chart in Vega-lite that uses Royalty as theta and Year as color, and includes both values in the legend. The legend for color is working fine, but I cannot figure out how to either concatenate the theta values, or create a new legend.

I've tried hiding another arc underneath the current one and using Royalty as color, but Vega-lite connects the legends so you cannot control them individually.

I've tried creating a new text mark and moving it next to the legend, but the values stack as there is no x or y values. This way also feels wrong. I've gone over the documentation multiple times and I can't seem to find a solution.

Is there a way to do this?

vega-editor

1 Answers1

0

Chart

Just concatenate the values in the Year field.

      {"Year": "2022 - 100000", "Royalty": 100000},
      {"Year": "2021 - 150000", "Royalty": 150000},
      {"Year": "2020 - 200000", "Royalty": 200000}

You could also create the label in DAX and pass it in as a separate column.

      {"Year": "2022", "Year label": "2022 - 100000", "Royalty": 100000},
      {"Year": "2021", "Year label": "2021 - 150000", "Royalty": 150000},
      {"Year": "2020", "Year label": "2020 - 200000", "Royalty": 200000}

Open the Chart in the Vega Editor

TheRizza
  • 1,577
  • 1
  • 10
  • 23
  • Can't believe I didn't think of just concatenating the label in DAX! That worked, thank you! – Wiremu-Sharman Dec 07 '22 at 16:59
  • I've learned a bunch of tricks like that from Kerry Kolosko's website. See https://kerrykolosko.com/category/custom-visualisations/deneb/. Her KPIs are out of this world amazing and has some great examples with images too. – TheRizza Dec 07 '22 at 17:05