streamlit-nightly 1.34.1.dev20240522__py2.py3-none-any.whl → 1.35.1.dev20240524__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/__init__.py +4 -5
- streamlit/commands/logo.py +61 -13
- streamlit/config.py +9 -15
- 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 +5 -3
- 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/utils.py +3 -6
- streamlit/elements/vega_charts.py +327 -84
- streamlit/elements/widgets/data_editor.py +17 -8
- streamlit/runtime/app_session.py +3 -3
- streamlit/runtime/caching/__init__.py +5 -0
- streamlit/runtime/caching/legacy_cache_api.py +164 -0
- streamlit/runtime/fragment.py +91 -80
- streamlit/runtime/runtime.py +0 -2
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{main.7e42f54d.js → main.e93f99a3.js} +2 -2
- streamlit/web/cli.py +1 -8
- streamlit/web/server/browser_websocket_handler.py +8 -4
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240524.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240524.dist-info}/RECORD +32 -34
- streamlit/runtime/legacy_caching/__init__.py +0 -17
- streamlit/runtime/legacy_caching/caching.py +0 -810
- streamlit/runtime/legacy_caching/hashing.py +0 -1005
- /streamlit/static/static/js/{main.7e42f54d.js.LICENSE.txt → main.e93f99a3.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.34.1.dev20240522.data → streamlit_nightly-1.35.1.dev20240524.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240524.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240524.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240524.dist-info}/top_level.txt +0 -0
streamlit/__init__.py
CHANGED
@@ -77,6 +77,7 @@ from streamlit.elements.dialog_decorator import dialog_decorator as _dialog_deco
|
|
77
77
|
from streamlit.runtime.caching import (
|
78
78
|
cache_resource as _cache_resource,
|
79
79
|
cache_data as _cache_data,
|
80
|
+
cache as _cache,
|
80
81
|
experimental_singleton as _experimental_singleton,
|
81
82
|
experimental_memo as _experimental_memo,
|
82
83
|
)
|
@@ -104,7 +105,6 @@ import streamlit.column_config as _column_config
|
|
104
105
|
# You can check the export behavior by running 'mypy --strict example_app.py', which disables implicit_reexport, where you use the respective command in the example_app.py Streamlit app.
|
105
106
|
|
106
107
|
from streamlit.echo import echo as echo
|
107
|
-
from streamlit.runtime.legacy_caching import cache as _cache
|
108
108
|
from streamlit.commands.logo import logo as logo
|
109
109
|
from streamlit.elements.spinner import spinner as spinner
|
110
110
|
|
@@ -116,10 +116,6 @@ from streamlit.commands.execution_control import (
|
|
116
116
|
switch_page as switch_page,
|
117
117
|
)
|
118
118
|
|
119
|
-
# We add the metrics tracking for caching here,
|
120
|
-
# since the actual cache function calls itself recursively
|
121
|
-
cache = _gather_metrics("cache", _cache)
|
122
|
-
|
123
119
|
|
124
120
|
def _update_logger() -> None:
|
125
121
|
_logger.set_log_level(_config.get_option("logger.level").upper())
|
@@ -230,6 +226,8 @@ query_params = _QueryParamsProxy()
|
|
230
226
|
# Caching
|
231
227
|
cache_data = _cache_data
|
232
228
|
cache_resource = _cache_resource
|
229
|
+
# `st.cache` is deprecated and should be removed soon
|
230
|
+
cache = _cache
|
233
231
|
|
234
232
|
# Namespaces
|
235
233
|
column_config = _column_config
|
@@ -244,6 +242,7 @@ experimental_memo = _experimental_memo
|
|
244
242
|
experimental_singleton = _experimental_singleton
|
245
243
|
experimental_user = _UserInfoProxy()
|
246
244
|
|
245
|
+
|
247
246
|
_EXPERIMENTAL_QUERY_PARAMS_DEPRECATE_MSG = "Refer to our [docs page](https://docs.streamlit.io/library/api-reference/utilities/st.query_params) for more information."
|
248
247
|
|
249
248
|
experimental_get_query_params = _deprecate_func_name(
|
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()
|
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?",
|
@@ -465,19 +473,6 @@ _create_option(
|
|
465
473
|
|
466
474
|
_create_section("client", "Settings for scripts that use Streamlit.")
|
467
475
|
|
468
|
-
_create_option(
|
469
|
-
"client.caching",
|
470
|
-
description="""
|
471
|
-
Whether to enable st.cache. This does not affect st.cache_data or
|
472
|
-
st.cache_resource.""",
|
473
|
-
default_val=True,
|
474
|
-
type_=bool,
|
475
|
-
scriptable=True,
|
476
|
-
deprecated=True,
|
477
|
-
deprecation_text="client.caching has been deprecated and is not required anymore for our new caching commands.",
|
478
|
-
expiration_date="2024-01-20",
|
479
|
-
)
|
480
|
-
|
481
476
|
_create_option(
|
482
477
|
"client.displayEnabled",
|
483
478
|
description="""If false, makes your Streamlit script not draw to a
|
@@ -639,8 +634,7 @@ _create_section("server", "Settings for the Streamlit server")
|
|
639
634
|
|
640
635
|
_create_option(
|
641
636
|
"server.folderWatchBlacklist",
|
642
|
-
description="""List of folders that should not be watched for changes.
|
643
|
-
impacts both "Run on Save" and @st.cache.
|
637
|
+
description="""List of folders that should not be watched for changes.
|
644
638
|
|
645
639
|
Relative paths will be taken as relative to the current working directory.
|
646
640
|
|
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
|
-------
|
@@ -20,7 +20,7 @@ from typing import Callable, TypeVar, cast, overload
|
|
20
20
|
from streamlit.delta_generator import event_dg, get_last_dg_added_to_context_stack
|
21
21
|
from streamlit.elements.lib.dialog import DialogWidth
|
22
22
|
from streamlit.errors import StreamlitAPIException
|
23
|
-
from streamlit.runtime.fragment import
|
23
|
+
from streamlit.runtime.fragment import _fragment
|
24
24
|
from streamlit.runtime.metrics_util import gather_metrics
|
25
25
|
|
26
26
|
|
@@ -64,14 +64,16 @@ def _dialog_decorator(
|
|
64
64
|
dialog = event_dg._dialog(title=title, dismissible=True, width=width)
|
65
65
|
dialog.open()
|
66
66
|
|
67
|
-
@_fragment
|
68
67
|
def dialog_content() -> None:
|
69
68
|
# if the dialog should be closed, st.rerun() has to be called (same behavior as with st.fragment)
|
70
69
|
_ = non_optional_func(*args, **kwargs)
|
71
70
|
return None
|
72
71
|
|
72
|
+
# the fragment decorator has multiple return types so that you can pass arguments to it. Here we know the return type, so we cast
|
73
|
+
fragmented_dialog_content = cast(Callable[[], None], _fragment(dialog_content))
|
73
74
|
with dialog:
|
74
|
-
|
75
|
+
fragmented_dialog_content()
|
76
|
+
return None
|
75
77
|
|
76
78
|
return cast(F, wrap)
|
77
79
|
|
@@ -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
|
--------
|