How to dynamically adjust text label radius in a Vega-Lite pie chart when chart size changes? #9701
VikrantRamesh
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am creating a pie chart in Vega-Lite and adding text labels on top of it. The chart’s size can vary dynamically (for example, when the window or container is resized), and I want the radius of the text labels to adjust automatically to match the chart’s new size.
What I tried: Right now, I can set a fixed radius value for the text marks, but that doesn’t scale correctly when the chart size changes.
I tried using
radiusOffsetfor the text marks, hoping it would adjust relative to the pie radius, but it seems thatradiusOffsetonly works when theradiuschannel is defined in thethetaencoding. Unfortunately, settingradiusinthetaremoves the dynamic resizing behavior of the pie chart, which I want to preserve.Example (Vegalite Editor):
In this setup, the
radiusOffsetdoesn’t take effect unless I explicitly define a radius encoding — but doing so fixes the pie radius, breaking the responsive scaling.Question: Is there a way in Vega-Lite to make the text label radius (or offset) dynamic so it scales automatically with the chart size, without having to define a fixed radius in the theta encoding?
Beta Was this translation helpful? Give feedback.
All reactions