Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independent theta and radius in pie chart renders incorrectly #3805

Open
nine9ths opened this issue Feb 17, 2025 · 0 comments
Open

Independent theta and radius in pie chart renders incorrectly #3805

nine9ths opened this issue Feb 17, 2025 · 0 comments
Labels
bug needs-triage Bug report needs maintainer response

Comments

@nine9ths
Copy link

What happened?

I started with this chart:

import altair as alt
import pandas as pd

data = pd.DataFrame({
    'category': ['A', 'B', 'C', 'D'],
    'value': [40, 20, 30, 10],
    'radius_value': [400, 500, 400, 400]
})

chart = alt.Chart(data).mark_arc().encode(
    theta=alt.Theta(field="value", type="quantitative", stack=True),
    radius=alt.Radius(field="value", type="quantitative", scale=alt.Scale(zero=True)),
    color="category:N"
)

chart.show()

This draws as expected.
I then changed the radius field to "radius_value":

import altair as alt
import pandas as pd

data = pd.DataFrame({
    'category': ['A', 'B', 'C', 'D'],
    'value': [40, 20, 30, 10],
    'radius_value': [400, 500, 400, 400]
})

chart = alt.Chart(data).mark_arc().encode(
    theta=alt.Theta(field="value", type="quantitative", stack=True),
    radius=alt.Radius(field="radius_value", type="quantitative", scale=alt.Scale(zero=True)),
    color="category:N"
)

chart.show()

The stacking no longer applied correctly causing the wedge with a different radius to be rendered separately and on top of the other wedges.

In the compiled vega, the stack transform gains a groupby:["radius_value"] which if removed then renders as expected.

What would you like to happen instead?

I expected that by supplying the radius as a field I would be able to modify the radius without changing the stacking of the graph.

Which version of Altair are you using?

5.5.0

@nine9ths nine9ths added bug needs-triage Bug report needs maintainer response labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Bug report needs maintainer response
Projects
None yet
Development

No branches or pull requests

1 participant