Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Nivo/Boxplot #31

Open
LaurinHerbsthofer opened this issue Nov 20, 2023 · 1 comment
Open

Support for Nivo/Boxplot #31

LaurinHerbsthofer opened this issue Nov 20, 2023 · 1 comment

Comments

@LaurinHerbsthofer
Copy link

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?

@LaurinHerbsthofer
Copy link
Author

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:

  1. I added BoxPlot: dynamic(() => import("@nivo/boxplot").then(m => m.ResponsiveBoxPlot), { loading: ElementsLoading, ssr: false }), to ./streamlit_elements/frontend/components/modules/charts/Nivo.tsx
  2. I added the "@nivo/boxplot": "^0.84.0" requirement to streamlit_elements/frontend/package.json
  3. I added __version__="0.1.0" to streamlit_elements/__init__.py to fix a problem with make
  4. make
  5. make build
  6. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant