[Fix] Improve fallback behavior for `chartSequentialColors`
Describe your changes
Previously, chartSequentialColors had to be passed exactly 10 valid colors to be applied since sequential colors are used to create a continuous gradient (see streamlit_plotly_theme.py).
This PR updates the behavior so passing less than 10 or greater than 10 colors still works, but as follows:
- If
chartSequentialColorsreceives less than 10 colors, it repeats the colors from the beginning until it has 10 color values - If
chartSequentialColorsreceives more than 10 colors, only the first 10 values are used
Testing Plan
- Unit Tests (JS and/or Python): ✅ Added
- E2E Tests: ✅ Added
- Manual Testing: ✅
:tada: Snyk checks have passed. No issues have been found so far.
:white_check_mark: security/snyk check is complete. No issues have been found. (View Details)
:white_check_mark: license/snyk check is complete. No issues have been found. (View Details)
✅ PR preview is ready!
| Name | Link |
|---|---|
| 📦 Wheel file | https://core-previews.s3-us-west-2.amazonaws.com/pr-12224/streamlit-1.48.1-py3-none-any.whl |
| 🕹️ Preview app | pr-12224.streamlit.app (☁️ Deploy here if not accessible) |
If chartSequentialColors receives less than 10 colors, it repeats the colors from the beginning until it has 10 color values
Hm I'm not sure if this makes so much sense here given that these colors should be sequential? E.g. if I pass in 5 colors from blue to white, it would be pretty awkward (and also potentially hard to debug) if my values go from blue -> white -> blue -> white. Or am I understanding something wrong here?
Maybe we should rather raise an exception or interpolate between the colors?
Edit: yeah looking at the test screenshots I think it is pretty confusing that e.g. 0 and 4 have the same color. I don't think that's something you'd ever want in a sequential chart.