-
Notifications
You must be signed in to change notification settings - Fork 795
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
Add Pie Chart #2148
Comments
Vega-Lite recently added pie chart support in version 4.9, but Altair has not yet been updated to support this release. The next version of Altair should make this possible. |
Looks like Vega-Lite added significant new features at the end of March, including enabling pie charts and marker rotation (arrows are now possible!). If one were interested in contributing to help update I've read the maintainer instructions and I can follow along, but I'm new to |
The big blocker in this case is updating the code generation tools to handle the new datum encoding. There are no docs because a new class of encoding has not been added since Altair was created. |
Thanks for the reply, I should have known it wouldn’t be trivial. Is there a path forward or is this one of those road blocks that ends up requiring a time consuming & paradigm shifting refactor? Also, maybe this thread is not the best place for tracking this discussion any more. Does this new encoding warrant its own issue? |
Roughly, the idea is this: we will need a and a Then these will have to be constructed as part of the loop further down in the file, which may not be straightforward depending on the vega-lite schema's conventions regarding how these definitions are named. |
I have some catching up to do if I’m going to be of any use in helping with this; I’ll need to better understand the Vega and VegaLite json schemas, and I’ll need more time with the code generation patterns to get my head around the arguments that are passed to the code templates. Thanks taking time to show me where to begin. |
hi, is pie chart now available in altair? |
No, Altair does not yet support Vega-Lite 4.9 features. |
Hi @jakevdp, thanks for maintaining/developing Altair, it's my go-to data visualisation library! Is there a roadmap for supporting newer versions of Vega-Lite? |
Not sure... the update is a bit complicated because Vega-Lite 4.9 added the |
I played around a bit, just to get a start of an understanding what this I got it to work a bit: import pandas as pd
import altair as alt
df = pd.DataFrame({'category': [1, 2, 3, 4, 5, 6], 'value': [4, 6, 10, 3, 7, 8]})
alt.Chart(df).mark_arc().encode(
theta=alt.Theta(field='value', type='quantitative'),
color=alt.Color(field='category', type='nominal')
) # this also works
alt.Chart(df).mark_arc().encode(
theta=alt.PositionFieldDefBase(field='value', type='quantitative'),
color=alt.PositionFieldDefBase(field='category', type='nominal')
)
# this creates an empty chart
alt.Chart(df).mark_arc().encode(
theta=alt.PositionDatumDefBase(datum='value', type='quantitative'),
color=alt.PositionDatumDefBase(datum='category', type='nominal')
) Now I also understand what you mean with:
Since you check for |
Is mark_arc supported by altair in the latest version? I am getting 'Chart object has no attribute mark_arc' |
No. This issue is still open |
Hi @mattijn I tried adapting your code for pie charts; thanks for sharing it! I think I got a few extra parts to work but also a few other things got broken. I shared it here (not sure if that's the best place or not): #2509 I'm very happy for any feedback! I am not experienced with open-source software development and in many cases am not sure what the etiquette and conventions are. |
Its great you are trying to push things forward @ChristopherDavisUCI! You have managed to dig deep in Altair internals and tried to give it another spin. |
Is there a workaround to use pie charts? Would loading a specific version of Vega Light work? import altair.vegalite.v4_8 as alt |
Pie charts are part of Altair 4.2 which is not yet released, but a release candidate is available:
You can see some examples here: https://altair-viz.github.io/gallery/index.html#circular-plots |
Closing since 4.2 is now released. |
I am building a dashboard with flask & altair and I feel the pie chart is missing.
I tried hacking it in following this spec.
But it was harder than expected.
Would be great if that was builtin
The text was updated successfully, but these errors were encountered: