Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18035

How to Position Text Labels at the Center of Arcs in a Radial Bar Chart using Vega?

$
0
0

I'm trying to create a radial bar chart using Vega, and I want to add text labels at the center of each arc in the chart to display the corresponding values. However, I'm having trouble positioning the text labels correctly within the arcs.

Here's a simplified version of my Vega specification:

  {"type": "text","name": "labels","from": {"data": "table"},"encode": {"update": {"radius": {"scale": "chbands", "field": "category"},"x": {"signal": "width", "mult": 0.5},"y": {"signal": "height", "mult": 0.5},"dx": {"value": 0},"dy": {"value": 0},"text": {"signal": "isValid(datum['amount']) && datum['amount'] !== 0 ? datum['amount'] : ''"          },"align": {"value": "center"},"baseline": {"value": "middle"},"theta": {"signal": "scale('theta', 0.5 * datum['r0'] + 0.5 * datum['r1'])"          }        }      }    }

Here is the screenshot of my current version.circular bar chart using vega

Complete Vega Spec with Data

My expectation is that each text label should be centrally aligned with the arc path it belongs.


Viewing all articles
Browse latest Browse all 18035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>