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
[Coming soon] Ability to accept input from Charts, Tables, etc. #455
Comments
Eventually you will be building that kind of functionality (is my guess). Very much needed to provide awesome interactivity. :-) |
Another one: ability to get the time from an audio widget. See forum thread here. |
If you want to select rows in a table, you can use this somewhat inelegant workaround, which will scale up to about 1000 rows or so. 👍 |
Here is just my few cents. If we supported the ipywidgets then we would also get access to the awesome qgrid/ slickgrid. That grid is really great to read, sort and filter. And it's fast. But I guess the looks of it is not very Streamlit like. |
You can see plotly's new FigureWidget in action here and how it plays well with the ipywidgets and supports call backs. https://plot.ly/python/figurewidget/ |
That would be a great feature, since it might allow to support brushing & linking between charts in streamlit apps. For reference, dc.js is a cool JS chart framework that focuses on getting exactly this kind of interaction/dependency between multiple charts right (example). That kind of functionality would be awesome in streamlit. |
Esp. Tables as inputs or resp. changeable, like a spreadsheet, would allow using streamlit.io as a replacement for a lot of excel-file based solutions, which are floating around in the millions in cooperate settings. |
@torwag : I think this is a super valid use case. Can you please tell me a bit more about the setup you envision. Would you want only a single "spreadsheet" (i.e. table), or would you want graphs etc? Do you want widgets / sidebar? Also, what industry are you working in? Thanks! |
@treuille My vision would be to have all possibilities, like graphs, buttons, sliders etc. but also have editable tables, thus people can contribute data to it. Possibilities are endless. I am in an university setting, and here we would have both academic and administrative use for such a solution. E.g. staff and lecture dashboards to show all kind of information on a single page. But enable the user to make inputs where necessary. |
I would love also to have the output from a selection on a graph. |
Just a quick update: we're currently brainstorming a few other features that touch on this one, so it would be great to hear some more use cases from you all, to better inform our discussion. Even better if you provide a tiny toy example with some arbitrary API! For example: st.write("Pick a user to edit")
# In this example, st.Table (with capital T) returns an object with properties you can use.
# This is not something that exists today. Just one of the many possible APIs for this...
table = st.Table(users_table)
if table.selected_row is not None:
user = users_table[table.selected_row]
show_editor(user) |
But if the functionality at its core could be based on being able to subscribe to any event. That would be very powerfull. The core functionality could then be wrapped into a simpler api for tables, charts etc. With Dash you can add a callback to any kind of event. In Panel you can do reactive programming in Python using Streams. And here is an example of a Stream from the front end http://holoviews.org/reference/streams/bokeh/RangeXY.html. That concept is really powerfull but maybe too much for Streamlit? |
I'm interjecting as a hopeful user of streamlit, we're evaluating a transition from Bokeh which uses slick-grid as it's table implementation. If you do decide to introduce an editable datatable can we add ag-grid to the evaluation list? Slickgrid is not very attractive, has a number of bugs related to sortable grouped columns, and has odd editing behavior where cell state for drop-down columns isn't retained until you switch focus away from the cell. There are some working python bindings for ag-grid which may be a good starting point. |
Here is a an example use case from a user https://discuss.streamlit.io/t/plotly-click-events-in-streamlit/1419 |
@mstump : Thanks for putting |
Thanks for providing that context, @MarcSkovMadsen! My current though (happy to be convinced otherwise) is that @tvst's suggestion above would allow us to integrate this kind of table selection (or point selection, respectively) within Streamlit's event model. The main advantage of this approach is simpler state handling, since the user doesn't need to think about explicitly mutating program state. The main disadvantage is performance (for now). Are there are things I'm missing? |
Oh, and happy new year! 🎆 |
Just chiming in that the geospatial use case is pretty apparent: if one could take the st.Table's selections and then set an opacity/color on a scatter mark or polygon with those selections, that would be immediately useful for visualizing subsets of your geospatial data. Here's to hoping that the API feeds nicely into the emerging pydeck integration! |
Hey guys, my 2 cents: another use case you might consider in the industry is data annotation. I have a webapp made of Jupyter + ipywidgets + qgrid + voila that currently allows not only my stakeholders to navigate and explore the data but most importantly, they can annotate data. Also, I have a section to serve "low confident" predictions and downstream improve my models, i.e. active learning. Therefore, IMHO considering something like qgrid may add plenty of value to Streamlit (ps: that's why I am still using this stack instead of streamlit 😅) Recap, 2 great use case for qgrid are:
Hope it helps, cheers! |
Another use case for selection in tables: I'd like to use rows in a table to control what I graph elsewhere in my app (roughly what you'd get if you could embed an st.checkbox in each row of an st.table.) Forum post about it here |
Another tool that could make this feature request easier to implement would be to use d-tale: https://pypi.org/project/dtale/ It uses flask as a back-end and already integrates with jupyter so perhaps with some hacking it could take care of all interface elements with the dataframe inside streamlit? Just throwing ideas here. |
An amazing editable react table/spreadsheet widget is the following: https://blueprintjs.com/docs/#table/features.editing Also an example of an editable table in a streamlit like project is the following: https://mybinder.org/v2/gh/SimonBiggs/scriptedforms-examples/master?urlpath=scriptedforms/use/detailed-example.md (scroll down to the "table variables" heading) Mentioned these in the following issue, but I'm going to close that one, as here is likely the best place for that. |
There has been discussion of aggrid here and I use that in Jupyter Notebooks they are beautiful, and allow a wide range of functionality as well as fast. There is a package of python bindings to wrap it here: |
Keen to see this feature manifest |
Bike shedding: For # 1 what about |
Amazing stuff! Really looking forward to the release of the experimental version! |
So cool, thank you! |
Yup! CleanShot.2024-04-09.at.21.56.31.mp4 |
We want to keep it aligned with the |
I also would have liked something a little clearer like Thanks for all the work on this! very exciting |
This is amazing and exactly what we need. What are some rough timeframes for this bad boy to be released? |
The proposed solution is very laggy. It takes up to 1 second for the click to be processed. How many solutions are there by now? Do all streamlit-based solutions have this issue because of the rerun-architecture? If yes, then this is probably the sign that if you want a responsive app you should switch from streamlit+plotly to javascript+plotly. edit: I deployed the wheel file to the github codespace and running it from the github code space is actually not that laggy. But I have not figured out how to deploy it to the streamlit.app space that is connected to the github codespace. streamlit.app still uses the old/current streamlit and not the new wheel version. edit2: To clarify, after doing:
There are actually 3 ways to test it in a github codespace:
edit3: Now it also works in the side-browser for some reason. I have |
Probably mid May, you can follow for updates on #688! |
@allocater2 We have some documentation on how to commit changes from Codespaces and make them show up in your deployed app. In your case, you'd probably want to upload the wheel file to your repo directly and then install that as a local file via About reruns: Yes, that's the basic concept of Streamlit, it always reruns your app from top to bottom upon user interactions. In most cases, that shouldn't be too laggy, unless you're e.g. doing expensive computations. If your app feels slow, I'd recommend you to look at fragments (a way to rerun only part of your app) and caching (a way to cache expensive computations). |
Mid-May! Perfect timing for our publication - keep it up team! Can't wait 🙏 |
Thanks, that worked. I have this in the requirements.txt now:
We'll see how slow it is with the data I want to use. Thankfully it only has to run locally and not on the web. The web is just for collaboration. |
## Describe your changes Adds selection support to `st.plotly_chart` that can be used via: ```python selections = st.plotly_chart(fig, on_select="rerun", selection_mode=("box", "points")) ``` ## GitHub Issue Link (if applicable) - Related: #455 - Closes #5902 - Closes #8244 - Closes #8169 - Closes #7597 - Closes #6324 - Closes #8575 - Closes #8576 ## Testing Plan - Implemented e2e and unit tests. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Lukas Masuch <[email protected]> Co-authored-by: William Wei Huang <[email protected]>
Hi @allocater2, I can confirm with @jrieke, just because Streamlit "always reruns from the top" that doesn't have to equate to "slow". The "always rerun from the top" means that the execution model is simple to reason about (which is a huge plus), and with appropriate caching of the key load bearing items many steps do not need to rerun. In practice I have found that I have never hit an issue where Streamlit rerun speed has became a limiting factor in the applications I have built when using the appropriate caching approaches. |
I tried streamlit-1.32.2-py2.py3-none-any.whl and it doesn't appear to capture click events for plotly heatmaps. I tried both px.imshow and go.Heatmap - I'm guessing this is because click event =/= select event. |
@Glypican yep, the current implementation will only capture select events and no click events :( |
Does the new method work for "select" or "pick" events for a pydeck_chart? Or is there another method for pydeck_chart? |
@allocater2 with the |
## Describe your changes This PR adds row and column selection support to `st.dataframe`. It can be used like this: ```python selection = st.dataframe( df, on_select="rerun", selection_mode="single-row" ) ``` - [Demo App](https://dataframe-row-selections.streamlit.app/) https://github.com/streamlit/streamlit/assets/2852129/f3ff476a-0bd0-4b82-bc97-6bda3a3be98c ## GitHub Issue Link (if applicable) - Closes #688 - Closes #7134 - #455 - #8319 ## Testing Plan - Added unit tests - Added e2e tests (see #8634) ```[tasklist] ### e2e tests - [x] Single row/column selection - [x] Multi row/column selection - [x] Mixed selections - [x] Screenshot of a dataframe with multiple selections - [x] Clear selections via toolbar - [x] Clear selections via escape - [x] Select all rows in multi-row selection via top checkbox - [x] Optional: Test drag and drop selection - [x] Optional: Test shift selections - [x] Optional: Test selections in form - [x] Have some test cases work with session state and others with return value - [x] Add a test case validating that the callback gets called ``` --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Benjamin Räthlein <[email protected]>
Great. In the meantime I was trying dash+dash-deck and it seems they also never implemented click/selection events. The only map I have gotten to work so far is dash+leaflet with the "n_clicks" event. |
FWIW, I successfully used the |
We just merged row & column selections for selection = st.dataframe(df, on_select="rerun", selection_mode="single-row") Or for multi-row & column selections: selection = st.dataframe(df, on_select="rerun", selection_mode=("multi-row", "multi-column")) You can try it out in this demo. |
@allocater2 I created a feature request for adding selections to pydeck; please feel free to upvote and describe your use case there; that helps us a lot with prioritization! ❤️ |
#8302) ## Describe your changes Adds selection support to `st.altair_chart` and `st.vega_lite_chart` that can be used via: ```python selections = st.altair_chart(fig, on_select="rerun") ``` ## GitHub Issue Link (if applicable) - Closes: #455 - Closes: #2263 ## Testing Plan - Added unit tests - Added e2e tests --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Lukas Masuch <[email protected]> Co-authored-by: William Wei Huang <[email protected]> Co-authored-by: braethlein <[email protected]>
Hey all! We just merged selections for You can then activate selections via the new event_dict = st.plotly_chart(chart, on_select="rerun") Since we now support almost all interactivity features mentioned in the original issue, we decided to (finally!) close it. I created separate issues for a few additional events we want to expose in the future. Please upvote and comment on those, and feel free to open new feature requests for additional events we should support!
Thanks everyone for your feedback over the years! ❤️ |
What if every output element could also serve as an input widget?
Then you could do things like:
Related discussions:
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
The text was updated successfully, but these errors were encountered: