streamlit 1.47.1__py3-none-any.whl → 1.48.1__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 (193) hide show
  1. streamlit/cli_util.py +1 -1
  2. streamlit/commands/echo.py +2 -2
  3. streamlit/commands/execution_control.py +1 -1
  4. streamlit/commands/page_config.py +16 -16
  5. streamlit/components/v1/component_arrow.py +4 -4
  6. streamlit/config.py +23 -5
  7. streamlit/connections/base_connection.py +2 -2
  8. streamlit/connections/snowflake_connection.py +2 -2
  9. streamlit/connections/sql_connection.py +4 -3
  10. streamlit/dataframe_util.py +1 -1
  11. streamlit/deprecation_util.py +20 -5
  12. streamlit/elements/arrow.py +105 -79
  13. streamlit/elements/deck_gl_json_chart.py +6 -6
  14. streamlit/elements/dialog_decorator.py +72 -17
  15. streamlit/elements/form.py +36 -7
  16. streamlit/elements/graphviz_chart.py +7 -0
  17. streamlit/elements/iframe.py +13 -22
  18. streamlit/elements/json.py +3 -3
  19. streamlit/elements/layouts.py +241 -75
  20. streamlit/elements/lib/built_in_chart_utils.py +11 -3
  21. streamlit/elements/lib/dialog.py +43 -0
  22. streamlit/elements/lib/file_uploader_utils.py +21 -2
  23. streamlit/elements/lib/layout_utils.py +88 -2
  24. streamlit/elements/lib/options_selector_utils.py +1 -1
  25. streamlit/elements/lib/utils.py +23 -3
  26. streamlit/elements/map.py +12 -11
  27. streamlit/elements/plotly_chart.py +21 -21
  28. streamlit/elements/pyplot.py +8 -4
  29. streamlit/elements/vega_charts.py +237 -143
  30. streamlit/elements/widgets/audio_input.py +2 -2
  31. streamlit/elements/widgets/button.py +147 -35
  32. streamlit/elements/widgets/button_group.py +9 -8
  33. streamlit/elements/widgets/camera_input.py +2 -2
  34. streamlit/elements/widgets/chat.py +8 -2
  35. streamlit/elements/widgets/checkbox.py +4 -4
  36. streamlit/elements/widgets/color_picker.py +2 -2
  37. streamlit/elements/widgets/data_editor.py +22 -15
  38. streamlit/elements/widgets/file_uploader.py +8 -2
  39. streamlit/elements/widgets/multiselect.py +27 -17
  40. streamlit/elements/widgets/number_input.py +2 -2
  41. streamlit/elements/widgets/radio.py +5 -4
  42. streamlit/elements/widgets/select_slider.py +8 -5
  43. streamlit/elements/widgets/selectbox.py +14 -4
  44. streamlit/elements/widgets/slider.py +59 -33
  45. streamlit/elements/widgets/text_widgets.py +4 -4
  46. streamlit/elements/widgets/time_widgets.py +4 -4
  47. streamlit/elements/write.py +9 -8
  48. streamlit/env_util.py +1 -1
  49. streamlit/errors.py +20 -4
  50. streamlit/file_util.py +1 -1
  51. streamlit/git_util.py +1 -1
  52. streamlit/logger.py +2 -2
  53. streamlit/proto/Block_pb2.py +39 -31
  54. streamlit/proto/Block_pb2.pyi +54 -3
  55. streamlit/proto/Button_pb2.py +4 -2
  56. streamlit/proto/Button_pb2.pyi +1 -0
  57. streamlit/proto/IFrame_pb2.py +8 -2
  58. streamlit/proto/IFrame_pb2.pyi +3 -0
  59. streamlit/runtime/caching/cache_data_api.py +15 -2
  60. streamlit/runtime/caching/cache_errors.py +1 -1
  61. streamlit/runtime/caching/cache_resource_api.py +24 -2
  62. streamlit/runtime/caching/cache_utils.py +6 -3
  63. streamlit/runtime/caching/hashing.py +6 -9
  64. streamlit/runtime/fragment.py +3 -2
  65. streamlit/runtime/runtime.py +19 -2
  66. streamlit/runtime/scriptrunner/script_runner.py +3 -3
  67. streamlit/runtime/state/common.py +2 -1
  68. streamlit/runtime/state/query_params.py +2 -1
  69. streamlit/runtime/state/session_state.py +1 -1
  70. streamlit/static/index.html +1 -1
  71. streamlit/static/manifest.json +231 -231
  72. streamlit/static/static/css/index.CQt5TjGB.css +1 -0
  73. streamlit/static/static/js/{ErrorOutline.esm.BEZPMjuG.js → ErrorOutline.esm.DjObtx4K.js} +1 -1
  74. streamlit/static/static/js/{FileDownload.esm.Dy1V9a2E.js → FileDownload.esm.Bz9nxNC5.js} +1 -1
  75. streamlit/static/static/js/{FileHelper.D0K06YBq.js → FileHelper.BrQvUXVD.js} +1 -1
  76. streamlit/static/static/js/{FormClearHelper.Cdw5Y7_m.js → FormClearHelper.DF4gFAOO.js} +1 -1
  77. streamlit/static/static/js/{Hooks.C_qx1sSw.js → Hooks.DEoLCfOE.js} +1 -1
  78. streamlit/static/static/js/{InputInstructions.D3IDU-eY.js → InputInstructions.D8zoMog9.js} +1 -1
  79. streamlit/static/static/js/Particles.CCFySwdL.js +1 -0
  80. streamlit/static/static/js/ProgressBar.COK9j1l0.js +2 -0
  81. streamlit/static/static/js/Toolbar.Dt4jIKlY.js +1 -0
  82. streamlit/static/static/js/{base-input.DMlw5p7n.js → base-input.BmvSaPd2.js} +4 -4
  83. streamlit/static/static/js/{checkbox.C7QR6llE.js → checkbox.Cgxgc0et.js} +2 -2
  84. streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
  85. streamlit/static/static/js/{createSuper.C5k_2vfB.js → createSuper.siQeagI2.js} +1 -1
  86. streamlit/static/static/js/data-grid-overlay-editor.Ct51iCb_.js +1 -0
  87. streamlit/static/static/js/{downloader.Nj6v3ioB.js → downloader.M6jQeNDf.js} +1 -1
  88. streamlit/static/static/js/{es6.CVz13CSz.js → es6.CMaUdEZ5.js} +2 -2
  89. streamlit/static/static/js/{iframeResizer.contentWindow.gZ8zjT0K.js → iframeResizer.contentWindow.C33BryyP.js} +1 -1
  90. streamlit/static/static/js/index.8GJD0eeD.js +1 -0
  91. streamlit/static/static/js/index.8QEYHMQD.js +1 -0
  92. streamlit/static/static/js/index.Ay41Wnu9.js +1 -0
  93. streamlit/static/static/js/index.BLiKiJ7_.js +1 -0
  94. streamlit/static/static/js/index.BT78cJmU.js +1 -0
  95. streamlit/static/static/js/index.BXDq9dj4.js +1 -0
  96. streamlit/static/static/js/index.BdGvnhlM.js +1 -0
  97. streamlit/static/static/js/index.BfasrT0d.js +1 -0
  98. streamlit/static/static/js/index.CCdtFMFG.js +1 -0
  99. streamlit/static/static/js/index.CFRGZDz1.js +1 -0
  100. streamlit/static/static/js/{index.MbqsiUV4.js → index.CFSFYiPA.js} +289 -289
  101. streamlit/static/static/js/{index.B2L574n6.js → index.CbdWnLqS.js} +3 -3
  102. streamlit/static/static/js/index.CeiIiXap.js +1 -0
  103. streamlit/static/static/js/index.CgZDfhN4.js +2 -0
  104. streamlit/static/static/js/{index.xfcNJBLM.js → index.Cqa4gqqN.js} +1 -1
  105. streamlit/static/static/js/index.CzX2xpyc.js +1 -0
  106. streamlit/static/static/js/index.D1EayrNh.js +73 -0
  107. streamlit/static/static/js/index.D1ErX5go.js +2 -0
  108. streamlit/static/static/js/{index.CTT2YqEU.js → index.D1jHqUJq.js} +1 -1
  109. streamlit/static/static/js/index.D5gweoL5.js +7 -0
  110. streamlit/static/static/js/index.DByVKZgq.js +1 -0
  111. streamlit/static/static/js/index.DEND45D1.js +3 -0
  112. streamlit/static/static/js/{index.CbQtRkVt.js → index.DKN5MVff.js} +162 -188
  113. streamlit/static/static/js/index.DfoxW1gP.js +3855 -0
  114. streamlit/static/static/js/index.Dtf1Ac0x.js +1 -0
  115. streamlit/static/static/js/index.DxrLhpeO.js +1 -0
  116. streamlit/static/static/js/{index.BSFzxMXi.js → index.J7o-_HIh.js} +1 -1
  117. streamlit/static/static/js/index.LU8juINp.js +197 -0
  118. streamlit/static/static/js/index.L_N2iylt.js +1 -0
  119. streamlit/static/static/js/{index.BscWuWHL.js → index.PZUX2kRz.js} +3 -3
  120. streamlit/static/static/js/index.ROjU6K0k.js +1 -0
  121. streamlit/static/static/js/index.WSNLkF94.js +1 -0
  122. streamlit/static/static/js/index.X5W3gJLn.js +1 -0
  123. streamlit/static/static/js/index.k9LYqfSL.js +1 -0
  124. streamlit/static/static/js/{index.D3wOJJsg.js → index.pnHtHv_c.js} +12 -12
  125. streamlit/static/static/js/index.tPUXqsfW.js +1 -0
  126. streamlit/static/static/js/index.tsvTLdio.js +12 -0
  127. streamlit/static/static/js/{input.D_45B0P-.js → input.DZd6EQlV.js} +2 -2
  128. streamlit/static/static/js/{memory.BmhrRyO2.js → memory.ptkfuI71.js} +1 -1
  129. streamlit/static/static/js/{mergeWith.DvOME7eH.js → mergeWith.GRNk8iwv.js} +1 -1
  130. streamlit/static/static/js/{number-overlay-editor.BRNxOzEZ.js → number-overlay-editor.DXS2qb1U.js} +1 -1
  131. streamlit/static/static/js/{possibleConstructorReturn.C5GiK_Ob.js → possibleConstructorReturn.Bd4ImlQ9.js} +1 -1
  132. streamlit/static/static/js/{sandbox.B-Q9S7vW.js → sandbox.DsH8LuID.js} +1 -1
  133. streamlit/static/static/js/{timepicker.DOMbfm_a.js → timepicker.QVekV78C.js} +1 -1
  134. streamlit/static/static/js/{toConsumableArray.CbNz0Ciu.js → toConsumableArray.BJvaP8gb.js} +1 -1
  135. streamlit/static/static/js/{uniqueId.-ygIU7IL.js → uniqueId.D_5M8Dgf.js} +1 -1
  136. streamlit/static/static/js/{useBasicWidgetState.Bx3VaRHk.js → useBasicWidgetState.DB3vMS9V.js} +1 -1
  137. streamlit/static/static/js/useTextInputAutoExpand.CBkGkaRt.js +2 -0
  138. streamlit/static/static/js/useUpdateUiValue.C7ZKpLQK.js +1 -0
  139. streamlit/static/static/js/withFullScreenWrapper.C-gXt0Rl.js +1 -0
  140. streamlit/temporary_directory.py +5 -3
  141. streamlit/testing/v1/app_test.py +4 -1
  142. streamlit/testing/v1/element_tree.py +4 -5
  143. streamlit/type_util.py +10 -3
  144. streamlit/user_info.py +6 -1
  145. streamlit/util.py +11 -1
  146. streamlit/watcher/local_sources_watcher.py +4 -3
  147. streamlit/web/bootstrap.py +18 -12
  148. streamlit/web/cli.py +2 -1
  149. streamlit/web/server/server.py +72 -21
  150. {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/METADATA +14 -2
  151. {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/RECORD +155 -155
  152. streamlit/static/static/css/index.CsLB_Bnz.css +0 -1
  153. streamlit/static/static/js/ProgressBar.EhJ_lCOf.js +0 -2
  154. streamlit/static/static/js/RenderInPortalIfExists.D6a0mMll.js +0 -1
  155. streamlit/static/static/js/Toolbar.D6yqQ65-.js +0 -1
  156. streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +0 -1
  157. streamlit/static/static/js/data-grid-overlay-editor.CoquyZNK.js +0 -1
  158. streamlit/static/static/js/index.B3n-pURl.js +0 -2
  159. streamlit/static/static/js/index.B9jJp9aE.js +0 -1
  160. streamlit/static/static/js/index.BBVtld-D.js +0 -1
  161. streamlit/static/static/js/index.BKHPnvYd.js +0 -1
  162. streamlit/static/static/js/index.B_1CXynz.js +0 -1
  163. streamlit/static/static/js/index.Bm1LklYO.js +0 -1
  164. streamlit/static/static/js/index.Byi6__iF.js +0 -1
  165. streamlit/static/static/js/index.BzJeMpQ-.js +0 -197
  166. streamlit/static/static/js/index.C4tw7-Cl.js +0 -2
  167. streamlit/static/static/js/index.CG0C49ex.js +0 -1
  168. streamlit/static/static/js/index.CMuSJPv-.js +0 -1
  169. streamlit/static/static/js/index.COPFcr_K.js +0 -3855
  170. streamlit/static/static/js/index.CU3TLDlu.js +0 -1
  171. streamlit/static/static/js/index.CVKKDwaf.js +0 -1
  172. streamlit/static/static/js/index.CWZeK3mV.js +0 -12
  173. streamlit/static/static/js/index.CWbiNJQl.js +0 -1
  174. streamlit/static/static/js/index.CWxefYP6.js +0 -73
  175. streamlit/static/static/js/index.DOdWa88b.js +0 -1
  176. streamlit/static/static/js/index.DXtnaPua.js +0 -1
  177. streamlit/static/static/js/index.DatDwFl3.js +0 -3
  178. streamlit/static/static/js/index.DeWYPvQR.js +0 -1
  179. streamlit/static/static/js/index.Do4vzIvK.js +0 -1
  180. streamlit/static/static/js/index.Dvrstlh8.js +0 -1
  181. streamlit/static/static/js/index.DvznfdF_.js +0 -1
  182. streamlit/static/static/js/index.U1vvXeGn.js +0 -1
  183. streamlit/static/static/js/index._WAuWRkp.js +0 -7
  184. streamlit/static/static/js/index.bwA9_eWC.js +0 -1
  185. streamlit/static/static/js/index.m1njXuKl.js +0 -1
  186. streamlit/static/static/js/index.mihWZKb1.js +0 -1
  187. streamlit/static/static/js/useOnInputChange.CDZx-L6q.js +0 -1
  188. streamlit/static/static/js/useTextInputAutoExpand.BuE9l5TG.js +0 -2
  189. streamlit/static/static/js/withFullScreenWrapper.DWXejOhQ.js +0 -1
  190. {streamlit-1.47.1.data → streamlit-1.48.1.data}/scripts/streamlit.cmd +0 -0
  191. {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/WHEEL +0 -0
  192. {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/entry_points.txt +0 -0
  193. {streamlit-1.47.1.dist-info → streamlit-1.48.1.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 StreamlitInvalidHeightError, StreamlitInvalidWidthError
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:
@@ -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
- # If form_id is provided, add it to the kwargs.
232
- kwargs_to_use = {"form_id": form_id, **kwargs} if form_id else kwargs
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, element_type, element_id)
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 numpy as np
192
+ >>> import streamlit as st
193
+ >>> from numpy.random import default_rng as rng
194
194
  >>>
195
195
  >>> df = pd.DataFrame(
196
- ... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
197
- ... columns=["lat", "lon"],
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 numpy as np
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": np.random.randn(1000) / 50 + 37.76,
220
- ... "col2": np.random.randn(1000) / 50 + -122.4,
221
- ... "col3": np.random.randn(1000) * 100,
222
- ... "col4": np.random.rand(1000, 4).tolist(),
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() # iris is a pandas DataFrame
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 Chart**
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
- >>> # Add histogram data
441
- >>> x1 = np.random.randn(200) - 2
442
- >>> x2 = np.random.randn(200)
443
- >>> x3 = np.random.randn(200) + 2
444
- >>>
445
- >>> # Group data together
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
- ... hist_data, group_labels, bin_size=[.1, .25, .5])
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(
@@ -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 numpy as np
87
+ >>> import streamlit as st
88
+ >>> from numpy.random import default_rng as rng
85
89
  >>>
86
- >>> arr = np.random.normal(1, 1, size=100)
90
+ >>> arr = rng(0).normal(1, 1, size=100)
87
91
  >>> fig, ax = plt.subplots()
88
92
  >>> ax.hist(arr, bins=20)
89
93
  >>>