streamlit 1.47.1__py3-none-any.whl → 1.48.0__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/cli_util.py +1 -1
- streamlit/commands/echo.py +2 -2
- streamlit/commands/execution_control.py +1 -1
- streamlit/commands/page_config.py +16 -16
- streamlit/components/v1/component_arrow.py +4 -4
- streamlit/config.py +23 -5
- streamlit/connections/base_connection.py +2 -2
- streamlit/connections/snowflake_connection.py +2 -2
- streamlit/connections/sql_connection.py +4 -3
- streamlit/dataframe_util.py +1 -1
- streamlit/deprecation_util.py +20 -5
- streamlit/elements/arrow.py +105 -79
- streamlit/elements/deck_gl_json_chart.py +6 -6
- streamlit/elements/dialog_decorator.py +72 -17
- streamlit/elements/form.py +36 -7
- streamlit/elements/graphviz_chart.py +7 -0
- streamlit/elements/json.py +3 -3
- streamlit/elements/layouts.py +241 -75
- streamlit/elements/lib/built_in_chart_utils.py +11 -3
- streamlit/elements/lib/dialog.py +43 -0
- streamlit/elements/lib/file_uploader_utils.py +21 -2
- streamlit/elements/lib/layout_utils.py +88 -2
- streamlit/elements/lib/options_selector_utils.py +1 -1
- streamlit/elements/lib/utils.py +23 -3
- streamlit/elements/map.py +12 -11
- streamlit/elements/plotly_chart.py +21 -21
- streamlit/elements/pyplot.py +8 -4
- streamlit/elements/vega_charts.py +237 -143
- streamlit/elements/widgets/audio_input.py +2 -2
- streamlit/elements/widgets/button.py +147 -35
- streamlit/elements/widgets/button_group.py +9 -8
- streamlit/elements/widgets/camera_input.py +2 -2
- streamlit/elements/widgets/chat.py +8 -2
- streamlit/elements/widgets/checkbox.py +4 -4
- streamlit/elements/widgets/color_picker.py +2 -2
- streamlit/elements/widgets/data_editor.py +22 -15
- streamlit/elements/widgets/file_uploader.py +8 -2
- streamlit/elements/widgets/multiselect.py +27 -17
- streamlit/elements/widgets/number_input.py +2 -2
- streamlit/elements/widgets/radio.py +5 -4
- streamlit/elements/widgets/select_slider.py +8 -5
- streamlit/elements/widgets/selectbox.py +14 -4
- streamlit/elements/widgets/slider.py +59 -33
- streamlit/elements/widgets/text_widgets.py +4 -4
- streamlit/elements/widgets/time_widgets.py +4 -4
- streamlit/elements/write.py +9 -8
- streamlit/env_util.py +1 -1
- streamlit/errors.py +20 -4
- streamlit/file_util.py +1 -1
- streamlit/git_util.py +1 -1
- streamlit/logger.py +2 -2
- streamlit/proto/Block_pb2.py +39 -31
- streamlit/proto/Block_pb2.pyi +54 -3
- streamlit/proto/Button_pb2.py +4 -2
- streamlit/proto/Button_pb2.pyi +1 -0
- streamlit/runtime/caching/cache_data_api.py +15 -2
- streamlit/runtime/caching/cache_errors.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +24 -2
- streamlit/runtime/caching/cache_utils.py +6 -3
- streamlit/runtime/caching/hashing.py +6 -9
- streamlit/runtime/fragment.py +3 -2
- streamlit/runtime/runtime.py +19 -2
- streamlit/runtime/scriptrunner/script_runner.py +3 -3
- streamlit/runtime/state/common.py +2 -1
- streamlit/runtime/state/query_params.py +2 -1
- streamlit/runtime/state/session_state.py +1 -1
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +231 -231
- streamlit/static/static/css/index.CQt5TjGB.css +1 -0
- streamlit/static/static/js/{ErrorOutline.esm.BEZPMjuG.js → ErrorOutline.esm.D_4oFNKB.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Dy1V9a2E.js → FileDownload.esm.NPgaLlUE.js} +1 -1
- streamlit/static/static/js/{FileHelper.D0K06YBq.js → FileHelper.B2t9ikoS.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Cdw5Y7_m.js → FormClearHelper.BLEIUk6L.js} +1 -1
- streamlit/static/static/js/{Hooks.C_qx1sSw.js → Hooks.BGm9sd4U.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D3IDU-eY.js → InputInstructions.DtUxCBS8.js} +1 -1
- streamlit/static/static/js/Particles.BDRPO7r3.js +1 -0
- streamlit/static/static/js/ProgressBar.B64DUUqp.js +2 -0
- streamlit/static/static/js/Toolbar.B3FquPk5.js +1 -0
- streamlit/static/static/js/{base-input.DMlw5p7n.js → base-input.DeBqm5mN.js} +4 -4
- streamlit/static/static/js/{checkbox.C7QR6llE.js → checkbox.C0odQfKb.js} +2 -2
- streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
- streamlit/static/static/js/{createSuper.C5k_2vfB.js → createSuper.DqQ5L3XG.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.DbNsQa8Y.js +1 -0
- streamlit/static/static/js/{downloader.Nj6v3ioB.js → downloader.Bx1D0jhz.js} +1 -1
- streamlit/static/static/js/{es6.CVz13CSz.js → es6.CbPK4m0H.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.gZ8zjT0K.js → iframeResizer.contentWindow.CfLKrptA.js} +1 -1
- streamlit/static/static/js/{index.D3wOJJsg.js → index.0XDwe9RV.js} +12 -12
- streamlit/static/static/js/{index.BscWuWHL.js → index.4lI9TuZm.js} +3 -3
- streamlit/static/static/js/index.6s0nVIis.js +3855 -0
- streamlit/static/static/js/index.9E7bRUBU.js +1 -0
- streamlit/static/static/js/index.B9PgeLrZ.js +1 -0
- streamlit/static/static/js/index.B9vzGbOt.js +1 -0
- streamlit/static/static/js/index.BDrQKMCm.js +1 -0
- streamlit/static/static/js/index.BPsoiGgP.js +1 -0
- streamlit/static/static/js/index.CJzdLAun.js +1 -0
- streamlit/static/static/js/index.CNNlC1NL.js +1 -0
- streamlit/static/static/js/index.CO1sClzJ.js +2 -0
- streamlit/static/static/js/index.CZnagxXD.js +1 -0
- streamlit/static/static/js/{index.MbqsiUV4.js → index.Cb0xSF7V.js} +289 -289
- streamlit/static/static/js/index.CgUt3tz_.js +1 -0
- streamlit/static/static/js/index.CjImmcsV.js +1 -0
- streamlit/static/static/js/index.ClRTsv8m.js +2 -0
- streamlit/static/static/js/{index.CTT2YqEU.js → index.CnfWsQzS.js} +1 -1
- streamlit/static/static/js/index.CrJ1XD_V.js +1 -0
- streamlit/static/static/js/index.CtiKsjSC.js +1 -0
- streamlit/static/static/js/index.CwAuytgV.js +1 -0
- streamlit/static/static/js/index.D7GB-kly.js +1 -0
- streamlit/static/static/js/index.DA5wU0mQ.js +1 -0
- streamlit/static/static/js/{index.xfcNJBLM.js → index.DCpyIFTV.js} +1 -1
- streamlit/static/static/js/index.DE9wNOje.js +1 -0
- streamlit/static/static/js/{index.mihWZKb1.js → index.DHnB-C8A.js} +1 -1
- streamlit/static/static/js/{index.BSFzxMXi.js → index.DRTn9zvD.js} +1 -1
- streamlit/static/static/js/index.DjMjyJl9.js +7 -0
- streamlit/static/static/js/{index.CbQtRkVt.js → index.DvRPFfw6.js} +162 -188
- streamlit/static/static/js/{index.B2L574n6.js → index.DwaoC4Zp.js} +3 -3
- streamlit/static/static/js/index.F9tSej94.js +1 -0
- streamlit/static/static/js/index.HeVbRh9H.js +73 -0
- streamlit/static/static/js/index.J2D_m7LY.js +197 -0
- streamlit/static/static/js/index.PyIqRRSR.js +1 -0
- streamlit/static/static/js/index.dfivzJNz.js +1 -0
- streamlit/static/static/js/index.mRztGO69.js +3 -0
- streamlit/static/static/js/index.tB1kn_7z.js +1 -0
- streamlit/static/static/js/index.wDYef4mQ.js +12 -0
- streamlit/static/static/js/{input.D_45B0P-.js → input.BL2buuce.js} +2 -2
- streamlit/static/static/js/{memory.BmhrRyO2.js → memory.CUxjUWS7.js} +1 -1
- streamlit/static/static/js/{mergeWith.DvOME7eH.js → mergeWith.C1kp1zIi.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BRNxOzEZ.js → number-overlay-editor.WpheGpmR.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.C5GiK_Ob.js → possibleConstructorReturn.DbvQboK3.js} +1 -1
- streamlit/static/static/js/{sandbox.B-Q9S7vW.js → sandbox.6lnFVWhX.js} +1 -1
- streamlit/static/static/js/{timepicker.DOMbfm_a.js → timepicker.Bg4xAK95.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CbNz0Ciu.js → toConsumableArray.D9x7Ktv4.js} +1 -1
- streamlit/static/static/js/{uniqueId.-ygIU7IL.js → uniqueId.Bm8FHN92.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Bx3VaRHk.js → useBasicWidgetState.CUSYQZpm.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.BuE9l5TG.js → useTextInputAutoExpand.Bf2egQOG.js} +2 -2
- streamlit/static/static/js/useUpdateUiValue.lE5xnYWF.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.CCOXR7N6.js +1 -0
- streamlit/temporary_directory.py +5 -3
- streamlit/testing/v1/app_test.py +4 -1
- streamlit/testing/v1/element_tree.py +4 -5
- streamlit/type_util.py +10 -3
- streamlit/user_info.py +18 -14
- streamlit/util.py +11 -1
- streamlit/watcher/local_sources_watcher.py +4 -3
- streamlit/web/bootstrap.py +18 -12
- streamlit/web/cli.py +2 -1
- streamlit/web/server/oauth_authlib_routes.py +59 -3
- streamlit/web/server/server.py +72 -21
- {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/METADATA +14 -2
- {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/RECORD +153 -153
- streamlit/static/static/css/index.CsLB_Bnz.css +0 -1
- streamlit/static/static/js/ProgressBar.EhJ_lCOf.js +0 -2
- streamlit/static/static/js/RenderInPortalIfExists.D6a0mMll.js +0 -1
- streamlit/static/static/js/Toolbar.D6yqQ65-.js +0 -1
- streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.CoquyZNK.js +0 -1
- streamlit/static/static/js/index.B3n-pURl.js +0 -2
- streamlit/static/static/js/index.B9jJp9aE.js +0 -1
- streamlit/static/static/js/index.BBVtld-D.js +0 -1
- streamlit/static/static/js/index.BKHPnvYd.js +0 -1
- streamlit/static/static/js/index.B_1CXynz.js +0 -1
- streamlit/static/static/js/index.Bm1LklYO.js +0 -1
- streamlit/static/static/js/index.Byi6__iF.js +0 -1
- streamlit/static/static/js/index.BzJeMpQ-.js +0 -197
- streamlit/static/static/js/index.C4tw7-Cl.js +0 -2
- streamlit/static/static/js/index.CG0C49ex.js +0 -1
- streamlit/static/static/js/index.CMuSJPv-.js +0 -1
- streamlit/static/static/js/index.COPFcr_K.js +0 -3855
- streamlit/static/static/js/index.CU3TLDlu.js +0 -1
- streamlit/static/static/js/index.CVKKDwaf.js +0 -1
- streamlit/static/static/js/index.CWZeK3mV.js +0 -12
- streamlit/static/static/js/index.CWbiNJQl.js +0 -1
- streamlit/static/static/js/index.CWxefYP6.js +0 -73
- streamlit/static/static/js/index.DOdWa88b.js +0 -1
- streamlit/static/static/js/index.DXtnaPua.js +0 -1
- streamlit/static/static/js/index.DatDwFl3.js +0 -3
- streamlit/static/static/js/index.DeWYPvQR.js +0 -1
- streamlit/static/static/js/index.Do4vzIvK.js +0 -1
- streamlit/static/static/js/index.Dvrstlh8.js +0 -1
- streamlit/static/static/js/index.DvznfdF_.js +0 -1
- streamlit/static/static/js/index.U1vvXeGn.js +0 -1
- streamlit/static/static/js/index._WAuWRkp.js +0 -7
- streamlit/static/static/js/index.bwA9_eWC.js +0 -1
- streamlit/static/static/js/index.m1njXuKl.js +0 -1
- streamlit/static/static/js/useOnInputChange.CDZx-L6q.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.DWXejOhQ.js +0 -1
- {streamlit-1.47.1.data → streamlit-1.48.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/WHEEL +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/top_level.txt +0 -0
|
@@ -14,11 +14,19 @@
|
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from dataclasses import dataclass
|
|
17
|
-
from typing import Literal, Union
|
|
17
|
+
from typing import Literal, Union, cast
|
|
18
18
|
|
|
19
19
|
from typing_extensions import TypeAlias
|
|
20
20
|
|
|
21
|
-
from streamlit.errors import
|
|
21
|
+
from streamlit.errors import (
|
|
22
|
+
StreamlitInvalidColumnGapError,
|
|
23
|
+
StreamlitInvalidHeightError,
|
|
24
|
+
StreamlitInvalidHorizontalAlignmentError,
|
|
25
|
+
StreamlitInvalidVerticalAlignmentError,
|
|
26
|
+
StreamlitInvalidWidthError,
|
|
27
|
+
)
|
|
28
|
+
from streamlit.proto.Block_pb2 import Block
|
|
29
|
+
from streamlit.proto.GapSize_pb2 import GapSize
|
|
22
30
|
from streamlit.proto.HeightConfig_pb2 import HeightConfig
|
|
23
31
|
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
|
24
32
|
|
|
@@ -26,6 +34,9 @@ WidthWithoutContent: TypeAlias = Union[int, Literal["stretch"]]
|
|
|
26
34
|
Width: TypeAlias = Union[int, Literal["stretch", "content"]]
|
|
27
35
|
HeightWithoutContent: TypeAlias = Union[int, Literal["stretch"]]
|
|
28
36
|
Height: TypeAlias = Union[int, Literal["stretch", "content"]]
|
|
37
|
+
Gap: TypeAlias = Literal["small", "medium", "large"]
|
|
38
|
+
HorizontalAlignment: TypeAlias = Literal["left", "center", "right", "distribute"]
|
|
39
|
+
VerticalAlignment: TypeAlias = Literal["top", "center", "bottom", "distribute"]
|
|
29
40
|
|
|
30
41
|
|
|
31
42
|
@dataclass
|
|
@@ -113,3 +124,78 @@ def get_height_config(height: Height) -> HeightConfig:
|
|
|
113
124
|
else:
|
|
114
125
|
height_config.use_stretch = True
|
|
115
126
|
return height_config
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def get_gap_size(gap: str | None, element_type: str) -> GapSize.ValueType:
|
|
130
|
+
"""Convert a gap string or None to a GapSize proto value."""
|
|
131
|
+
gap_mapping = {
|
|
132
|
+
"small": GapSize.SMALL,
|
|
133
|
+
"medium": GapSize.MEDIUM,
|
|
134
|
+
"large": GapSize.LARGE,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if isinstance(gap, str):
|
|
138
|
+
gap_size = gap.lower()
|
|
139
|
+
valid_sizes = gap_mapping.keys()
|
|
140
|
+
|
|
141
|
+
if gap_size in valid_sizes:
|
|
142
|
+
return gap_mapping[gap_size]
|
|
143
|
+
elif gap is None:
|
|
144
|
+
return GapSize.NONE
|
|
145
|
+
|
|
146
|
+
raise StreamlitInvalidColumnGapError(gap=gap, element_type=element_type)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def validate_horizontal_alignment(horizontal_alignment: HorizontalAlignment) -> None:
|
|
150
|
+
valid_horizontal_alignments = ["left", "center", "right", "distribute"]
|
|
151
|
+
if horizontal_alignment not in valid_horizontal_alignments:
|
|
152
|
+
raise StreamlitInvalidHorizontalAlignmentError(
|
|
153
|
+
horizontal_alignment, "st.container"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def validate_vertical_alignment(vertical_alignment: VerticalAlignment) -> None:
|
|
158
|
+
valid_vertical_alignments = ["top", "center", "bottom", "distribute"]
|
|
159
|
+
if vertical_alignment not in valid_vertical_alignments:
|
|
160
|
+
raise StreamlitInvalidVerticalAlignmentError(vertical_alignment, "st.container")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
map_to_flex_terminology = {
|
|
164
|
+
"left": "start",
|
|
165
|
+
"center": "center",
|
|
166
|
+
"right": "end",
|
|
167
|
+
"top": "start",
|
|
168
|
+
"bottom": "end",
|
|
169
|
+
"distribute": "space_between",
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def get_justify(
|
|
174
|
+
alignment: HorizontalAlignment | VerticalAlignment,
|
|
175
|
+
) -> Block.FlexContainer.Justify.ValueType:
|
|
176
|
+
valid_justify = ["start", "center", "end", "space_between"]
|
|
177
|
+
justify = map_to_flex_terminology[alignment]
|
|
178
|
+
if justify not in valid_justify:
|
|
179
|
+
return Block.FlexContainer.Justify.JUSTIFY_UNDEFINED
|
|
180
|
+
if justify in ["start", "end", "center"]:
|
|
181
|
+
return cast(
|
|
182
|
+
"Block.FlexContainer.Justify.ValueType",
|
|
183
|
+
getattr(Block.FlexContainer.Justify, f"JUSTIFY_{justify.upper()}"),
|
|
184
|
+
)
|
|
185
|
+
return cast(
|
|
186
|
+
"Block.FlexContainer.Justify.ValueType",
|
|
187
|
+
getattr(Block.FlexContainer.Justify, f"{justify.upper()}"),
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def get_align(
|
|
192
|
+
alignment: HorizontalAlignment | VerticalAlignment,
|
|
193
|
+
) -> Block.FlexContainer.Align.ValueType:
|
|
194
|
+
valid_align = ["start", "end", "center"]
|
|
195
|
+
align = map_to_flex_terminology[alignment]
|
|
196
|
+
if align not in valid_align:
|
|
197
|
+
return Block.FlexContainer.Align.ALIGN_UNDEFINED
|
|
198
|
+
return cast(
|
|
199
|
+
"Block.FlexContainer.Align.ValueType",
|
|
200
|
+
getattr(Block.FlexContainer.Align, f"ALIGN_{align.upper()}"),
|
|
201
|
+
)
|
|
@@ -22,7 +22,6 @@ from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
|
|
22
22
|
from streamlit.errors import StreamlitAPIException
|
|
23
23
|
from streamlit.runtime.state.common import RegisterWidgetResult
|
|
24
24
|
from streamlit.type_util import (
|
|
25
|
-
T,
|
|
26
25
|
check_python_comparable,
|
|
27
26
|
)
|
|
28
27
|
|
|
@@ -33,6 +32,7 @@ _LOGGER: Final = logger.get_logger(__name__)
|
|
|
33
32
|
|
|
34
33
|
_FLOAT_EQUALITY_EPSILON: Final[float] = 0.000000000005
|
|
35
34
|
_Value = TypeVar("_Value")
|
|
35
|
+
T = TypeVar("T")
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def index_(iterable: Iterable[_Value], x: _Value) -> int:
|
streamlit/elements/lib/utils.py
CHANGED
|
@@ -186,6 +186,7 @@ def compute_and_register_element_id(
|
|
|
186
186
|
user_key: str | None,
|
|
187
187
|
form_id: str | None,
|
|
188
188
|
dg: DeltaGenerator | None = None,
|
|
189
|
+
style: str | None = None,
|
|
189
190
|
**kwargs: SAFE_VALUES | Iterable[SAFE_VALUES],
|
|
190
191
|
) -> str:
|
|
191
192
|
"""Compute and register the ID for the given element.
|
|
@@ -219,6 +220,11 @@ def compute_and_register_element_id(
|
|
|
219
220
|
dg : DeltaGenerator | None
|
|
220
221
|
The DeltaGenerator of each element. `None` if the element is not a widget.
|
|
221
222
|
|
|
223
|
+
style: str | None
|
|
224
|
+
The style of the element, to provide more context to the user in the
|
|
225
|
+
error message. This should be `None` if the element does not support
|
|
226
|
+
the style parameter.
|
|
227
|
+
|
|
222
228
|
kwargs : SAFE_VALUES | Iterable[SAFE_VALUES]
|
|
223
229
|
The arguments to use to compute the element ID.
|
|
224
230
|
The arguments must be stable, deterministic values.
|
|
@@ -228,8 +234,22 @@ def compute_and_register_element_id(
|
|
|
228
234
|
"""
|
|
229
235
|
ctx = get_script_run_ctx()
|
|
230
236
|
|
|
231
|
-
|
|
232
|
-
|
|
237
|
+
kwargs_to_use = {**kwargs}
|
|
238
|
+
if form_id:
|
|
239
|
+
kwargs_to_use["form_id"] = form_id
|
|
240
|
+
if style:
|
|
241
|
+
kwargs_to_use["style"] = style
|
|
242
|
+
|
|
243
|
+
# If style is provided, use it for the error message, to provide more
|
|
244
|
+
# context to the user.
|
|
245
|
+
if style == "borderless":
|
|
246
|
+
# The borderless style is used by st.feedback, but users expect to see
|
|
247
|
+
# "feedback" in errors
|
|
248
|
+
element_type_for_error = "feedback"
|
|
249
|
+
elif style:
|
|
250
|
+
element_type_for_error = style
|
|
251
|
+
else:
|
|
252
|
+
element_type_for_error = element_type
|
|
233
253
|
|
|
234
254
|
if ctx:
|
|
235
255
|
# Add the active script hash to give elements on different
|
|
@@ -251,7 +271,7 @@ def compute_and_register_element_id(
|
|
|
251
271
|
)
|
|
252
272
|
|
|
253
273
|
if ctx:
|
|
254
|
-
_register_element_id(ctx,
|
|
274
|
+
_register_element_id(ctx, element_type_for_error, element_id)
|
|
255
275
|
return element_id
|
|
256
276
|
|
|
257
277
|
|
streamlit/elements/map.py
CHANGED
|
@@ -188,14 +188,15 @@ class MapMixin:
|
|
|
188
188
|
|
|
189
189
|
Examples
|
|
190
190
|
--------
|
|
191
|
-
>>> import streamlit as st
|
|
192
191
|
>>> import pandas as pd
|
|
193
|
-
>>> import
|
|
192
|
+
>>> import streamlit as st
|
|
193
|
+
>>> from numpy.random import default_rng as rng
|
|
194
194
|
>>>
|
|
195
195
|
>>> df = pd.DataFrame(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
>>> rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
|
|
197
|
+
>>> columns=["lat", "lon"],
|
|
198
|
+
>>> )
|
|
199
|
+
>>>
|
|
199
200
|
>>> st.map(df)
|
|
200
201
|
|
|
201
202
|
.. output::
|
|
@@ -210,16 +211,16 @@ class MapMixin:
|
|
|
210
211
|
and longitude components, as well as set size and color of each
|
|
211
212
|
datapoint dynamically based on other columns:
|
|
212
213
|
|
|
213
|
-
>>> import streamlit as st
|
|
214
214
|
>>> import pandas as pd
|
|
215
|
-
>>> import
|
|
215
|
+
>>> import streamlit as st
|
|
216
|
+
>>> from numpy.random import default_rng as rng
|
|
216
217
|
>>>
|
|
217
218
|
>>> df = pd.DataFrame(
|
|
218
219
|
... {
|
|
219
|
-
... "col1":
|
|
220
|
-
... "col2":
|
|
221
|
-
... "col3":
|
|
222
|
-
... "col4":
|
|
220
|
+
... "col1": rng(0).standard_normal(1000) / 50 + 37.76,
|
|
221
|
+
... "col2": rng(1).standard_normal(1000) / 50 + -122.4,
|
|
222
|
+
... "col3": rng(2).standard_normal(1000) * 100,
|
|
223
|
+
... "col4": rng(3).standard_normal((1000, 4)).tolist(),
|
|
223
224
|
... }
|
|
224
225
|
... )
|
|
225
226
|
>>>
|
|
@@ -112,8 +112,8 @@ class PlotlySelectionState(TypedDict, total=False):
|
|
|
112
112
|
displays additional information. Try selecting points in the following
|
|
113
113
|
example:
|
|
114
114
|
|
|
115
|
-
>>> import streamlit as st
|
|
116
115
|
>>> import plotly.express as px
|
|
116
|
+
>>> import streamlit as st
|
|
117
117
|
>>>
|
|
118
118
|
>>> df = px.data.iris()
|
|
119
119
|
>>> fig = px.scatter(
|
|
@@ -189,10 +189,10 @@ class PlotlyState(TypedDict, total=False):
|
|
|
189
189
|
box, or lasso). The current selection state is available through Session
|
|
190
190
|
State or as the output of the chart function.
|
|
191
191
|
|
|
192
|
-
>>> import streamlit as st
|
|
193
192
|
>>> import plotly.express as px
|
|
193
|
+
>>> import streamlit as st
|
|
194
194
|
>>>
|
|
195
|
-
>>> df = px.data.iris()
|
|
195
|
+
>>> df = px.data.iris()
|
|
196
196
|
>>> fig = px.scatter(df, x="sepal_width", y="sepal_length")
|
|
197
197
|
>>>
|
|
198
198
|
>>> event = st.plotly_chart(fig, key="iris", on_select="rerun")
|
|
@@ -328,8 +328,12 @@ class PlotlyMixin:
|
|
|
328
328
|
you would call Plotly's ``py.plot`` or ``py.iplot``.
|
|
329
329
|
|
|
330
330
|
.. Important::
|
|
331
|
-
You must install ``plotly`` to use this command. Your app's
|
|
332
|
-
performance may be enhanced by installing ``orjson`` as well.
|
|
331
|
+
You must install ``plotly>=4.0.0`` to use this command. Your app's
|
|
332
|
+
performance may be enhanced by installing ``orjson`` as well. You
|
|
333
|
+
can install all charting dependencies (except Bokeh) as an extra
|
|
334
|
+
with Streamlit:
|
|
335
|
+
|
|
336
|
+
>>> pip install streamlit[charts]
|
|
333
337
|
|
|
334
338
|
Parameters
|
|
335
339
|
----------
|
|
@@ -428,30 +432,26 @@ class PlotlyMixin:
|
|
|
428
432
|
|
|
429
433
|
Examples
|
|
430
434
|
--------
|
|
431
|
-
**Example 1: Basic Plotly
|
|
435
|
+
**Example 1: Basic Plotly chart**
|
|
432
436
|
|
|
433
437
|
The example below comes from the examples at https://plot.ly/python.
|
|
434
438
|
Note that ``plotly.figure_factory`` requires ``scipy`` to run.
|
|
435
439
|
|
|
436
|
-
>>> import streamlit as st
|
|
437
|
-
>>> import numpy as np
|
|
438
440
|
>>> import plotly.figure_factory as ff
|
|
441
|
+
>>> import streamlit as st
|
|
442
|
+
>>> from numpy.random import default_rng as rng
|
|
439
443
|
>>>
|
|
440
|
-
>>>
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
>>>
|
|
446
|
-
>>> hist_data = [x1, x2, x3]
|
|
447
|
-
>>>
|
|
448
|
-
>>> group_labels = ['Group 1', 'Group 2', 'Group 3']
|
|
444
|
+
>>> hist_data = [
|
|
445
|
+
... rng(0).standard_normal(200) - 2,
|
|
446
|
+
... rng(1).standard_normal(200),
|
|
447
|
+
... rng(2).standard_normal(200) + 2,
|
|
448
|
+
... ]
|
|
449
|
+
>>> group_labels = ["Group 1", "Group 2", "Group 3"]
|
|
449
450
|
>>>
|
|
450
|
-
>>> # Create distplot with custom bin_size
|
|
451
451
|
>>> fig = ff.create_distplot(
|
|
452
|
-
...
|
|
452
|
+
... hist_data, group_labels, bin_size=[0.1, 0.25, 0.5]
|
|
453
|
+
... )
|
|
453
454
|
>>>
|
|
454
|
-
>>> # Plot!
|
|
455
455
|
>>> st.plotly_chart(fig)
|
|
456
456
|
|
|
457
457
|
.. output::
|
|
@@ -466,8 +466,8 @@ class PlotlyMixin:
|
|
|
466
466
|
zoom. In the following example, scroll zoom is disabled, but the zoom
|
|
467
467
|
buttons are still enabled in the modebar.
|
|
468
468
|
|
|
469
|
-
>>> import streamlit as st
|
|
470
469
|
>>> import plotly.graph_objects as go
|
|
470
|
+
>>> import streamlit as st
|
|
471
471
|
>>>
|
|
472
472
|
>>> fig = go.Figure()
|
|
473
473
|
>>> fig.add_trace(
|
streamlit/elements/pyplot.py
CHANGED
|
@@ -42,7 +42,11 @@ class PyplotMixin:
|
|
|
42
42
|
"""Display a matplotlib.pyplot figure.
|
|
43
43
|
|
|
44
44
|
.. Important::
|
|
45
|
-
You must install ``matplotlib`` to use this command.
|
|
45
|
+
You must install ``matplotlib>=3.0.0`` to use this command. You can
|
|
46
|
+
install all charting dependencies (except Bokeh) as an extra with
|
|
47
|
+
Streamlit:
|
|
48
|
+
|
|
49
|
+
>>> pip install streamlit[charts]
|
|
46
50
|
|
|
47
51
|
Parameters
|
|
48
52
|
----------
|
|
@@ -79,11 +83,11 @@ class PyplotMixin:
|
|
|
79
83
|
|
|
80
84
|
Example
|
|
81
85
|
-------
|
|
82
|
-
>>> import streamlit as st
|
|
83
86
|
>>> import matplotlib.pyplot as plt
|
|
84
|
-
>>> import
|
|
87
|
+
>>> import streamlit as st
|
|
88
|
+
>>> from numpy.random import default_rng as rng
|
|
85
89
|
>>>
|
|
86
|
-
>>> arr =
|
|
90
|
+
>>> arr = rng(0).normal(1, 1, size=100)
|
|
87
91
|
>>> fig, ax = plt.subplots()
|
|
88
92
|
>>> ax.hist(arr, bins=20)
|
|
89
93
|
>>>
|