streamlit-nightly 1.34.1.dev20240521__py2.py3-none-any.whl → 1.35.1.dev20240523__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. streamlit/commands/logo.py +61 -13
  2. streamlit/components/types/base_custom_component.py +15 -2
  3. streamlit/components/v1/custom_component.py +13 -1
  4. streamlit/config.py +8 -0
  5. streamlit/elements/arrow.py +141 -46
  6. streamlit/elements/bokeh_chart.py +9 -5
  7. streamlit/elements/deck_gl_json_chart.py +6 -0
  8. streamlit/elements/dialog_decorator.py +3 -9
  9. streamlit/elements/graphviz_chart.py +6 -2
  10. streamlit/elements/lib/built_in_chart_utils.py +4 -4
  11. streamlit/elements/map.py +6 -2
  12. streamlit/elements/plotly_chart.py +158 -39
  13. streamlit/elements/pyplot.py +9 -4
  14. streamlit/elements/vega_charts.py +327 -84
  15. streamlit/elements/widgets/data_editor.py +17 -8
  16. streamlit/runtime/app_session.py +2 -1
  17. streamlit/runtime/state/common.py +1 -1
  18. streamlit/static/asset-manifest.json +3 -3
  19. streamlit/static/index.html +1 -1
  20. streamlit/static/static/js/{8148.f80eec24.chunk.js → 8148.a17a918e.chunk.js} +1 -1
  21. streamlit/static/static/js/{main.9db3e91c.js → main.7e42f54d.js} +2 -2
  22. streamlit/web/server/browser_websocket_handler.py +8 -4
  23. {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/METADATA +1 -1
  24. {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/RECORD +29 -29
  25. /streamlit/static/static/js/{main.9db3e91c.js.LICENSE.txt → main.7e42f54d.js.LICENSE.txt} +0 -0
  26. {streamlit_nightly-1.34.1.dev20240521.data → streamlit_nightly-1.35.1.dev20240523.data}/scripts/streamlit.cmd +0 -0
  27. {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/WHEEL +0 -0
  28. {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/entry_points.txt +0 -0
  29. {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/top_level.txt +0 -0
@@ -41,25 +41,73 @@ def logo(
41
41
  icon_image: AtomicImage | None = None,
42
42
  ) -> None:
43
43
  """
44
- Renders logos in the main and sidebar sections of the page
44
+ Renders a logo in the upper-left corner of your app and its sidebar.
45
+
46
+ If ``st.logo`` is called multiple times within a page, Streamlit will
47
+ render the image passed in the last call. For the most consistent results,
48
+ call ``st.logo`` early in your page script and choose an image that works
49
+ well in both light and dark mode. Avoid empty margins around your image.
50
+
51
+ If your logo does not work well for both light and dark mode, consider
52
+ setting the theme and hiding the settings menu from users with the
53
+ `configuration option <https://docs.streamlit.io/develop/api-reference/configuration/config.toml>`_
54
+ ``client.toolbarMode="minimal"``.
45
55
 
46
56
  Parameters
47
57
  ----------
48
- image: Anything supported by st.image or str
49
- The app logo to be displayed in the top left corner of the sidebar of your app
50
- (as well as the main section if icon_image param is not provided).
58
+ image: Anything supported by st.image
59
+ The image to display in the upper-left corner of your app and its
60
+ sidebar. If ``icon_image`` is also provided, then Streamlit will only
61
+ display ``image`` in the sidebar.
62
+
63
+ Streamlit scales the image to a height of 24 pixels and a maximum
64
+ width of 240 pixels. Use images with an aspect ratio of 10:1 or less to
65
+ avoid distortion.
51
66
  link : str or None
52
- The external url to be opened when a user clicks on the logo (must start with
53
- http:// or https://)
54
- icon_image: numpy.ndarray, BytesIO, str, or None
55
- The app logo to be displayed in the top left corner of the main section of your
56
- app.
57
-
58
- Example
59
- -------
67
+ The external URL to open when a user clicks on the logo. The URL must
68
+ start with "\\http://" or "\\https://". If ``link`` is ``None`` (default),
69
+ the logo will not include a hyperlink.
70
+ icon_image: Anything supported by st.image or None
71
+ An alternate image to replace ``image`` in the upper-left corner of the
72
+ app's main body. If ``icon_image`` is ``None`` (default), Streamlit
73
+ will render ``image`` in the upper-left corner of the app and its
74
+ sidebar. Otherwise, Streamlit will render ``icon_image`` in the
75
+ upper-left corner of the app and ``image`` in the upper-left corner
76
+ of the sidebar.
77
+
78
+ Streamlit scales the image to a height of 24 pixels and a maximum
79
+ width of 240 pixels. Use images with an aspect ratio of 10:1 or less to
80
+ avoid distortion.
81
+
82
+ Examples
83
+ --------
84
+ A common design practice is to use a wider logo in the sidebar, and a
85
+ smaller, icon-styled logo in your app's main body.
86
+
60
87
  >>> import streamlit as st
61
88
  >>>
62
- >>> st.logo(streamlit_full, link="https://streamlit.io/gallery", icon_image=streamlit_small)
89
+ >>> st.logo(LOGO_URL_LARGE, link="https://streamlit.io/gallery", icon_image=LOGO_URL_SMALL)
90
+
91
+ Try switching logos around in the following example:
92
+
93
+ >>> import streamlit as st
94
+ >>>
95
+ >>> HORIZONTAL_RED = "images/horizontal_red.png"
96
+ >>> ICON_RED = "images/icon_red.png"
97
+ >>> HORIZONTAL_BLUE = "images/horizontal_blue.png"
98
+ >>> ICON_BLUE = "images/icon_blue.png"
99
+ >>>
100
+ >>> options = [HORIZONTAL_RED, ICON_RED, HORIZONTAL_BLUE, ICON_BLUE]
101
+ >>> sidebar_logo = st.selectbox("Sidebar logo", options, 0)
102
+ >>> main_body_logo = st.selectbox("Main body logo", options, 1)
103
+ >>>
104
+ >>> st.logo(sidebar_logo, icon_image=main_body_logo)
105
+ >>> st.sidebar.markdown("Hi!")
106
+
107
+ .. output::
108
+ https://doc-logo.streamlit.app/
109
+ height: 300px
110
+
63
111
  """
64
112
 
65
113
  ctx = get_script_run_ctx()
@@ -16,11 +16,14 @@ from __future__ import annotations
16
16
 
17
17
  import os
18
18
  from abc import ABC, abstractmethod
19
- from typing import Any
19
+ from typing import TYPE_CHECKING, Any
20
20
 
21
21
  from streamlit import util
22
22
  from streamlit.errors import StreamlitAPIException
23
23
 
24
+ if TYPE_CHECKING:
25
+ from streamlit.runtime.state.common import WidgetCallback
26
+
24
27
 
25
28
  class MarshallComponentException(StreamlitAPIException):
26
29
  """Class for exceptions generated during custom component marshalling."""
@@ -56,10 +59,17 @@ class BaseCustomComponent(ABC):
56
59
  *args,
57
60
  default: Any = None,
58
61
  key: str | None = None,
62
+ on_change: WidgetCallback | None = None,
59
63
  **kwargs,
60
64
  ) -> Any:
61
65
  """An alias for create_instance."""
62
- return self.create_instance(*args, default=default, key=key, **kwargs)
66
+ return self.create_instance(
67
+ *args,
68
+ default=default,
69
+ key=key,
70
+ on_change=on_change,
71
+ **kwargs,
72
+ )
63
73
 
64
74
  @property
65
75
  def abspath(self) -> str | None:
@@ -102,6 +112,7 @@ class BaseCustomComponent(ABC):
102
112
  *args,
103
113
  default: Any = None,
104
114
  key: str | None = None,
115
+ on_change: WidgetCallback | None = None,
105
116
  **kwargs,
106
117
  ) -> Any:
107
118
  """Create a new instance of the component.
@@ -118,6 +129,8 @@ class BaseCustomComponent(ABC):
118
129
  key: str or None
119
130
  If not None, this is the user key we use to generate the
120
131
  component's "widget ID".
132
+ on_change: WidgetCallback or None
133
+ An optional callback invoked when the widget's value changes. No arguments are passed to it.
121
134
  **kwargs
122
135
  Keyword args to pass to the component.
123
136
 
@@ -33,6 +33,7 @@ from streamlit.type_util import to_bytes
33
33
 
34
34
  if TYPE_CHECKING:
35
35
  from streamlit.delta_generator import DeltaGenerator
36
+ from streamlit.runtime.state.common import WidgetCallback
36
37
 
37
38
 
38
39
  class MarshallComponentException(StreamlitAPIException):
@@ -49,10 +50,17 @@ class CustomComponent(BaseCustomComponent):
49
50
  *args,
50
51
  default: Any = None,
51
52
  key: str | None = None,
53
+ on_change: WidgetCallback | None = None,
52
54
  **kwargs,
53
55
  ) -> Any:
54
56
  """An alias for create_instance."""
55
- return self.create_instance(*args, default=default, key=key, **kwargs)
57
+ return self.create_instance(
58
+ *args,
59
+ default=default,
60
+ key=key,
61
+ on_change=on_change,
62
+ **kwargs,
63
+ )
56
64
 
57
65
  @gather_metrics("create_instance")
58
66
  def create_instance(
@@ -60,6 +68,7 @@ class CustomComponent(BaseCustomComponent):
60
68
  *args,
61
69
  default: Any = None,
62
70
  key: str | None = None,
71
+ on_change: WidgetCallback | None = None,
63
72
  **kwargs,
64
73
  ) -> Any:
65
74
  """Create a new instance of the component.
@@ -76,6 +85,8 @@ class CustomComponent(BaseCustomComponent):
76
85
  key: str or None
77
86
  If not None, this is the user key we use to generate the
78
87
  component's "widget ID".
88
+ on_change: WidgetCallback or None
89
+ An optional callback invoked when the widget's value changes. No arguments are passed to it.
79
90
  **kwargs
80
91
  Keyword args to pass to the component.
81
92
 
@@ -195,6 +206,7 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
195
206
  deserializer=deserialize_component,
196
207
  serializer=lambda x: x,
197
208
  ctx=ctx,
209
+ on_change_handler=on_change,
198
210
  )
199
211
  widget_value = component_state.value
200
212
 
streamlit/config.py CHANGED
@@ -342,6 +342,14 @@ _create_option(
342
342
  replaced_by="logger.level",
343
343
  )
344
344
 
345
+ _create_option(
346
+ "global.e2eTest",
347
+ description="Are we in an e2e (playwright) test? Set automatically when our e2e tests are running.",
348
+ visibility="hidden",
349
+ default_val=False,
350
+ type_=bool,
351
+ )
352
+
345
353
  _create_option(
346
354
  "global.unitTest",
347
355
  description="Are we in a unit test?",
@@ -85,14 +85,49 @@ _SELECTION_MODES: Final[set[SelectionMode]] = {
85
85
 
86
86
  class DataframeSelectionState(TypedDict, total=False):
87
87
  """
88
- A dictionary representing the current selection state of the dataframe.
88
+ The schema for the dataframe selection state.
89
+
90
+ The selection state is stored in a dictionary-like object that suports both
91
+ key and attribute notation. Selection states cannot be programmatically
92
+ changed or set through Session State.
89
93
 
90
94
  Attributes
91
95
  ----------
92
- rows
93
- The selected rows (numerical indices).
94
- columns
95
- The selected columns (column names).
96
+ rows : list[int]
97
+ The selected rows, identified by their positional index. The positional
98
+ indices match the original dataframe, even if the user sorts the
99
+ dataframe in their browser.
100
+ columns : list[str]
101
+ The selected columns, identified by their names.
102
+
103
+ Example
104
+ -------
105
+ The following example has multi-row and multi-column selections enabled.
106
+ Try selecting some rows. To select multiple columns, hold ``Ctrl`` while
107
+ selecting columns. Hold ``Shift`` to select a range of columns.
108
+
109
+ >>> import streamlit as st
110
+ >>> import pandas as pd
111
+ >>> import numpy as np
112
+ >>>
113
+ >>> if "df" not in st.session_state:
114
+ >>> st.session_state.df = pd.DataFrame(
115
+ ... np.random.randn(12, 5), columns=["a", "b", "c", "d", "e"]
116
+ ... )
117
+ >>>
118
+ >>> event = st.dataframe(
119
+ ... st.session_state.df,
120
+ ... key="data",
121
+ ... on_select="rerun",
122
+ ... selection_mode=["multi-row", "multi-column"],
123
+ ... )
124
+ >>>
125
+ >>> event.selection
126
+
127
+ .. output::
128
+ https://doc-dataframe-events-selection-state.streamlit.app
129
+ height: 600px
130
+
96
131
  """
97
132
 
98
133
  rows: list[int]
@@ -101,12 +136,19 @@ class DataframeSelectionState(TypedDict, total=False):
101
136
 
102
137
  class DataframeState(TypedDict, total=False):
103
138
  """
104
- A dictionary representing the current state of the dataframe.
139
+ The schema for the dataframe event state.
140
+
141
+ The event state is stored in a dictionary-like object that suports both
142
+ key and attribute notation. Event states cannot be programmatically
143
+ changed or set through Session State.
144
+
145
+ Only selection events are supported at this time.
105
146
 
106
147
  Attributes
107
148
  ----------
108
149
  selection : DataframeSelectionState
109
- The state of the `on_select` event.
150
+ The state of the ``on_select`` event.
151
+
110
152
  """
111
153
 
112
154
  selection: DataframeSelectionState
@@ -234,75 +276,128 @@ class ArrowMixin:
234
276
 
235
277
  Parameters
236
278
  ----------
237
- data : pandas.DataFrame, pandas.Series, pandas.Styler, pandas.Index, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table, Iterable, dict, or None
279
+ data : pandas.DataFrame, pandas.Series, pandas.Styler, pandas.Index, \
280
+ pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
281
+ snowflake.snowpark.table.Table, Iterable, dict, or None
238
282
  The data to display.
239
283
 
240
- If 'data' is a pandas.Styler, it will be used to style its
241
- underlying DataFrame. Streamlit supports custom cell
284
+ If ``data`` is a ``pandas.Styler``, it will be used to style its
285
+ underlying ``pandas.DataFrame``. Streamlit supports custom cell
242
286
  values and colors. It does not support some of the more exotic
243
287
  pandas styling features, like bar charts, hovering, and captions.
244
288
 
245
289
  width : int or None
246
- Desired width of the dataframe expressed in pixels. If None, the width
247
- will be automatically calculated based on the column content.
290
+ Desired width of the dataframe expressed in pixels. If ``width`` is
291
+ ``None`` (default), Streamlit sets the dataframe width to fit its
292
+ contents up to the width of the parent container. If ``width`` is
293
+ greater than the width of the parent container, Streamlit sets the
294
+ dataframe width to match the width of the parent container.
248
295
 
249
296
  height : int or None
250
- Desired height of the dataframe expressed in pixels. If None, a
251
- default height is used.
297
+ Desired height of the dataframe expressed in pixels. If ``height``
298
+ is ``None`` (default), Streamlit sets the height to show at most
299
+ ten rows. Vertical scrolling within the dataframe element is
300
+ enabled when the height does not accomodate all rows.
252
301
 
253
302
  use_container_width : bool
254
- If True, set the dataframe width to the width of the parent container.
255
- This takes precedence over the width argument.
303
+ Whether to override ``width`` with the width of the parent
304
+ container. If ``use_container_width`` is ``False`` (default),
305
+ Streamlit sets the dataframe's width according to ``width``. If
306
+ ``use_container_width`` is ``True``, Streamlit sets the width of
307
+ the dataframe to match the width of the parent container.
256
308
 
257
309
  hide_index : bool or None
258
- Whether to hide the index column(s). If None (default), the visibility of
259
- index columns is automatically determined based on the data.
310
+ Whether to hide the index column(s). If ``hide_index`` is ``None``
311
+ (default), the visibility of index columns is automatically
312
+ determined based on the data.
260
313
 
261
314
  column_order : Iterable of str or None
262
- Specifies the display order of columns. This also affects which columns are
263
- visible. For example, ``column_order=("col2", "col1")`` will display 'col2'
264
- first, followed by 'col1', and will hide all other non-index columns. If
265
- None (default), the order is inherited from the original data structure.
315
+ The ordered list of columns to display. If ``column_order`` is
316
+ ``None`` (default), Streamlit displays all columns in the order
317
+ inherited from the underlying data structure. If ``column_order``
318
+ is a list, the indicated columns will display in the order they
319
+ appear within the list. Columns may be omitted or repeated within
320
+ the list.
321
+
322
+ For example, ``column_order=("col2", "col1")`` will display
323
+ ``"col2"`` first, followed by ``"col1"``, and will hide all other
324
+ non-index columns.
266
325
 
267
326
  column_config : dict or None
268
- Configures how columns are displayed, e.g. their title, visibility, type, or
269
- format. This needs to be a dictionary where each key is a column name and
270
- the value is one of:
327
+ Configuration to customize how columns display. If ``column_config``
328
+ is ``None`` (default), columns are styled based on the underlying
329
+ data type of each column.
330
+
331
+ Column configuration can modify column names, visibility, type,
332
+ width, or format, among other things. ``column_config`` must be a
333
+ dictionary where each key is a column name and the associated value
334
+ is one of the following:
271
335
 
272
- * ``None`` to hide the column.
336
+ * ``None``: Streamlit hides the column.
273
337
 
274
- * A string to set the display label of the column.
338
+ * A string: Streamlit changes the display label of the column to
339
+ the given string.
275
340
 
276
- * One of the column types defined under ``st.column_config``, e.g.
277
- ``st.column_config.NumberColumn("Dollar values”, format=”$ %d")`` to show
278
- a column as dollar amounts. See more info on the available column types
279
- and config options `here <https://docs.streamlit.io/library/api-reference/data/st.column_config>`_.
341
+ * A column type within ``st.column_config``: Streamlit applies the
342
+ defined configuration to the column. For example, use
343
+ ``st.column_config.NumberColumn("Dollar values”, format=”$ %d")``
344
+ to change the displayed name of the column to "Dollar values"
345
+ and add a "$" prefix in each cell. For more info on the
346
+ available column types and config options, see
347
+ `Column configuration <https://docs.streamlit.io/library/api-reference/data/st.column_config>`_.
280
348
 
281
349
  To configure the index column(s), use ``_index`` as the column name.
282
350
 
283
351
  key : str
284
- An optional string to use as the unique key for this element when used in combination
285
- with ```on_select```. If this is omitted, a key will be generated for the widget based
286
- on its content. Multiple widgets of the same type may not share the same key.
352
+ An optional string to use for giving this element a stable
353
+ identity. If ``key`` is ``None`` (default), this element's identity
354
+ will be determined based on the values of the other parameters.
355
+
356
+ Additionally, if selections are activated and ``key`` is provided,
357
+ Streamlit will register the key in Session State to store the
358
+ selection state. The selection state is read-only.
287
359
 
288
360
  on_select : "ignore" or "rerun" or callable
289
- Controls the behavior in response to selection events on the table. Can be one of:
361
+ How the dataframe should respond to user selection events. This
362
+ controls whether or not the dataframe behaves like an input widget.
363
+ ``on_select`` can be one of the following:
364
+
365
+ - ``"ignore"`` (default): Streamlit will not react to any selection
366
+ events in the dataframe. The dataframe will not behave like an
367
+ input widget.
368
+
369
+ - ``"rerun"``: Streamlit will rerun the app when the user selects
370
+ rows or columns in the dataframe. In this case, ``st.dataframe``
371
+ will return the selection data as a dictionary.
290
372
 
291
- - "ignore" (default): Streamlit will not react to any selection events in the chart.
292
- - "rerun": Streamlit will rerun the app when the user selects rows or columns in the table.
293
- In this case, ```st.dataframe``` will return the selection data as a dictionary.
294
- - callable: If a callable is provided, Streamlit will rerun and execute the callable as a
295
- callback function before the rest of the app. The selection data can be retrieved through
296
- session state by setting the key parameter.
373
+ - A ``callable``: Streamlit will rerun the app and execute the
374
+ ``callable`` as a callback function before the rest of the app.
375
+ In this case, ``st.dataframe`` will return the selection data
376
+ as a dictionary.
297
377
 
298
- selection_mode : "single-row", "multi-row", single-column", "multi-column", or an iterable of these
299
- The selection mode of the table. Can be one of:
378
+ selection_mode : "single-row", "multi-row", single-column", \
379
+ "multi-column", or Iterable of these
380
+ The types of selections Streamlit should allow. This can be one of
381
+ the following:
300
382
 
301
383
  - "multi-row" (default): Multiple rows can be selected at a time.
302
384
  - "single-row": Only one row can be selected at a time.
303
385
  - "multi-column": Multiple columns can be selected at a time.
304
386
  - "single-column": Only one column can be selected at a time.
305
- - An iterable of the above options: The table will allow selection based on the modes specified.
387
+ - An ``Iterable`` of the above options: The table will allow
388
+ selection based on the modes specified.
389
+
390
+ When column selections are enabled, column sorting is disabled.
391
+
392
+ Returns
393
+ -------
394
+ element or dict
395
+ If ``on_select`` is ``"ignore"`` (default), this method returns an
396
+ internal placeholder for the dataframe element that can be used
397
+ with the ``.add_rows()`` method. Otherwise, this method returns a
398
+ dictionary-like object that supports both key and attribute
399
+ notation. The attributes are described by the ``DataframeState``
400
+ dictionary schema.
306
401
 
307
402
  Examples
308
403
  --------
@@ -316,7 +411,7 @@ class ArrowMixin:
316
411
 
317
412
  .. output::
318
413
  https://doc-dataframe.streamlit.app/
319
- height: 410px
414
+ height: 500px
320
415
 
321
416
  You can also pass a Pandas Styler object to change the style of
322
417
  the rendered DataFrame:
@@ -331,7 +426,7 @@ class ArrowMixin:
331
426
 
332
427
  .. output::
333
428
  https://doc-dataframe1.streamlit.app/
334
- height: 410px
429
+ height: 500px
335
430
 
336
431
  Or you can customize the dataframe via ``column_config``, ``hide_index``, or ``column_order``:
337
432
 
@@ -43,11 +43,11 @@ class BokehMixin:
43
43
  """Display an interactive Bokeh chart.
44
44
 
45
45
  Bokeh is a charting library for Python. The arguments to this function
46
- closely follow the ones for Bokeh's `show` function. You can find
46
+ closely follow the ones for Bokeh's ``show`` function. You can find
47
47
  more about Bokeh at https://bokeh.pydata.org.
48
48
 
49
- To show Bokeh charts in Streamlit, call `st.bokeh_chart`
50
- wherever you would call Bokeh's `show`.
49
+ To show Bokeh charts in Streamlit, call ``st.bokeh_chart``
50
+ wherever you would call Bokeh's ``show``.
51
51
 
52
52
  Parameters
53
53
  ----------
@@ -55,8 +55,12 @@ class BokehMixin:
55
55
  A Bokeh figure to plot.
56
56
 
57
57
  use_container_width : bool
58
- If True, set the chart width to the column width. This takes
59
- precedence over Bokeh's native `width` value.
58
+ Whether to override the figure's native width with the width of
59
+ the parent container. If ``use_container_width`` is ``False``
60
+ (default), Streamlit sets the width of the chart to fit its contents
61
+ according to the plotting library, up to the width of the parent
62
+ container. If ``use_container_width`` is ``True``, Streamlit sets
63
+ the width of the figure to match the width of the parent container.
60
64
 
61
65
  Example
62
66
  -------
@@ -73,6 +73,12 @@ class PydeckMixin:
73
73
  pydeck_obj: pydeck.Deck or None
74
74
  Object specifying the PyDeck chart to draw.
75
75
  use_container_width: bool
76
+ Whether to override the figure's native width with the width of
77
+ the parent container. If ``use_container_width`` is ``False``
78
+ (default), Streamlit sets the width of the chart to fit its contents
79
+ according to the plotting library, up to the width of the parent
80
+ container. If ``use_container_width`` is ``True``, Streamlit sets
81
+ the width of the figure to match the width of the parent container.
76
82
 
77
83
  Example
78
84
  -------
@@ -86,13 +86,13 @@ def dialog_decorator(title: str, *, width: DialogWidth = "small") -> Callable[[F
86
86
  # The user is supposed to call it like @st.dialog("my_title") , which makes 'title' a positional arg, hence
87
87
  # this 'trick'. The overload is required to have a good type hint for the decorated function args.
88
88
  @overload
89
- def dialog_decorator(title: F | None, *, width: DialogWidth = "small") -> F:
89
+ def dialog_decorator(title: F, *, width: DialogWidth = "small") -> F:
90
90
  ...
91
91
 
92
92
 
93
93
  @gather_metrics("experimental_dialog")
94
94
  def dialog_decorator(
95
- title: F | None | str = "", *, width: DialogWidth = "small"
95
+ title: F | str, *, width: DialogWidth = "small"
96
96
  ) -> F | Callable[[F], F]:
97
97
  """Function decorator to create a modal dialog.
98
98
 
@@ -173,13 +173,7 @@ def dialog_decorator(
173
173
  """
174
174
 
175
175
  func_or_title = title
176
- if func_or_title is None:
177
- # Support passing the params via function decorator
178
- def wrapper(f: F) -> F:
179
- return _dialog_decorator(non_optional_func=f, title="", width=width)
180
-
181
- return wrapper
182
- elif type(func_or_title) is str:
176
+ if type(func_or_title) is str:
183
177
  # Support passing the params via function decorator
184
178
  def wrapper(f: F) -> F:
185
179
  title: str = func_or_title
@@ -50,8 +50,12 @@ class GraphvizMixin:
50
50
  The Graphlib graph object or dot string to display
51
51
 
52
52
  use_container_width : bool
53
- If True, set the chart width to the column width. This takes
54
- precedence over the figure's native `width` value.
53
+ Whether to override the figure's native width with the width of
54
+ the parent container. If ``use_container_width`` is ``False``
55
+ (default), Streamlit sets the width of the chart to fit its contents
56
+ according to the plotting library, up to the width of the parent
57
+ container. If ``use_container_width`` is ``True``, Streamlit sets
58
+ the width of the figure to match the width of the parent container.
55
59
 
56
60
  Example
57
61
  -------
@@ -118,8 +118,8 @@ def generate_chart(
118
118
  y_from_user: str | Sequence[str] | None = None,
119
119
  color_from_user: str | Color | list[Color] | None = None,
120
120
  size_from_user: str | float | None = None,
121
- width: int = 0,
122
- height: int = 0,
121
+ width: int | None = None,
122
+ height: int | None = None,
123
123
  ) -> tuple[alt.Chart, AddRowsMetadata]:
124
124
  """Function to use the chart's type, data columns and indices to figure out the chart's spec."""
125
125
  import altair as alt
@@ -167,8 +167,8 @@ def generate_chart(
167
167
  chart = alt.Chart(
168
168
  data=df,
169
169
  mark=chart_type.value["mark_type"],
170
- width=width,
171
- height=height,
170
+ width=width or 0,
171
+ height=height or 0,
172
172
  ).encode(
173
173
  x=_get_x_encoding(df, x_column, x_from_user, chart_type),
174
174
  y=_get_y_encoding(df, y_column, y_from_user),
streamlit/elements/map.py CHANGED
@@ -166,8 +166,12 @@ class MapMixin:
166
166
  https://wiki.openstreetmap.org/wiki/Zoom_levels.
167
167
 
168
168
  use_container_width: bool
169
- If True, set the chart width to the column width. This takes
170
- precedence over the width argument.
169
+ Whether to override the map's native width with the width of
170
+ the parent container. If ``use_container_width`` is ``False``
171
+ (default), Streamlit sets the width of the chart to fit its contents
172
+ according to the plotting library, up to the width of the parent
173
+ container. If ``use_container_width`` is ``True``, Streamlit sets
174
+ the width of the map to match the width of the parent container.
171
175
 
172
176
  Examples
173
177
  --------