Support for Nivo/Boxplot
Opened this issue · 1 comments
I'm using streamlit-gallery (https://github.com/okld/streamlit-gallery) based on streamlit-elements and I successfully recreated the nivo radar and pie chart plots as shown in the draggable UI demo (which is fantastic) and I also expanded the functionality to include bump, areabump and chord plots.
However, I cannot get nivo/boxplot to work, presumably because boxplots were added rather recently to nivo (plouc/nivo#849 (comment)).
What are necessary steps that I need to take to make nivo/boxplot useable in the draggable UI, just like radar and pie charts?
I got it working by modifying the streamlit-elements source code and building it manually using make, then integrating the built code into my streamlit-gallery python environment. If someone else needs to do this, here is what I did:
- I added
BoxPlot: dynamic(() => import("@nivo/boxplot").then(m => m.ResponsiveBoxPlot), { loading: ElementsLoading, ssr: false }),
to ./streamlit_elements/frontend/components/modules/charts/Nivo.tsx - I added the
"@nivo/boxplot": "^0.84.0"
requirement tostreamlit_elements/frontend/package.json
- I added
__version__="0.1.0"
tostreamlit_elements/__init__.py
to fix a problem with make - make
- make build
- I copied the newly built
streamlit_elements/streamlit_elements
folder to my streamlit-gallery python environment
Now nivo boxplots works in streamlit-gallery just like all other plots by simply making a copy of streamlit_gallery/components/elements/dashbaord/bar.py
to */boxplot.py
and replacing the line nivo.Bar()
with nivo.BoxPlot()
. How to work with the associated demo data can be found here: https://nivo.rocks/boxplot/
However, it would be nice if the streamlit-elements repo could be updated to include these changes. I will make a pull request for that soon.