Streamlit stacked chart forcing alphabetical order

I am looking to create a streamlit stacked chart which keeps the order of my dataframe but streamlit is forcing alphabetical order.

Using this code - I want “a” to always be in the middle but streamlit re-arranges this by always putting “b” in the middle. What am I missing?
chart_data = pd.DataFrame(
np.random.randn(20, 3),
columns=[‘c’, ‘a’, ‘b’])

st.bar_chart(chart_data)

Hi @Khuthadzo_Masindi, welcome to the Streamlit community!

In this case, it’s not Streamlit itself that’s forcing anything, as st.bar_chart is a convenience function around the Altair visualization library (via st.altair_chart). To directly specify column order, you can switch to using the Altair syntax directly, using order argument:

https://altair-viz.github.io/gallery/stacked_bar_chart_sorted_segments.html

Best,
Randy