Using ordered categorical columns with built-in charts causes an error #7776
Labels
feature:builtin-charts
priority:P3
status:confirmed
Bug has been confirmed by the Streamlit team
type:bug
Something isn't working
Checklist
Summary
The usage of an ordered categorical column (
pd.Categorical(..., ordered=True)
) with the built-in charts results in aSchemaValidationError
. The underlying issue is that ordered categorical columns are treated slightly differently within theinfer_vegalite_type
by returning a tuple:streamlit/lib/streamlit/type_util.py
Lines 1078 to 1079 in 39a21c3
To solve this, we would need to split up this tuple into
type
andsort
within our built-in chart logic similar to how it is done here in Altair:https://github.com/altair-viz/altair/blob/e1bb266f91bd743c815fce9908d03d3bb1ad13fc/altair/utils/core.py#L603-L605
Reproducible Code Example
Steps To Reproduce
Running the app will result in an error.
Expected Behavior
Show the chart with the x-axis using the categories ordered by "c", "b", "a".
Current Behavior
Exception:
Is this a regression?
Debug info
Additional Information
No response
The text was updated successfully, but these errors were encountered: