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.
- streamlit/commands/logo.py +61 -13
- streamlit/components/types/base_custom_component.py +15 -2
- streamlit/components/v1/custom_component.py +13 -1
- streamlit/config.py +8 -0
- streamlit/elements/arrow.py +141 -46
- streamlit/elements/bokeh_chart.py +9 -5
- streamlit/elements/deck_gl_json_chart.py +6 -0
- streamlit/elements/dialog_decorator.py +3 -9
- streamlit/elements/graphviz_chart.py +6 -2
- streamlit/elements/lib/built_in_chart_utils.py +4 -4
- streamlit/elements/map.py +6 -2
- streamlit/elements/plotly_chart.py +158 -39
- streamlit/elements/pyplot.py +9 -4
- streamlit/elements/vega_charts.py +327 -84
- streamlit/elements/widgets/data_editor.py +17 -8
- streamlit/runtime/app_session.py +2 -1
- streamlit/runtime/state/common.py +1 -1
- streamlit/static/asset-manifest.json +3 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{8148.f80eec24.chunk.js → 8148.a17a918e.chunk.js} +1 -1
- streamlit/static/static/js/{main.9db3e91c.js → main.7e42f54d.js} +2 -2
- streamlit/web/server/browser_websocket_handler.py +8 -4
- {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/RECORD +29 -29
- /streamlit/static/static/js/{main.9db3e91c.js.LICENSE.txt → main.7e42f54d.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.34.1.dev20240521.data → streamlit_nightly-1.35.1.dev20240523.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.34.1.dev20240521.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/top_level.txt +0 -0
streamlit/commands/logo.py
CHANGED
@@ -41,25 +41,73 @@ def logo(
|
|
41
41
|
icon_image: AtomicImage | None = None,
|
42
42
|
) -> None:
|
43
43
|
"""
|
44
|
-
Renders
|
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
|
49
|
-
The
|
50
|
-
|
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
|
53
|
-
http:// or https://)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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(
|
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(
|
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(
|
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?",
|
streamlit/elements/arrow.py
CHANGED
@@ -85,14 +85,49 @@ _SELECTION_MODES: Final[set[SelectionMode]] = {
|
|
85
85
|
|
86
86
|
class DataframeSelectionState(TypedDict, total=False):
|
87
87
|
"""
|
88
|
-
|
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
|
94
|
-
|
95
|
-
|
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
|
-
|
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
|
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,
|
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
|
241
|
-
underlying DataFrame
|
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
|
247
|
-
|
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
|
251
|
-
default height
|
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
|
-
|
255
|
-
|
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
|
259
|
-
index columns is automatically
|
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
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
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
|
-
|
269
|
-
|
270
|
-
|
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
|
336
|
+
* ``None``: Streamlit hides the column.
|
273
337
|
|
274
|
-
* A string
|
338
|
+
* A string: Streamlit changes the display label of the column to
|
339
|
+
the given string.
|
275
340
|
|
276
|
-
*
|
277
|
-
|
278
|
-
|
279
|
-
|
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
|
285
|
-
|
286
|
-
|
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
|
-
|
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
|
-
-
|
292
|
-
|
293
|
-
In this case,
|
294
|
-
|
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",
|
299
|
-
|
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
|
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:
|
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:
|
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
|
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
|
50
|
-
wherever you would call Bokeh's
|
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
|
-
|
59
|
-
|
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
|
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 |
|
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
|
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
|
-
|
54
|
-
|
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 =
|
122
|
-
height: int =
|
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
|
-
|
170
|
-
|
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
|
--------
|