streamlit-nightly 1.34.1.dev20240522__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/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/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/web/server/browser_websocket_handler.py +8 -4
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/RECORD +20 -20
- {streamlit_nightly-1.34.1.dev20240522.data → streamlit_nightly-1.35.1.dev20240523.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.34.1.dev20240522.dist-info → streamlit_nightly-1.35.1.dev20240523.dist-info}/top_level.txt +0 -0
@@ -80,18 +80,24 @@ _SELECTION_MODES: Final[set[SelectionMode]] = {"lasso", "points", "box"}
|
|
80
80
|
|
81
81
|
class PlotlySelectionState(TypedDict, total=False):
|
82
82
|
"""
|
83
|
-
|
83
|
+
The schema for the Plotly chart selection state.
|
84
|
+
|
85
|
+
The selection state is stored in a dictionary-like object that suports both
|
86
|
+
key and attribute notation. Selection states cannot be programmatically
|
87
|
+
changed or set through Session State.
|
84
88
|
|
85
89
|
Attributes
|
86
90
|
----------
|
87
91
|
points : list[dict[str, Any]]
|
88
|
-
The selected data points in the chart,
|
89
|
-
|
92
|
+
The selected data points in the chart, including the data points
|
93
|
+
selected by the box and lasso mode. The data includes the values
|
94
|
+
associated to each point and a point index used to populate
|
95
|
+
``point_indices``. If additional information has been assigned to your
|
96
|
+
points, such as size or legend group, this is also included.
|
90
97
|
|
91
98
|
point_indices : list[int]
|
92
|
-
The numerical indices of all selected data points in the chart
|
93
|
-
|
94
|
-
and lasso mode.
|
99
|
+
The numerical indices of all selected data points in the chart. The
|
100
|
+
details of each identified point are included in ``points``.
|
95
101
|
|
96
102
|
box : list[dict[str, Any]]
|
97
103
|
The metadata related to the box selection. This includes the
|
@@ -100,6 +106,58 @@ class PlotlySelectionState(TypedDict, total=False):
|
|
100
106
|
lasso : list[dict[str, Any]]
|
101
107
|
The metadata related to the lasso selection. This includes the
|
102
108
|
coordinates of the selected area.
|
109
|
+
|
110
|
+
Example
|
111
|
+
-------
|
112
|
+
When working with more complicated graphs, the ``points`` attribute
|
113
|
+
displays additional information. Try selecting points in the following
|
114
|
+
example:
|
115
|
+
|
116
|
+
>>> import streamlit as st
|
117
|
+
>>> import plotly.express as px
|
118
|
+
>>>
|
119
|
+
>>> df = px.data.iris()
|
120
|
+
>>> fig = px.scatter(
|
121
|
+
... df,
|
122
|
+
... x="sepal_width",
|
123
|
+
... y="sepal_length",
|
124
|
+
... color="species",
|
125
|
+
... size="petal_length",
|
126
|
+
... hover_data=["petal_width"],
|
127
|
+
... )
|
128
|
+
>>>
|
129
|
+
>>> event = st.plotly_chart(fig, key="iris", on_select="rerun")
|
130
|
+
>>>
|
131
|
+
>>> event.selection
|
132
|
+
|
133
|
+
.. output::
|
134
|
+
https://doc-chart-events-plotly-selection-state.streamlit.app
|
135
|
+
height: 600px
|
136
|
+
|
137
|
+
This is an example of the selection state when selecting a single point:
|
138
|
+
|
139
|
+
>>> {
|
140
|
+
>>> "points": [
|
141
|
+
>>> {
|
142
|
+
>>> "curve_number": 2,
|
143
|
+
>>> "point_number": 9,
|
144
|
+
>>> "point_index": 9,
|
145
|
+
>>> "x": 3.6,
|
146
|
+
>>> "y": 7.2,
|
147
|
+
>>> "customdata": [
|
148
|
+
>>> 2.5
|
149
|
+
>>> ],
|
150
|
+
>>> "marker_size": 6.1,
|
151
|
+
>>> "legendgroup": "virginica"
|
152
|
+
>>> }
|
153
|
+
>>> ],
|
154
|
+
>>> "point_indices": [
|
155
|
+
>>> 9
|
156
|
+
>>> ],
|
157
|
+
>>> "box": [],
|
158
|
+
>>> "lasso": []
|
159
|
+
>>> }
|
160
|
+
|
103
161
|
"""
|
104
162
|
|
105
163
|
points: list[dict[str, Any]]
|
@@ -110,12 +168,39 @@ class PlotlySelectionState(TypedDict, total=False):
|
|
110
168
|
|
111
169
|
class PlotlyState(TypedDict, total=False):
|
112
170
|
"""
|
113
|
-
|
171
|
+
The schema for the Plotly chart event state.
|
172
|
+
|
173
|
+
The event state is stored in a dictionary-like object that suports both
|
174
|
+
key and attribute notation. Event states cannot be programmatically
|
175
|
+
changed or set through Session State.
|
176
|
+
|
177
|
+
Only selection events are supported at this time.
|
114
178
|
|
115
179
|
Attributes
|
116
180
|
----------
|
117
181
|
selection : PlotlySelectionState
|
118
|
-
The state of the
|
182
|
+
The state of the ``on_select`` event.
|
183
|
+
|
184
|
+
Example
|
185
|
+
-------
|
186
|
+
Try selecting points by any of the three available methods (direct click,
|
187
|
+
box, or lasso). The current selection state is available through Session
|
188
|
+
State or as the output of the chart function.
|
189
|
+
|
190
|
+
>>> import streamlit as st
|
191
|
+
>>> import plotly.express as px
|
192
|
+
>>>
|
193
|
+
>>> df = px.data.iris() # iris is a pandas DataFrame
|
194
|
+
>>> fig = px.scatter(df, x="sepal_width", y="sepal_length")
|
195
|
+
>>>
|
196
|
+
>>> event = st.plotly_chart(fig, key="iris", on_select="rerun")
|
197
|
+
>>>
|
198
|
+
>>> event
|
199
|
+
|
200
|
+
.. output::
|
201
|
+
https://doc-chart-events-plotly-state.streamlit.app
|
202
|
+
height: 600px
|
203
|
+
|
119
204
|
"""
|
120
205
|
|
121
206
|
selection: PlotlySelectionState
|
@@ -224,58 +309,92 @@ class PlotlyMixin:
|
|
224
309
|
) -> DeltaGenerator | PlotlyState:
|
225
310
|
"""Display an interactive Plotly chart.
|
226
311
|
|
227
|
-
Plotly is a charting library for Python.
|
228
|
-
closely follow the ones for Plotly's
|
229
|
-
|
312
|
+
`Plotly <https://plot.ly/python>`_ is a charting library for Python.
|
313
|
+
The arguments to this function closely follow the ones for Plotly's
|
314
|
+
``plot()`` function.
|
230
315
|
|
231
|
-
To show Plotly charts in Streamlit, call
|
232
|
-
would call Plotly's
|
316
|
+
To show Plotly charts in Streamlit, call ``st.plotly_chart`` wherever
|
317
|
+
you would call Plotly's ``py.plot`` or ``py.iplot``.
|
233
318
|
|
234
319
|
Parameters
|
235
320
|
----------
|
236
321
|
figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data,\
|
237
|
-
dict/list of plotly.graph_objs.Figure/Data
|
322
|
+
or dict/list of plotly.graph_objs.Figure/Data
|
238
323
|
|
239
|
-
|
324
|
+
The Plotly ``Figure`` or ``Data`` object to render. See
|
325
|
+
https://plot.ly/python/ for examples of graph descriptions.
|
240
326
|
|
241
327
|
use_container_width : bool
|
242
|
-
|
243
|
-
|
328
|
+
Whether to override the figure's native width with the width of
|
329
|
+
the parent container. If ``use_container_width`` is ``False``
|
330
|
+
(default), Streamlit sets the width of the chart to fit its contents
|
331
|
+
according to the plotting library, up to the width of the parent
|
332
|
+
container. If ``use_container_width`` is ``True``, Streamlit sets
|
333
|
+
the width of the figure to match the width of the parent container.
|
244
334
|
|
245
335
|
theme : "streamlit" or None
|
246
|
-
The theme of the chart.
|
247
|
-
|
336
|
+
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
|
337
|
+
Streamlit uses its own design default. If ``theme`` is ``None``,
|
338
|
+
Streamlit falls back to the default behavior of the library.
|
248
339
|
|
249
340
|
key : str
|
250
|
-
An optional string to use
|
251
|
-
|
252
|
-
|
341
|
+
An optional string to use for giving this element a stable
|
342
|
+
identity. If ``key`` is ``None`` (default), this element's identity
|
343
|
+
will be determined based on the values of the other parameters.
|
344
|
+
|
345
|
+
Additionally, if selections are activated and ``key`` is provided,
|
346
|
+
Streamlit will register the key in Session State to store the
|
347
|
+
selection state. The selection state is read-only.
|
253
348
|
|
254
349
|
on_select : "ignore" or "rerun" or callable
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
-
|
268
|
-
|
350
|
+
How the figure should respond to user selection events. This
|
351
|
+
controls whether or not the figure behaves like an input widget.
|
352
|
+
``on_select`` can be one of the following:
|
353
|
+
|
354
|
+
- ``"ignore"`` (default): Streamlit will not react to any selection
|
355
|
+
events in the chart. The figure will not behave like an input
|
356
|
+
widget.
|
357
|
+
|
358
|
+
- ``"rerun"``: Streamlit will rerun the app when the user selects
|
359
|
+
data in the chart. In this case, ``st.plotly_chart`` will return
|
360
|
+
the selection data as a dictionary.
|
361
|
+
|
362
|
+
- A ``callable``: Streamlit will rerun the app and execute the
|
363
|
+
``callable`` as a callback function before the rest of the app.
|
364
|
+
In this case, ``st.plotly_chart`` will return the selection data
|
365
|
+
as a dictionary.
|
366
|
+
|
367
|
+
selection_mode : "points", "box", "lasso" or an Iterable of these
|
368
|
+
The selection mode of the chart. This can be one of the following:
|
369
|
+
|
370
|
+
- ``"points"``: The chart will allow selections based on individual
|
371
|
+
data points.
|
372
|
+
- ``"box"``: The chart will allow selections based on rectangular
|
373
|
+
areas.
|
374
|
+
- ``"lasso"``: The chart will allow selections based on freeform
|
375
|
+
areas.
|
376
|
+
- An ``Iterable`` of the above options: The chart will allow
|
377
|
+
selections based on the modes specified.
|
269
378
|
|
270
379
|
All selections modes are activated by default.
|
271
380
|
|
272
381
|
**kwargs
|
273
|
-
Any argument accepted by Plotly's
|
382
|
+
Any argument accepted by Plotly's ``plot()`` function.
|
383
|
+
|
384
|
+
Returns
|
385
|
+
-------
|
386
|
+
element or dict
|
387
|
+
If ``on_select`` is ``"ignore"`` (default), this method returns an
|
388
|
+
internal placeholder for the chart element. Otherwise, this method
|
389
|
+
returns a dictionary-like object that supports both key and
|
390
|
+
attribute notation. The attributes are described by the
|
391
|
+
``PlotlyState`` dictionary schema.
|
274
392
|
|
275
393
|
Example
|
276
394
|
-------
|
277
395
|
The example below comes straight from the examples at
|
278
|
-
https://plot.ly/python
|
396
|
+
https://plot.ly/python. Note that ``plotly.figure_factory`` requires
|
397
|
+
``scipy`` to run.
|
279
398
|
|
280
399
|
>>> import streamlit as st
|
281
400
|
>>> import numpy as np
|
@@ -300,7 +419,7 @@ class PlotlyMixin:
|
|
300
419
|
|
301
420
|
.. output::
|
302
421
|
https://doc-plotly-chart.streamlit.app/
|
303
|
-
height:
|
422
|
+
height: 550px
|
304
423
|
|
305
424
|
"""
|
306
425
|
import plotly.io
|
streamlit/elements/pyplot.py
CHANGED
@@ -52,15 +52,20 @@ class PyplotMixin:
|
|
52
52
|
clear_figure : bool
|
53
53
|
If True, the figure will be cleared after being rendered.
|
54
54
|
If False, the figure will not be cleared after being rendered.
|
55
|
-
If left unspecified, we pick a default based on the value of
|
55
|
+
If left unspecified, we pick a default based on the value of ``fig``.
|
56
56
|
|
57
|
-
* If
|
57
|
+
* If ``fig`` is set, defaults to ``False``.
|
58
58
|
|
59
|
-
* If
|
59
|
+
* If ``fig`` is not set, defaults to ``True``. This simulates Jupyter's
|
60
60
|
approach to matplotlib rendering.
|
61
61
|
|
62
62
|
use_container_width : bool
|
63
|
-
|
63
|
+
Whether to override the figure's native width with the width of
|
64
|
+
the parent container. If ``use_container_width`` is ``False``
|
65
|
+
(default), Streamlit sets the width of the chart to fit its contents
|
66
|
+
according to the plotting library, up to the width of the parent
|
67
|
+
container. If ``use_container_width`` is ``True``, Streamlit sets
|
68
|
+
the width of the figure to match the width of the parent container.
|
64
69
|
|
65
70
|
**kwargs : any
|
66
71
|
Arguments to pass to Matplotlib's savefig function.
|