arnaudmiribel / streamlit-extras

Discover, try, install and share Streamlit re-usable bits we call "extras"!
https://extras.streamlit.app
Apache License 2.0
754 stars 126 forks source link

Add chart container #80

Closed arnaudmiribel closed 1 year ago

arnaudmiribel commented 1 year ago

Fix #65

image
arnaudmiribel commented 1 year ago

First spent a ridiculous amount of time trying to automagically guess the chart's data by parsing the chart command source code. Only to realize that an explicit parameter worked well and wasn't that bad 😅 since you can even want to show a bigger dataset than just the chart's data.

arnaudmiribel commented 1 year ago

Um....this is amazing. We need to start using this everywhere. I love that you made it a context-manager, too!

One minor suggestion, not too important, but it might be nice to be able to export it as a few more type -- perhaps to_excel and to_parquet? to_excel is definitely not a big deal, but I imagine people might like it.

No big deal if you'd rather not.

No I agree, more exports would be great. If there's a tab for it, better fill it a little bit. Let me add parquet and excel. Two questions:

  1. Should I limit the df to e.g.df.head(1e6) rows?
  2. I could add a st.selectbox() to let the user chose the export format instead of having multiple buttons. Ah but afraid it reruns and screws the active tab again

I also enquired to somehow enable people to one-click create a Google Sheet (using gspread) with the data but ran into obvious concerns and difficulties around authentication. Workaround could be a button to get the data in the clipboard so that it's easily pastable in a sheets.new... I think I've seen that somewhere (the dataframe-copy-clipboard-button stuff). Ah yea, here at least

blackary commented 1 year ago

Um....this is amazing. We need to start using this everywhere. I love that you made it a context-manager, too! One minor suggestion, not too important, but it might be nice to be able to export it as a few more type -- perhaps to_excel and to_parquet? to_excel is definitely not a big deal, but I imagine people might like it. No big deal if you'd rather not.

No I agree, more exports would be great. If there's a tab for it, better fill it a little bit. Let me add parquet and excel. Two questions:

  1. Should I limit the df to e.g.df.head(1e6) rows?
  2. I could add a st.selectbox() to let the user chose the export format instead of having multiple buttons. Ah but afraid it reruns and screws the active tab again

I also enquired to somehow enable people to one-click create a Google Sheet (using gspread) with the data but ran into obvious concerns and difficulties around authentication. Workaround could be a button to get the data in the clipboard so that it's easily pastable in a sheets.new... I think I've seen that somewhere (the dataframe-copy-clipboard-button stuff). Ah yea, here at least

I was actually thinking of just making it programmable, like adding an extra argument to the container about what kind of export to support. But, since this is mostly for making the user's life easier, making it user-selectable sounds good. I don't think having 3 buttons is a big deal, and we could allow the developer to specify which buttons are allowed.

1e6 row limit seems reasonable.

We could use this https://streamlitextras.readthedocs.io/en/latest/api/streamlitextras.html#streamlitextras.helpers.CustomHTML.download_link to make them download links that don't rerun the page if we wanted.