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
@@ -97,11 +97,110 @@ VegaLiteSpec: TypeAlias = "dict[str, Any]"
|
|
97
97
|
|
98
98
|
class VegaLiteState(TypedDict, total=False):
|
99
99
|
"""
|
100
|
-
|
100
|
+
The schema for the Vega-Lite event state.
|
101
|
+
|
102
|
+
The event state is stored in a dictionary-like object that suports both
|
103
|
+
key and attribute notation. Event states cannot be programmatically
|
104
|
+
changed or set through Session State.
|
105
|
+
|
106
|
+
Only selection events are supported at this time.
|
107
|
+
|
101
108
|
Attributes
|
102
109
|
----------
|
103
110
|
selection : AttributeDictionary
|
104
|
-
The state of the
|
111
|
+
The state of the ``on_select`` event. The name of each selection
|
112
|
+
parameter becomes an attribute in the ``selection`` attribute
|
113
|
+
dictionary. The format of the data within each attribute is determined
|
114
|
+
by the selection parameter definition within Vega-Lite.
|
115
|
+
|
116
|
+
Examples
|
117
|
+
--------
|
118
|
+
The following two examples have equivalent definitions. Each one has a
|
119
|
+
point and interval selection parameter include in the chart definition.
|
120
|
+
The point seleciton parameter is named ``"point_selection"``. The interval
|
121
|
+
or box selection parameter is named ``"interval_selection"``.
|
122
|
+
|
123
|
+
The follow example uses ``st.altair_chart``:
|
124
|
+
|
125
|
+
>>> import streamlit as st
|
126
|
+
>>> import pandas as pd
|
127
|
+
>>> import numpy as np
|
128
|
+
>>> import altair as alt
|
129
|
+
>>>
|
130
|
+
>>> if "data" not in st.session_state:
|
131
|
+
>>> st.session_state.data = pd.DataFrame(
|
132
|
+
... np.random.randn(20, 3), columns=["a", "b", "c"]
|
133
|
+
... )
|
134
|
+
>>> df = st.session_state.data
|
135
|
+
>>>
|
136
|
+
>>> point_selector = alt.selection_point("point_selection")
|
137
|
+
>>> interval_selector = alt.selection_interval("interval_selection")
|
138
|
+
>>> chart = (
|
139
|
+
... alt.Chart(df)
|
140
|
+
... .mark_circle()
|
141
|
+
... .encode(
|
142
|
+
... x="a",
|
143
|
+
... y="b",
|
144
|
+
... size="c",
|
145
|
+
... color="c",
|
146
|
+
... tooltip=["a", "b", "c"],
|
147
|
+
... fillOpacity=alt.condition(point_selector, alt.value(1), alt.value(0.3)),
|
148
|
+
... )
|
149
|
+
... .add_params(point_selector, interval_selector)
|
150
|
+
... )
|
151
|
+
>>>
|
152
|
+
>>> event = st.altair_chart(chart, key="alt_chart", on_select="rerun")
|
153
|
+
>>>
|
154
|
+
>>> event
|
155
|
+
|
156
|
+
The following example uses ``st.vega_lite_chart``:
|
157
|
+
|
158
|
+
>>> import streamlit as st
|
159
|
+
>>> import pandas as pd
|
160
|
+
>>> import numpy as np
|
161
|
+
>>>
|
162
|
+
>>> if "data" not in st.session_state:
|
163
|
+
>>> st.session_state.data = pd.DataFrame(
|
164
|
+
... np.random.randn(20, 3), columns=["a", "b", "c"]
|
165
|
+
... )
|
166
|
+
>>>
|
167
|
+
>>> spec = {
|
168
|
+
... "mark": {"type": "circle", "tooltip": True},
|
169
|
+
... "params": [
|
170
|
+
... {"name": "interval_selection", "select": "interval"},
|
171
|
+
... {"name": "point_selection", "select": "point"},
|
172
|
+
... ],
|
173
|
+
... "encoding": {
|
174
|
+
... "x": {"field": "a", "type": "quantitative"},
|
175
|
+
... "y": {"field": "b", "type": "quantitative"},
|
176
|
+
... "size": {"field": "c", "type": "quantitative"},
|
177
|
+
... "color": {"field": "c", "type": "quantitative"},
|
178
|
+
... "fillOpacity": {
|
179
|
+
... "condition": {"param": "point_selection", "value": 1},
|
180
|
+
... "value": 0.3,
|
181
|
+
... },
|
182
|
+
... },
|
183
|
+
... }
|
184
|
+
>>>
|
185
|
+
>>> event = st.vega_lite_chart(st.session_state.data, spec, key="vega_chart", on_select="rerun")
|
186
|
+
>>>
|
187
|
+
>>> event
|
188
|
+
|
189
|
+
Try selecting points in this interactive example. When you click a point,
|
190
|
+
the selection will appear under the attribute, ``"point_selection"``, which
|
191
|
+
is the name given to the point selection parameter. Similarly, when you
|
192
|
+
make an interval selection, it will appear under the attribute
|
193
|
+
``"interval_selection"``. You can give your selection parameters other
|
194
|
+
names if desired.
|
195
|
+
|
196
|
+
If you hold ``Shift`` while selecting points, existing point selections
|
197
|
+
will be preserved. Interval selections are not preserved when making
|
198
|
+
additional selections.
|
199
|
+
|
200
|
+
.. output::
|
201
|
+
https://doc-chart-events-vega-lite-state.streamlit.app
|
202
|
+
height: 600px
|
203
|
+
|
105
204
|
"""
|
106
205
|
|
107
206
|
selection: AttributeDictionary
|
@@ -461,16 +560,16 @@ class VegaChartsMixin:
|
|
461
560
|
x: str | None = None,
|
462
561
|
y: str | Sequence[str] | None = None,
|
463
562
|
color: str | Color | list[Color] | None = None,
|
464
|
-
width: int =
|
465
|
-
height: int =
|
563
|
+
width: int | None = None,
|
564
|
+
height: int | None = None,
|
466
565
|
use_container_width: bool = True,
|
467
566
|
) -> DeltaGenerator:
|
468
567
|
"""Display a line chart.
|
469
568
|
|
470
569
|
This is syntax-sugar around ``st.altair_chart``. The main difference
|
471
570
|
is this command uses the data's own column and indices to figure out
|
472
|
-
the chart's spec. As a result this is easier to use for many
|
473
|
-
this" scenarios, while being less customizable.
|
571
|
+
the chart's Altair spec. As a result this is easier to use for many
|
572
|
+
"just plot this" scenarios, while being less customizable.
|
474
573
|
|
475
574
|
If ``st.line_chart`` does not guess the data specification
|
476
575
|
correctly, try specifying your desired chart using ``st.altair_chart``.
|
@@ -529,15 +628,25 @@ class VegaChartsMixin:
|
|
529
628
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
530
629
|
for three lines).
|
531
630
|
|
532
|
-
width : int
|
533
|
-
|
631
|
+
width : int or None
|
632
|
+
Desired width of the chart expressed in pixels. If ``width`` is
|
633
|
+
``None`` (default), Streamlit sets the width of the chart to fit
|
634
|
+
its contents according to the plotting library, up to the width of
|
635
|
+
the parent container. If ``width`` is greater than the width of the
|
636
|
+
parent container, Streamlit sets the chart width to match the width
|
637
|
+
of the parent container.
|
534
638
|
|
535
|
-
height : int
|
536
|
-
|
639
|
+
height : int or None
|
640
|
+
Desired height of the chart expressed in pixels. If ``height`` is
|
641
|
+
``None`` (default), Streamlit sets the height of the chart to fit
|
642
|
+
its contents according to the plotting library.
|
537
643
|
|
538
644
|
use_container_width : bool
|
539
|
-
|
540
|
-
|
645
|
+
Whether to override ``width`` with the width of the parent
|
646
|
+
container. If ``use_container_width`` is ``False`` (default),
|
647
|
+
Streamlit sets the chart's width according to ``width``. If
|
648
|
+
``use_container_width`` is ``True``, Streamlit sets the width of
|
649
|
+
the chart to match the width of the parent container.
|
541
650
|
|
542
651
|
Examples
|
543
652
|
--------
|
@@ -623,16 +732,16 @@ class VegaChartsMixin:
|
|
623
732
|
x: str | None = None,
|
624
733
|
y: str | Sequence[str] | None = None,
|
625
734
|
color: str | Color | list[Color] | None = None,
|
626
|
-
width: int =
|
627
|
-
height: int =
|
735
|
+
width: int | None = None,
|
736
|
+
height: int | None = None,
|
628
737
|
use_container_width: bool = True,
|
629
738
|
) -> DeltaGenerator:
|
630
739
|
"""Display an area chart.
|
631
740
|
|
632
741
|
This is syntax-sugar around ``st.altair_chart``. The main difference
|
633
742
|
is this command uses the data's own column and indices to figure out
|
634
|
-
the chart's spec. As a result this is easier to use for many
|
635
|
-
this" scenarios, while being less customizable.
|
743
|
+
the chart's Altair spec. As a result this is easier to use for many
|
744
|
+
"just plot this" scenarios, while being less customizable.
|
636
745
|
|
637
746
|
If ``st.area_chart`` does not guess the data specification
|
638
747
|
correctly, try specifying your desired chart using ``st.altair_chart``.
|
@@ -691,15 +800,25 @@ class VegaChartsMixin:
|
|
691
800
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
692
801
|
for three lines).
|
693
802
|
|
694
|
-
width : int
|
695
|
-
|
803
|
+
width : int or None
|
804
|
+
Desired width of the chart expressed in pixels. If ``width`` is
|
805
|
+
``None`` (default), Streamlit sets the width of the chart to fit
|
806
|
+
its contents according to the plotting library, up to the width of
|
807
|
+
the parent container. If ``width`` is greater than the width of the
|
808
|
+
parent container, Streamlit sets the chart width to match the width
|
809
|
+
of the parent container.
|
696
810
|
|
697
|
-
height : int
|
698
|
-
|
811
|
+
height : int or None
|
812
|
+
Desired height of the chart expressed in pixels. If ``height`` is
|
813
|
+
``None`` (default), Streamlit sets the height of the chart to fit
|
814
|
+
its contents according to the plotting library.
|
699
815
|
|
700
816
|
use_container_width : bool
|
701
|
-
|
702
|
-
|
817
|
+
Whether to override ``width`` with the width of the parent
|
818
|
+
container. If ``use_container_width`` is ``False`` (default),
|
819
|
+
Streamlit sets the chart's width according to ``width``. If
|
820
|
+
``use_container_width`` is ``True``, Streamlit sets the width of
|
821
|
+
the chart to match the width of the parent container.
|
703
822
|
|
704
823
|
Examples
|
705
824
|
--------
|
@@ -785,16 +904,16 @@ class VegaChartsMixin:
|
|
785
904
|
x: str | None = None,
|
786
905
|
y: str | Sequence[str] | None = None,
|
787
906
|
color: str | Color | list[Color] | None = None,
|
788
|
-
width: int =
|
789
|
-
height: int =
|
907
|
+
width: int | None = None,
|
908
|
+
height: int | None = None,
|
790
909
|
use_container_width: bool = True,
|
791
910
|
) -> DeltaGenerator:
|
792
911
|
"""Display a bar chart.
|
793
912
|
|
794
913
|
This is syntax-sugar around ``st.altair_chart``. The main difference
|
795
914
|
is this command uses the data's own column and indices to figure out
|
796
|
-
the chart's spec. As a result this is easier to use for many
|
797
|
-
this" scenarios, while being less customizable.
|
915
|
+
the chart's Altair spec. As a result this is easier to use for many
|
916
|
+
"just plot this" scenarios, while being less customizable.
|
798
917
|
|
799
918
|
If ``st.bar_chart`` does not guess the data specification
|
800
919
|
correctly, try specifying your desired chart using ``st.altair_chart``.
|
@@ -853,15 +972,25 @@ class VegaChartsMixin:
|
|
853
972
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
854
973
|
for three lines).
|
855
974
|
|
856
|
-
width : int
|
857
|
-
|
975
|
+
width : int or None
|
976
|
+
Desired width of the chart expressed in pixels. If ``width`` is
|
977
|
+
``None`` (default), Streamlit sets the width of the chart to fit
|
978
|
+
its contents according to the plotting library, up to the width of
|
979
|
+
the parent container. If ``width`` is greater than the width of the
|
980
|
+
parent container, Streamlit sets the chart width to match the width
|
981
|
+
of the parent container.
|
858
982
|
|
859
|
-
height : int
|
860
|
-
|
983
|
+
height : int or None
|
984
|
+
Desired height of the chart expressed in pixels. If ``height`` is
|
985
|
+
``None`` (default), Streamlit sets the height of the chart to fit
|
986
|
+
its contents according to the plotting library.
|
861
987
|
|
862
988
|
use_container_width : bool
|
863
|
-
|
864
|
-
|
989
|
+
Whether to override ``width`` with the width of the parent
|
990
|
+
container. If ``use_container_width`` is ``False`` (default),
|
991
|
+
Streamlit sets the chart's width according to ``width``. If
|
992
|
+
``use_container_width`` is ``True``, Streamlit sets the width of
|
993
|
+
the chart to match the width of the parent container.
|
865
994
|
|
866
995
|
Examples
|
867
996
|
--------
|
@@ -950,16 +1079,16 @@ class VegaChartsMixin:
|
|
950
1079
|
y: str | Sequence[str] | None = None,
|
951
1080
|
color: str | Color | list[Color] | None = None,
|
952
1081
|
size: str | float | int | None = None,
|
953
|
-
width: int =
|
954
|
-
height: int =
|
1082
|
+
width: int | None = None,
|
1083
|
+
height: int | None = None,
|
955
1084
|
use_container_width: bool = True,
|
956
1085
|
) -> DeltaGenerator:
|
957
1086
|
"""Display a scatterplot chart.
|
958
1087
|
|
959
1088
|
This is syntax-sugar around ``st.altair_chart``. The main difference
|
960
1089
|
is this command uses the data's own column and indices to figure out
|
961
|
-
the chart's spec. As a result this is easier to use for many
|
962
|
-
this" scenarios, while being less customizable.
|
1090
|
+
the chart's Altair spec. As a result this is easier to use for many
|
1091
|
+
"just plot this" scenarios, while being less customizable.
|
963
1092
|
|
964
1093
|
If ``st.scatter_chart`` does not guess the data specification correctly,
|
965
1094
|
try specifying your desired chart using ``st.altair_chart``.
|
@@ -1027,15 +1156,25 @@ class VegaChartsMixin:
|
|
1027
1156
|
* The name of the column to use for the size. This allows each
|
1028
1157
|
datapoint to be represented by a circle of a different size.
|
1029
1158
|
|
1030
|
-
width : int
|
1031
|
-
|
1159
|
+
width : int or None
|
1160
|
+
Desired width of the chart expressed in pixels. If ``width`` is
|
1161
|
+
``None`` (default), Streamlit sets the width of the chart to fit
|
1162
|
+
its contents according to the plotting library, up to the width of
|
1163
|
+
the parent container. If ``width`` is greater than the width of the
|
1164
|
+
parent container, Streamlit sets the chart width to match the width
|
1165
|
+
of the parent container.
|
1032
1166
|
|
1033
|
-
height : int
|
1034
|
-
|
1167
|
+
height : int or None
|
1168
|
+
Desired height of the chart expressed in pixels. If ``height`` is
|
1169
|
+
``None`` (default), Streamlit sets the height of the chart to fit
|
1170
|
+
its contents according to the plotting library.
|
1035
1171
|
|
1036
1172
|
use_container_width : bool
|
1037
|
-
|
1038
|
-
|
1173
|
+
Whether to override ``width`` with the width of the parent
|
1174
|
+
container. If ``use_container_width`` is ``False`` (default),
|
1175
|
+
Streamlit sets the chart's width according to ``width``. If
|
1176
|
+
``use_container_width`` is ``True``, Streamlit sets the width of
|
1177
|
+
the chart to match the width of the parent container.
|
1039
1178
|
|
1040
1179
|
Examples
|
1041
1180
|
--------
|
@@ -1155,34 +1294,88 @@ class VegaChartsMixin:
|
|
1155
1294
|
on_select: Literal["rerun", "ignore"] | WidgetCallback = "ignore",
|
1156
1295
|
selection_mode: str | Iterable[str] | None = None,
|
1157
1296
|
) -> DeltaGenerator | VegaLiteState:
|
1158
|
-
"""Display a chart using the Altair library.
|
1297
|
+
"""Display a chart using the Vega-Altair library.
|
1298
|
+
|
1299
|
+
`Vega-Altair <https://altair-viz.github.io/>`_ is a declarative
|
1300
|
+
statistical visualization library for Python, based on Vega and
|
1301
|
+
Vega-Lite.
|
1159
1302
|
|
1160
1303
|
Parameters
|
1161
1304
|
----------
|
1162
1305
|
altair_chart : altair.Chart
|
1163
|
-
The Altair chart object to display.
|
1306
|
+
The Altair chart object to display. See
|
1307
|
+
https://altair-viz.github.io/gallery/ for examples of graph
|
1308
|
+
descriptions.
|
1164
1309
|
|
1165
1310
|
use_container_width : bool
|
1166
|
-
|
1167
|
-
|
1311
|
+
Whether to override the figure's native width with the width of
|
1312
|
+
the parent container. If ``use_container_width`` is ``False``
|
1313
|
+
(default), Streamlit sets the width of the chart to fit its contents
|
1314
|
+
according to the plotting library, up to the width of the parent
|
1315
|
+
container. If ``use_container_width`` is ``True``, Streamlit sets
|
1316
|
+
the width of the figure to match the width of the parent container.
|
1168
1317
|
|
1169
1318
|
theme : "streamlit" or None
|
1170
|
-
The theme of the chart.
|
1171
|
-
|
1319
|
+
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
|
1320
|
+
Streamlit uses its own design default. If ``theme`` is ``None``,
|
1321
|
+
Streamlit falls back to the default behavior of the library.
|
1172
1322
|
|
1173
1323
|
key : str
|
1174
|
-
An optional string to use
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1324
|
+
An optional string to use for giving this element a stable
|
1325
|
+
identity. If ``key`` is ``None`` (default), this element's identity
|
1326
|
+
will be determined based on the values of the other parameters.
|
1327
|
+
|
1328
|
+
Additionally, if selections are activated and ``key`` is provided,
|
1329
|
+
Streamlit will register the key in Session State to store the
|
1330
|
+
selection state. The selection state is read-only.
|
1331
|
+
|
1332
|
+
on_select : "ignore", "rerun", or callable
|
1333
|
+
How the figure should respond to user selection events. This
|
1334
|
+
controls whether or not the figure behaves like an input widget.
|
1335
|
+
``on_select`` can be one of the following:
|
1336
|
+
|
1337
|
+
- ``"ignore"`` (default): Streamlit will not react to any selection
|
1338
|
+
events in the chart. The figure will not behave like an input
|
1339
|
+
widget.
|
1340
|
+
|
1341
|
+
- ``"rerun"``: Streamlit will rerun the app when the user selects
|
1342
|
+
data in the chart. In this case, ``st.altair_chart`` will return
|
1343
|
+
the selection data as a dictionary.
|
1344
|
+
|
1345
|
+
- A ``callable``: Streamlit will rerun the app and execute the
|
1346
|
+
``callable`` as a callback function before the rest of the app.
|
1347
|
+
In this case, ``st.altair_chart`` will return the selection data
|
1348
|
+
as a dictionary.
|
1349
|
+
|
1350
|
+
To use selection events, the object passed to ``altair_chart`` must
|
1351
|
+
include selection paramters. To learn about defining interactions
|
1352
|
+
in Altair and how to declare selection-type parameters, see
|
1353
|
+
`Interactive Charts \
|
1354
|
+
<https://altair-viz.github.io/user_guide/interactions.html>`_
|
1355
|
+
in Altair's documentation.
|
1356
|
+
|
1357
|
+
selection_mode : str or Iterable of str
|
1358
|
+
The selection parameters Streamlit should use. If
|
1359
|
+
``selection_mode`` is ``None`` (default), Streamlit will use all
|
1360
|
+
selection parameters defined in the chart's Altair spec.
|
1361
|
+
|
1362
|
+
When Streamlit uses a selection parameter, selections from that
|
1363
|
+
parameter will trigger a rerun and be included in the selection
|
1364
|
+
state. When Streamlit does not use a selection parameter,
|
1365
|
+
selections from that parameter will not trigger a rerun and not be
|
1366
|
+
included in the selection state.
|
1367
|
+
|
1368
|
+
Selection parameters are identified by their ``name`` property.
|
1369
|
+
|
1370
|
+
Returns
|
1371
|
+
-------
|
1372
|
+
element or dict
|
1373
|
+
If ``on_select`` is ``"ignore"`` (default), this method returns an
|
1374
|
+
internal placeholder for the chart element that can be used with
|
1375
|
+
the ``.add_rows()`` method. Otherwise, this method returns a
|
1376
|
+
dictionary-like object that supports both key and attribute
|
1377
|
+
notation. The attributes are described by the ``VegaLiteState``
|
1378
|
+
dictionary schema.
|
1186
1379
|
|
1187
1380
|
Example
|
1188
1381
|
-------
|
@@ -1204,10 +1397,7 @@ class VegaChartsMixin:
|
|
1204
1397
|
|
1205
1398
|
.. output::
|
1206
1399
|
https://doc-vega-lite-chart.streamlit.app/
|
1207
|
-
height:
|
1208
|
-
|
1209
|
-
Examples of Altair charts can be found at
|
1210
|
-
https://altair-viz.github.io/gallery/.
|
1400
|
+
height: 450px
|
1211
1401
|
|
1212
1402
|
"""
|
1213
1403
|
return self._altair_chart(
|
@@ -1264,6 +1454,9 @@ class VegaChartsMixin:
|
|
1264
1454
|
) -> DeltaGenerator | VegaLiteState:
|
1265
1455
|
"""Display a chart using the Vega-Lite library.
|
1266
1456
|
|
1457
|
+
`Vega-Lite <https://vega.github.io/vega-lite/>`_ is a high-level
|
1458
|
+
grammar for defining interactive graphics.
|
1459
|
+
|
1267
1460
|
Parameters
|
1268
1461
|
----------
|
1269
1462
|
data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, Iterable, dict, or None
|
@@ -1271,34 +1464,84 @@ class VegaChartsMixin:
|
|
1271
1464
|
data (which more closely follows the Vega-Lite API).
|
1272
1465
|
|
1273
1466
|
spec : dict or None
|
1274
|
-
The Vega-Lite spec for the chart. If
|
1275
|
-
the
|
1467
|
+
The Vega-Lite spec for the chart. If ``spec`` is ``None`` (default),
|
1468
|
+
Streamlit uses the spec passed in ``data``. You cannot pass a spec
|
1469
|
+
to both ``data`` and ``spec``. See
|
1276
1470
|
https://vega.github.io/vega-lite/docs/ for more info.
|
1277
1471
|
|
1278
1472
|
use_container_width : bool
|
1279
|
-
|
1280
|
-
|
1473
|
+
Whether to override the figure's native width with the width of
|
1474
|
+
the parent container. If ``use_container_width`` is ``False``
|
1475
|
+
(default), Streamlit sets the width of the chart to fit its contents
|
1476
|
+
according to the plotting library, up to the width of the parent
|
1477
|
+
container. If ``use_container_width`` is ``True``, Streamlit sets
|
1478
|
+
the width of the figure to match the width of the parent container.
|
1281
1479
|
|
1282
1480
|
theme : "streamlit" or None
|
1283
|
-
The theme of the chart.
|
1284
|
-
|
1481
|
+
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
|
1482
|
+
Streamlit uses its own design default. If ``theme`` is ``None``,
|
1483
|
+
Streamlit falls back to the default behavior of the library.
|
1285
1484
|
|
1286
1485
|
key : str
|
1287
|
-
An optional string to use
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1486
|
+
An optional string to use for giving this element a stable
|
1487
|
+
identity. If ``key`` is ``None`` (default), this element's identity
|
1488
|
+
will be determined based on the values of the other parameters.
|
1489
|
+
|
1490
|
+
Additionally, if selections are activated and ``key`` is provided,
|
1491
|
+
Streamlit will register the key in Session State to store the
|
1492
|
+
selection state. The selection state is read-only.
|
1493
|
+
|
1494
|
+
on_select : "ignore", "rerun", or callable
|
1495
|
+
How the figure should respond to user selection events. This
|
1496
|
+
controls whether or not the figure behaves like an input widget.
|
1497
|
+
``on_select`` can be one of the following:
|
1498
|
+
|
1499
|
+
- ``"ignore"`` (default): Streamlit will not react to any selection
|
1500
|
+
events in the chart. The figure will not behave like an input
|
1501
|
+
widget.
|
1502
|
+
|
1503
|
+
- ``"rerun"``: Streamlit will rerun the app when the user selects
|
1504
|
+
data in the chart. In this case, ``st.vega_lite_chart`` will
|
1505
|
+
return the selection data as a dictionary.
|
1506
|
+
|
1507
|
+
- A ``callable``: Streamlit will rerun the app and execute the
|
1508
|
+
``callable`` as a callback function before the rest of the app.
|
1509
|
+
In this case, ``st.vega_lite_chart`` will return the selection data
|
1510
|
+
as a dictionary.
|
1511
|
+
|
1512
|
+
To use selection events, the Vega-Lite spec defined in ``data`` or
|
1513
|
+
``spec`` must include selection parameters from the the charting
|
1514
|
+
library. To learn about defining interactions in Vega-Lite, see
|
1515
|
+
`Dynamic Behaviors with Parameters \
|
1516
|
+
<https://vega.github.io/vega-lite/docs/parameter.html>`_
|
1517
|
+
in Vega-Lite's documentation.
|
1518
|
+
|
1519
|
+
selection_mode : str or Iterable of str
|
1520
|
+
The selection parameters Streamlit should use. If
|
1521
|
+
``selection_mode`` is ``None`` (default), Streamlit will use all
|
1522
|
+
selection parameters defined in the chart's Vega-Lite spec.
|
1523
|
+
|
1524
|
+
When Streamlit uses a selection parameter, selections from that
|
1525
|
+
parameter will trigger a rerun and be included in the selection
|
1526
|
+
state. When Streamlit does not use a selection parameter,
|
1527
|
+
selections from that parameter will not trigger a rerun and not be
|
1528
|
+
included in the selection state.
|
1529
|
+
|
1530
|
+
Selection parameters are identified by their ``name`` property.
|
1299
1531
|
|
1300
1532
|
**kwargs : any
|
1301
|
-
|
1533
|
+
The Vega-Lite spec for the chart as keywords. This is an alternative
|
1534
|
+
to ``spec``.
|
1535
|
+
|
1536
|
+
Returns
|
1537
|
+
-------
|
1538
|
+
element or dict
|
1539
|
+
If ``on_select`` is ``"ignore"`` (default), this method returns an
|
1540
|
+
internal placeholder for the chart element that can be used with
|
1541
|
+
the ``.add_rows()`` method. Otherwise, this method returns a
|
1542
|
+
dictionary-like object that supports both key and attribute
|
1543
|
+
notation. The attributes are described by the ``VegaLiteState``
|
1544
|
+
dictionary schema.
|
1302
1545
|
|
1303
1546
|
Example
|
1304
1547
|
-------
|
@@ -1323,7 +1566,7 @@ class VegaChartsMixin:
|
|
1323
1566
|
|
1324
1567
|
.. output::
|
1325
1568
|
https://doc-vega-lite-chart.streamlit.app/
|
1326
|
-
height:
|
1569
|
+
height: 450px
|
1327
1570
|
|
1328
1571
|
Examples of Vega-Lite usage without Streamlit can be found at
|
1329
1572
|
https://vega.github.io/vega-lite/examples/. Most of those can be easily
|
@@ -620,20 +620,29 @@ class DataEditorMixin:
|
|
620
620
|
changed through column configuration.
|
621
621
|
|
622
622
|
width : int or None
|
623
|
-
Desired width of the data editor expressed in pixels. If
|
624
|
-
|
623
|
+
Desired width of the data editor expressed in pixels. If ``width``
|
624
|
+
is ``None`` (default), Streamlit sets the data editor width to fit
|
625
|
+
its contents up to the width of the parent container. If ``width``
|
626
|
+
is greater than the width of the parent container, Streamlit sets
|
627
|
+
the data editor width to match the width of the parent container.
|
625
628
|
|
626
629
|
height : int or None
|
627
|
-
Desired height of the data editor expressed in pixels. If
|
628
|
-
|
630
|
+
Desired height of the data editor expressed in pixels. If ``height``
|
631
|
+
is ``None`` (default), Streamlit sets the height to show at most
|
632
|
+
ten rows. Vertical scrolling within the data editor element is
|
633
|
+
enabled when the height does not accomodate all rows.
|
629
634
|
|
630
635
|
use_container_width : bool
|
631
|
-
|
632
|
-
|
636
|
+
Whether to override ``width`` with the width of the parent
|
637
|
+
container. If ``use_container_width`` is ``False`` (default),
|
638
|
+
Streamlit sets the data editor's width according to ``width``. If
|
639
|
+
``use_container_width`` is ``True``, Streamlit sets the width of
|
640
|
+
the data editor to match the width of the parent container.
|
633
641
|
|
634
642
|
hide_index : bool or None
|
635
|
-
Whether to hide the index column(s). If
|
636
|
-
index columns is automatically
|
643
|
+
Whether to hide the index column(s). If ``hide_index`` is ``None``
|
644
|
+
(default), the visibility of index columns is automatically
|
645
|
+
determined based on the data.
|
637
646
|
|
638
647
|
column_order : Iterable of str or None
|
639
648
|
Specifies the display order of columns. This also affects which columns are
|
streamlit/runtime/app_session.py
CHANGED
@@ -144,7 +144,8 @@ class AppSession:
|
|
144
144
|
self._stop_config_listener: Callable[[], bool] | None = None
|
145
145
|
self._stop_pages_listener: Callable[[], None] | None = None
|
146
146
|
|
147
|
-
|
147
|
+
if config.get_option("server.fileWatcherType") != "none":
|
148
|
+
self.register_file_watchers()
|
148
149
|
|
149
150
|
self._run_on_save = config.get_option("server.runOnSave")
|
150
151
|
|
@@ -217,7 +217,7 @@ def user_key_from_widget_id(widget_id: str) -> str | None:
|
|
217
217
|
"None" as a key, but we can't avoid this kind of problem while storing the
|
218
218
|
string representation of the no-user-key sentinel as part of the widget id.
|
219
219
|
"""
|
220
|
-
user_key = widget_id.split("-", maxsplit=2)[-1]
|
220
|
+
user_key: str | None = widget_id.split("-", maxsplit=2)[-1]
|
221
221
|
user_key = None if user_key == "None" else user_key
|
222
222
|
return user_key
|
223
223
|
|