Gotta say, working with vega lite in streamlit has been the most frustrating part of using streamlit. I feel like the json dict you pass in should be abstracted away.
Right now, there’s line_chart which does everything for you, but has no customization, and vega_lite_chart and altair_chart, which do nothing for you but are fully customizable, and there’s nothing in between. I would expect I could just copy the spec from the line_chart and get the same vega lite chart, but that doesn’t happen, so I’m stuck in purgatory trying to make my vega chart work from scratch.
Alright, I did not realize that altair is actually a python API for vega-lite. My first impression was that altair and vega-lite were related in the way that tensorflow and keras are related: separate packages, one uses the other. Everything I want to do will probably be easier if try using altair, but I’m still interested in a default altair chart tutorial.
You’ll definitely be better using Altair, it mirrors all of the vega-lite spec and gives you autocompletion on the spec
Streamlit does not interact with your vegalite/altair spec and does not provide a default, it just passes the spec directly to the vegalite parser so, so yeah you have to actually learn the language which takes some time, trial and error . I think Streamlit does not provide a default because merging your Altair spec with Streamlit’s default option would mess things up given the sheer number of available options you would have to override.
For me the best way to learn Altair and its spec is to understand each example of the Altair gallery and its vega-lige counterpart, that way you will understand how Altair maps back to vega-lite and slowly be able to express your plot. I did not find a tutorial that can speed you through Altair, this is something you’ll have to dig into but honestly it’s worth it.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.