Altair pie chart error

I am getting the following error when trying to create an Altair pie chart. I have Altair bar charts, line charts and stacked bar charts all working properly. However, as soon as I try to create a pie chart I run into a fatal error. To eliminate any issues with my typing and incorrect encodings etc. I copied the example from the Altair documentation (Pie Chart — Altair 4.2.0 documentation). This also fails. I am not sure what I am doing incorrectly.

Hi @Gaurav_Kimothi, welcome to the Streamlit community!

It would be helpful to post the code that doesn’t work, that way someone can take a look and suggest what the fix might be.

Best,
Randy

Here it is. This is the example from the Altair documentation. I have no issues with bar chart (mark_bar) and line chart (mark_line). I am only running into this issue when trying to create a pie chart. Appreciate any help.

source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]})

fig_category_percent=alt.Chart(source).mark_arc().encode(
    theta=alt.Theta(field="value", type="quantitative"),
    color=alt.Color(field="category", type="nominal"))
st.altair_chart(fig_category_percent)

Make sure you have Altair 4.2 installed, which is when the mark_arc method was added:

https://altair-viz.github.io/releases/changes.html#version-4-2-0-released-dec-29-2021

Upgrading my local instance from Altair 4.1 to 4.2 with your code snippet displays a pie chart for me

Best,
Randy

Yes, that was it. Thank you!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.