-
Notifications
You must be signed in to change notification settings - Fork 4k
Set use_container_width=True by default for charts
#10064
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
Conversation
use_container_width=True by defaultuse_container_width=True by default for more elements
use_container_width=True by default for more elementsuse_container_width=True by default for more elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes related to the chart command look good 👍
For dataframe, it looks a bit off sometimes if the table has very few columns.
Maybe we could also introduce use_container_width = None to auto-activate if > x visible columns. Or find a way to better auto-size range index columns. Instead of using grow for those columns, we could probably calculate a perfect size based on the range index metadata. Or we only apply grow to all non-pinnend columns, this would probably make it look a bit nicer. E.g.:
vs
Another aspect to think through is how we want this to behave in Notebooks output. Maybe we want to set use_container_width=False for dataframe in st.write?
To speed up merging this, it might make sense to split out the changes for dataframe/data_editor into a dedicated PR.
|
Yeah good comment. I removed the dataframe changes from this PR for now, can you aprove @lukasmasuch?
I think that's the solution I'd prefer, can you give me a pointer where I'd change that? Then I can play around with it.
I think it's nicer if |
use_container_width=True by default for more elementsuse_container_width=True by default for charts
lukasmasuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Probably as simple as changing: streamlit/frontend/lib/src/components/widgets/DataFrame/columns/utils.ts Lines 240 to 242 in e73d401
to ...(column.isStretched &&
!column.isPinned && {
grow: 1,
}), |
## Describe your changes This PR makes the following commands have `use_container_width=True` by default: - ~~st.dataframe~~ -> Decided to do the dataframe changes in a separate PR, see discussion below. - ~~st.data_editor~~ - st.bokeh_chart - st.plotly_chart - st.pydeck_chart The following two commands get `use_container_width=None` by default, which is internally set to `True` for most cases except for some multi-view charts that don't work well with `use_container_width=True` (see streamlit#9091): - st.altair_chart - st.vega_lite_chart And we're keeping the default of `use_container_width=False` for the following commands: - st.image - st.button - st.graphviz_chart ## GitHub Issue Link (if applicable) ## Testing Plan Just updated existing snapshots and one unit test. ~~For a few tests (e.g. that click on a specific location), I simply set `use_container_width=False` to keep the current behavior. For others, I just went with the new default behavior and updated the snapshots. Note that this updates a ton of snapshots (especially for dataframes). If we don't want that, we can also set `use_container_width=False` for all of these tests. But I think it makes sense to just use the default value as much as possible.~~ --- **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: Johannes Rieke <[email protected]>
Describe your changes
This PR makes the following commands have
use_container_width=Trueby default:st.dataframe-> Decided to do the dataframe changes in a separate PR, see discussion below.st.data_editorThe following two commands get
use_container_width=Noneby default, which is internally set toTruefor most cases except for some multi-view charts that don't work well withuse_container_width=True(see #9091):And we're keeping the default of
use_container_width=Falsefor the following commands:GitHub Issue Link (if applicable)
Testing Plan
Just updated existing snapshots and one unit test.
For a few tests (e.g. that click on a specific location), I simply setuse_container_width=Falseto keep the current behavior. For others, I just went with the new default behavior and updated the snapshots. Note that this updates a ton of snapshots (especially for dataframes). If we don't want that, we can also setuse_container_width=Falsefor all of these tests. But I think it makes sense to just use the default value as much as possible.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.