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.
- 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/iframe.py +13 -22
- 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/proto/IFrame_pb2.py +8 -2
- streamlit/proto/IFrame_pb2.pyi +3 -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.DjObtx4K.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Dy1V9a2E.js → FileDownload.esm.Bz9nxNC5.js} +1 -1
- streamlit/static/static/js/{FileHelper.D0K06YBq.js → FileHelper.BrQvUXVD.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Cdw5Y7_m.js → FormClearHelper.DF4gFAOO.js} +1 -1
- streamlit/static/static/js/{Hooks.C_qx1sSw.js → Hooks.DEoLCfOE.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D3IDU-eY.js → InputInstructions.D8zoMog9.js} +1 -1
- streamlit/static/static/js/Particles.CCFySwdL.js +1 -0
- streamlit/static/static/js/ProgressBar.COK9j1l0.js +2 -0
- streamlit/static/static/js/Toolbar.Dt4jIKlY.js +1 -0
- streamlit/static/static/js/{base-input.DMlw5p7n.js → base-input.BmvSaPd2.js} +4 -4
- streamlit/static/static/js/{checkbox.C7QR6llE.js → checkbox.Cgxgc0et.js} +2 -2
- streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
- streamlit/static/static/js/{createSuper.C5k_2vfB.js → createSuper.siQeagI2.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.Ct51iCb_.js +1 -0
- streamlit/static/static/js/{downloader.Nj6v3ioB.js → downloader.M6jQeNDf.js} +1 -1
- streamlit/static/static/js/{es6.CVz13CSz.js → es6.CMaUdEZ5.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.gZ8zjT0K.js → iframeResizer.contentWindow.C33BryyP.js} +1 -1
- streamlit/static/static/js/index.8GJD0eeD.js +1 -0
- streamlit/static/static/js/index.8QEYHMQD.js +1 -0
- streamlit/static/static/js/index.Ay41Wnu9.js +1 -0
- streamlit/static/static/js/index.BLiKiJ7_.js +1 -0
- streamlit/static/static/js/index.BT78cJmU.js +1 -0
- streamlit/static/static/js/index.BXDq9dj4.js +1 -0
- streamlit/static/static/js/index.BdGvnhlM.js +1 -0
- streamlit/static/static/js/index.BfasrT0d.js +1 -0
- streamlit/static/static/js/index.CCdtFMFG.js +1 -0
- streamlit/static/static/js/index.CFRGZDz1.js +1 -0
- streamlit/static/static/js/{index.MbqsiUV4.js → index.CFSFYiPA.js} +289 -289
- streamlit/static/static/js/{index.B2L574n6.js → index.CbdWnLqS.js} +3 -3
- streamlit/static/static/js/index.CeiIiXap.js +1 -0
- streamlit/static/static/js/index.CgZDfhN4.js +2 -0
- streamlit/static/static/js/{index.xfcNJBLM.js → index.Cqa4gqqN.js} +1 -1
- streamlit/static/static/js/index.CzX2xpyc.js +1 -0
- streamlit/static/static/js/index.D1EayrNh.js +73 -0
- streamlit/static/static/js/index.D1ErX5go.js +2 -0
- streamlit/static/static/js/{index.CTT2YqEU.js → index.D1jHqUJq.js} +1 -1
- streamlit/static/static/js/index.D5gweoL5.js +7 -0
- streamlit/static/static/js/index.DByVKZgq.js +1 -0
- streamlit/static/static/js/index.DEND45D1.js +3 -0
- streamlit/static/static/js/{index.CbQtRkVt.js → index.DKN5MVff.js} +162 -188
- streamlit/static/static/js/index.DfoxW1gP.js +3855 -0
- streamlit/static/static/js/index.Dtf1Ac0x.js +1 -0
- streamlit/static/static/js/index.DxrLhpeO.js +1 -0
- streamlit/static/static/js/{index.BSFzxMXi.js → index.J7o-_HIh.js} +1 -1
- streamlit/static/static/js/index.LU8juINp.js +197 -0
- streamlit/static/static/js/index.L_N2iylt.js +1 -0
- streamlit/static/static/js/{index.BscWuWHL.js → index.PZUX2kRz.js} +3 -3
- streamlit/static/static/js/index.ROjU6K0k.js +1 -0
- streamlit/static/static/js/index.WSNLkF94.js +1 -0
- streamlit/static/static/js/index.X5W3gJLn.js +1 -0
- streamlit/static/static/js/index.k9LYqfSL.js +1 -0
- streamlit/static/static/js/{index.D3wOJJsg.js → index.pnHtHv_c.js} +12 -12
- streamlit/static/static/js/index.tPUXqsfW.js +1 -0
- streamlit/static/static/js/index.tsvTLdio.js +12 -0
- streamlit/static/static/js/{input.D_45B0P-.js → input.DZd6EQlV.js} +2 -2
- streamlit/static/static/js/{memory.BmhrRyO2.js → memory.ptkfuI71.js} +1 -1
- streamlit/static/static/js/{mergeWith.DvOME7eH.js → mergeWith.GRNk8iwv.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BRNxOzEZ.js → number-overlay-editor.DXS2qb1U.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.C5GiK_Ob.js → possibleConstructorReturn.Bd4ImlQ9.js} +1 -1
- streamlit/static/static/js/{sandbox.B-Q9S7vW.js → sandbox.DsH8LuID.js} +1 -1
- streamlit/static/static/js/{timepicker.DOMbfm_a.js → timepicker.QVekV78C.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CbNz0Ciu.js → toConsumableArray.BJvaP8gb.js} +1 -1
- streamlit/static/static/js/{uniqueId.-ygIU7IL.js → uniqueId.D_5M8Dgf.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Bx3VaRHk.js → useBasicWidgetState.DB3vMS9V.js} +1 -1
- streamlit/static/static/js/useTextInputAutoExpand.CBkGkaRt.js +2 -0
- streamlit/static/static/js/useUpdateUiValue.C7ZKpLQK.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.C-gXt0Rl.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 +6 -1
- 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/server.py +72 -21
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/METADATA +14 -2
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/RECORD +155 -155
- 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/index.mihWZKb1.js +0 -1
- streamlit/static/static/js/useOnInputChange.CDZx-L6q.js +0 -1
- streamlit/static/static/js/useTextInputAutoExpand.BuE9l5TG.js +0 -2
- streamlit/static/static/js/withFullScreenWrapper.DWXejOhQ.js +0 -1
- {streamlit-1.47.1.data → streamlit-1.48.1.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/WHEEL +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/entry_points.txt +0 -0
- {streamlit-1.47.1.dist-info → streamlit-1.48.1.dist-info}/top_level.txt +0 -0
|
@@ -93,7 +93,7 @@ _CHANNELS: Final = {
|
|
|
93
93
|
"column",
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
VegaLiteSpec: TypeAlias =
|
|
96
|
+
VegaLiteSpec: TypeAlias = dict[str, Any]
|
|
97
97
|
AltairChart: TypeAlias = Union[
|
|
98
98
|
"alt.Chart",
|
|
99
99
|
"alt.ConcatChart",
|
|
@@ -132,18 +132,14 @@ class VegaLiteState(TypedDict, total=False):
|
|
|
132
132
|
The point selection parameter is named ``"point_selection"``. The interval
|
|
133
133
|
or box selection parameter is named ``"interval_selection"``.
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
**Example 1: Chart selections with ``st.altair_chart``**
|
|
136
136
|
|
|
137
|
-
>>> import streamlit as st
|
|
138
|
-
>>> import pandas as pd
|
|
139
|
-
>>> import numpy as np
|
|
140
137
|
>>> import altair as alt
|
|
138
|
+
>>> import pandas as pd
|
|
139
|
+
>>> import streamlit as st
|
|
140
|
+
>>> from numpy.random import default_rng as rng
|
|
141
141
|
>>>
|
|
142
|
-
>>>
|
|
143
|
-
>>> st.session_state.data = pd.DataFrame(
|
|
144
|
-
... np.random.randn(20, 3), columns=["a", "b", "c"]
|
|
145
|
-
... )
|
|
146
|
-
>>> df = st.session_state.data
|
|
142
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
147
143
|
>>>
|
|
148
144
|
>>> point_selector = alt.selection_point("point_selection")
|
|
149
145
|
>>> interval_selector = alt.selection_interval("interval_selection")
|
|
@@ -165,16 +161,13 @@ class VegaLiteState(TypedDict, total=False):
|
|
|
165
161
|
>>>
|
|
166
162
|
>>> event
|
|
167
163
|
|
|
168
|
-
|
|
164
|
+
**Example 2: Chart selections with ``st.vega_lite_chart``**
|
|
169
165
|
|
|
170
|
-
>>> import streamlit as st
|
|
171
166
|
>>> import pandas as pd
|
|
172
|
-
>>> import
|
|
167
|
+
>>> import streamlit as st
|
|
168
|
+
>>> from numpy.random import default_rng as rng
|
|
173
169
|
>>>
|
|
174
|
-
>>>
|
|
175
|
-
>>> st.session_state.data = pd.DataFrame(
|
|
176
|
-
... np.random.randn(20, 3), columns=["a", "b", "c"]
|
|
177
|
-
... )
|
|
170
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
178
171
|
>>>
|
|
179
172
|
>>> spec = {
|
|
180
173
|
... "mark": {"type": "circle", "tooltip": True},
|
|
@@ -194,9 +187,7 @@ class VegaLiteState(TypedDict, total=False):
|
|
|
194
187
|
... },
|
|
195
188
|
... }
|
|
196
189
|
>>>
|
|
197
|
-
>>> event = st.vega_lite_chart(
|
|
198
|
-
... st.session_state.data, spec, key="vega_chart", on_select="rerun"
|
|
199
|
-
... )
|
|
190
|
+
>>> event = st.vega_lite_chart(df, spec, key="vega_chart", on_select="rerun")
|
|
200
191
|
>>>
|
|
201
192
|
>>> event
|
|
202
193
|
|
|
@@ -395,10 +386,19 @@ def _convert_altair_to_vega_lite_spec(
|
|
|
395
386
|
|
|
396
387
|
alt.data_transformers.register("id", id_transform) # type: ignore[arg-type,attr-defined,unused-ignore]
|
|
397
388
|
|
|
389
|
+
# alt.themes was deprecated in Altair 5.5.0 in favor of alt.theme
|
|
390
|
+
altair_theme = (
|
|
391
|
+
alt.themes if type_util.is_altair_version_less_than("5.5.0") else alt.theme
|
|
392
|
+
)
|
|
393
|
+
|
|
398
394
|
# The default altair theme has some width/height defaults defined
|
|
399
395
|
# which are not useful for Streamlit. Therefore, we change the theme to
|
|
400
396
|
# "none" to avoid those defaults.
|
|
401
|
-
with
|
|
397
|
+
with (
|
|
398
|
+
altair_theme.enable("none")
|
|
399
|
+
if altair_theme.active == "default"
|
|
400
|
+
else nullcontext()
|
|
401
|
+
): # type: ignore[attr-defined,unused-ignore]
|
|
402
402
|
with alt.data_transformers.enable("id"): # type: ignore[attr-defined,unused-ignore]
|
|
403
403
|
chart_dict = altair_chart.to_dict()
|
|
404
404
|
|
|
@@ -681,6 +681,9 @@ class VegaChartsMixin:
|
|
|
681
681
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
|
682
682
|
for three lines).
|
|
683
683
|
|
|
684
|
+
You can set the default colors in the ``theme.chartCategoryColors``
|
|
685
|
+
configuration option.
|
|
686
|
+
|
|
684
687
|
width : int or None
|
|
685
688
|
Desired width of the chart expressed in pixels. If ``width`` is
|
|
686
689
|
``None`` (default), Streamlit sets the width of the chart to fit
|
|
@@ -705,57 +708,72 @@ class VegaChartsMixin:
|
|
|
705
708
|
|
|
706
709
|
Examples
|
|
707
710
|
--------
|
|
708
|
-
|
|
711
|
+
**Example 1: Basic line chart from a dataframe**
|
|
712
|
+
|
|
713
|
+
If you don't use any of the optional parameters, Streamlit plots each
|
|
714
|
+
column as a separate line, uses the index as the x values, and labels
|
|
715
|
+
each series with the column name:
|
|
716
|
+
|
|
709
717
|
>>> import pandas as pd
|
|
710
|
-
>>> import
|
|
718
|
+
>>> import streamlit as st
|
|
719
|
+
>>> from numpy.random import default_rng as rng
|
|
711
720
|
>>>
|
|
712
|
-
>>>
|
|
721
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
713
722
|
>>>
|
|
714
|
-
>>> st.line_chart(
|
|
723
|
+
>>> st.line_chart(df)
|
|
715
724
|
|
|
716
725
|
.. output::
|
|
717
726
|
https://doc-line-chart.streamlit.app/
|
|
718
727
|
height: 440px
|
|
719
728
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
729
|
+
**Example 2: Line chart from specific dataframe columns**
|
|
730
|
+
|
|
731
|
+
You can choose different columns to use for the x and y values. If your
|
|
732
|
+
dataframe is in long format (all y-values in one column), you can set
|
|
733
|
+
the line colors from another column.
|
|
734
|
+
|
|
735
|
+
If the column contains color strings, the colors will be applied
|
|
736
|
+
directly and the series will be unlabeled. If the column contains other
|
|
737
|
+
values, those values will label each line, and the line colors will be
|
|
738
|
+
selected from the default color palette. You can configure this color
|
|
739
|
+
palette in the ``theme.chartCategoryColors`` configuration option.
|
|
723
740
|
|
|
724
|
-
>>> import streamlit as st
|
|
725
741
|
>>> import pandas as pd
|
|
726
|
-
>>> import
|
|
742
|
+
>>> import streamlit as st
|
|
743
|
+
>>> from numpy.random import default_rng as rng
|
|
727
744
|
>>>
|
|
728
|
-
>>>
|
|
745
|
+
>>> df = pd.DataFrame(
|
|
729
746
|
... {
|
|
730
|
-
... "col1":
|
|
731
|
-
... "col2":
|
|
732
|
-
... "col3":
|
|
747
|
+
... "col1": list(range(20)) * 3,
|
|
748
|
+
... "col2": rng(0).standard_normal(60),
|
|
749
|
+
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
|
|
733
750
|
... }
|
|
734
751
|
... )
|
|
735
752
|
>>>
|
|
736
|
-
>>> st.line_chart(
|
|
753
|
+
>>> st.line_chart(df, x="col1", y="col2", color="col3")
|
|
737
754
|
|
|
738
755
|
.. output::
|
|
739
756
|
https://doc-line-chart1.streamlit.app/
|
|
740
757
|
height: 440px
|
|
741
758
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
759
|
+
**Example 3: Line chart from wide-format dataframe**
|
|
760
|
+
|
|
761
|
+
If your dataframe is in wide format (y-values are in multiple columns),
|
|
762
|
+
you can pass a list of columns to the ``y`` parameter. Each column
|
|
763
|
+
name becomes a series label. To override the default colors, pass a
|
|
764
|
+
list of colors to the ``color`` parameter, one for each series:
|
|
745
765
|
|
|
746
|
-
>>> import streamlit as st
|
|
747
766
|
>>> import pandas as pd
|
|
748
|
-
>>> import
|
|
767
|
+
>>> import streamlit as st
|
|
768
|
+
>>> from numpy.random import default_rng as rng
|
|
749
769
|
>>>
|
|
750
|
-
>>>
|
|
751
|
-
... np.random.randn(20, 3), columns=["col1", "col2", "col3"]
|
|
752
|
-
... )
|
|
770
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
753
771
|
>>>
|
|
754
772
|
>>> st.line_chart(
|
|
755
|
-
...
|
|
756
|
-
... x="
|
|
757
|
-
... y=["
|
|
758
|
-
... color=["#FF0000", "#0000FF"],
|
|
773
|
+
... df,
|
|
774
|
+
... x="a",
|
|
775
|
+
... y=["b", "c"],
|
|
776
|
+
... color=["#FF0000", "#0000FF"],
|
|
759
777
|
... )
|
|
760
778
|
|
|
761
779
|
.. output::
|
|
@@ -879,6 +897,9 @@ class VegaChartsMixin:
|
|
|
879
897
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
|
880
898
|
for three lines).
|
|
881
899
|
|
|
900
|
+
You can set the default colors in the ``theme.chartCategoryColors``
|
|
901
|
+
configuration option.
|
|
902
|
+
|
|
882
903
|
stack : bool, "normalize", "center", or None
|
|
883
904
|
Whether to stack the areas. If this is ``None`` (default),
|
|
884
905
|
Streamlit uses Vega's default. Other values can be as follows:
|
|
@@ -915,72 +936,97 @@ class VegaChartsMixin:
|
|
|
915
936
|
|
|
916
937
|
Examples
|
|
917
938
|
--------
|
|
918
|
-
|
|
939
|
+
**Example 1: Basic area chart from a dataframe**
|
|
940
|
+
|
|
941
|
+
If you don't use any of the optional parameters, Streamlit plots each
|
|
942
|
+
column as a separate area, uses the index as the x values, and labels
|
|
943
|
+
each series with the column name:
|
|
944
|
+
|
|
919
945
|
>>> import pandas as pd
|
|
920
|
-
>>> import
|
|
946
|
+
>>> import streamlit as st
|
|
947
|
+
>>> from numpy.random import default_rng as rng
|
|
921
948
|
>>>
|
|
922
|
-
>>>
|
|
949
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
923
950
|
>>>
|
|
924
|
-
>>> st.area_chart(
|
|
951
|
+
>>> st.area_chart(df)
|
|
925
952
|
|
|
926
953
|
.. output::
|
|
927
954
|
https://doc-area-chart.streamlit.app/
|
|
928
955
|
height: 440px
|
|
929
956
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
957
|
+
**Example 2: Area chart from specific dataframe columns**
|
|
958
|
+
|
|
959
|
+
You can choose different columns to use for the x and y values. If your
|
|
960
|
+
dataframe is in long format (all y-values in one column), you can set
|
|
961
|
+
the area colors from another column.
|
|
962
|
+
|
|
963
|
+
If the column contains color strings, the colors will be applied
|
|
964
|
+
directly and the series will be unlabeled. If the column contains other
|
|
965
|
+
values, those values will label each area, and the area colors will be
|
|
966
|
+
selected from the default color palette. You can configure this color
|
|
967
|
+
palette in the ``theme.chartCategoryColors`` configuration option.
|
|
933
968
|
|
|
934
|
-
>>> import streamlit as st
|
|
935
969
|
>>> import pandas as pd
|
|
936
|
-
>>> import
|
|
970
|
+
>>> import streamlit as st
|
|
971
|
+
>>> from numpy.random import default_rng as rng
|
|
937
972
|
>>>
|
|
938
|
-
>>>
|
|
973
|
+
>>> df = pd.DataFrame(
|
|
939
974
|
... {
|
|
940
|
-
... "col1":
|
|
941
|
-
... "col2":
|
|
942
|
-
... "col3":
|
|
975
|
+
... "col1": list(range(20)) * 3,
|
|
976
|
+
... "col2": rng(0).standard_normal(60),
|
|
977
|
+
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
|
|
943
978
|
... }
|
|
944
979
|
... )
|
|
945
980
|
>>>
|
|
946
|
-
>>> st.area_chart(
|
|
981
|
+
>>> st.area_chart(df, x="col1", y="col2", color="col3")
|
|
947
982
|
|
|
948
983
|
.. output::
|
|
949
984
|
https://doc-area-chart1.streamlit.app/
|
|
950
985
|
height: 440px
|
|
951
986
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
987
|
+
**Example 3: Area chart from wide-format dataframe**
|
|
988
|
+
|
|
989
|
+
If your dataframe is in wide format (y-values are in multiple columns),
|
|
990
|
+
you can pass a list of columns to the ``y`` parameter. Each column
|
|
991
|
+
name becomes a series label. To override the default colors, pass a
|
|
992
|
+
list of colors to the ``color`` parameter, one for each series. If your
|
|
993
|
+
areas are overlapping, use colors with some transparency (alpha
|
|
994
|
+
channel) for the best results.
|
|
955
995
|
|
|
956
|
-
>>> import streamlit as st
|
|
957
996
|
>>> import pandas as pd
|
|
958
|
-
>>> import
|
|
997
|
+
>>> import streamlit as st
|
|
998
|
+
>>> from numpy.random import default_rng as rng
|
|
959
999
|
>>>
|
|
960
|
-
>>>
|
|
961
|
-
...
|
|
1000
|
+
>>> df = pd.DataFrame(
|
|
1001
|
+
... {
|
|
1002
|
+
... "col1": list(range(20)),
|
|
1003
|
+
... "col2": rng(0).standard_normal(20),
|
|
1004
|
+
... "col3": rng(1).standard_normal(20),
|
|
1005
|
+
... }
|
|
962
1006
|
... )
|
|
963
1007
|
>>>
|
|
964
1008
|
>>> st.area_chart(
|
|
965
|
-
...
|
|
1009
|
+
... df,
|
|
966
1010
|
... x="col1",
|
|
967
1011
|
... y=["col2", "col3"],
|
|
968
|
-
... color=["#
|
|
1012
|
+
... color=["#FF000080", "#0000FF80"],
|
|
969
1013
|
... )
|
|
970
1014
|
|
|
971
1015
|
.. output::
|
|
972
1016
|
https://doc-area-chart2.streamlit.app/
|
|
973
1017
|
height: 440px
|
|
974
1018
|
|
|
975
|
-
|
|
976
|
-
|
|
1019
|
+
**Example 4: Area chart with different stacking**
|
|
1020
|
+
|
|
1021
|
+
You can adjust the stacking behavior by setting ``stack``. You can
|
|
1022
|
+
create a streamgraph by setting ``stack="center"``:
|
|
977
1023
|
|
|
978
1024
|
>>> import streamlit as st
|
|
979
1025
|
>>> from vega_datasets import data
|
|
980
1026
|
>>>
|
|
981
|
-
>>>
|
|
1027
|
+
>>> df = data.unemployment_across_industries()
|
|
982
1028
|
>>>
|
|
983
|
-
>>> st.area_chart(
|
|
1029
|
+
>>> st.area_chart(df, x="date", y="count", color="series", stack="center")
|
|
984
1030
|
|
|
985
1031
|
.. output::
|
|
986
1032
|
https://doc-area-chart-steamgraph.streamlit.app/
|
|
@@ -1122,6 +1168,9 @@ class VegaChartsMixin:
|
|
|
1122
1168
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
|
1123
1169
|
for three lines).
|
|
1124
1170
|
|
|
1171
|
+
You can set the default colors in the ``theme.chartCategoryColors``
|
|
1172
|
+
configuration option.
|
|
1173
|
+
|
|
1125
1174
|
horizontal : bool
|
|
1126
1175
|
Whether to make the bars horizontal. If this is ``False``
|
|
1127
1176
|
(default), the bars display vertically. If this is ``True``,
|
|
@@ -1165,68 +1214,90 @@ class VegaChartsMixin:
|
|
|
1165
1214
|
|
|
1166
1215
|
Examples
|
|
1167
1216
|
--------
|
|
1168
|
-
|
|
1217
|
+
**Example 1: Basic bar chart from a dataframe**
|
|
1218
|
+
|
|
1219
|
+
If you don't use any of the optional parameters, Streamlit plots each
|
|
1220
|
+
column as a series of bars, uses the index as the x values, and labels
|
|
1221
|
+
each series with the column name:
|
|
1222
|
+
|
|
1169
1223
|
>>> import pandas as pd
|
|
1170
|
-
>>> import
|
|
1224
|
+
>>> import streamlit as st
|
|
1225
|
+
>>> from numpy.random import default_rng as rng
|
|
1171
1226
|
>>>
|
|
1172
|
-
>>>
|
|
1227
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
1173
1228
|
>>>
|
|
1174
|
-
>>> st.bar_chart(
|
|
1229
|
+
>>> st.bar_chart(df)
|
|
1175
1230
|
|
|
1176
1231
|
.. output::
|
|
1177
1232
|
https://doc-bar-chart.streamlit.app/
|
|
1178
1233
|
height: 440px
|
|
1179
1234
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1235
|
+
**Example 2: Bar chart from specific dataframe columns**
|
|
1236
|
+
|
|
1237
|
+
You can choose different columns to use for the x and y values. If your
|
|
1238
|
+
dataframe is in long format (all y-values in one column), you can set
|
|
1239
|
+
the bar colors from another column.
|
|
1240
|
+
|
|
1241
|
+
If the column contains color strings, the colors will be applied
|
|
1242
|
+
directly and the series will be unlabeled. If the column contains other
|
|
1243
|
+
values, those values will label each series, and the bar colors will be
|
|
1244
|
+
selected from the default color palette. You can configure this color
|
|
1245
|
+
palette in the ``theme.chartCategoryColors`` configuration option.
|
|
1183
1246
|
|
|
1184
|
-
>>> import streamlit as st
|
|
1185
1247
|
>>> import pandas as pd
|
|
1186
|
-
>>> import
|
|
1248
|
+
>>> import streamlit as st
|
|
1249
|
+
>>> from numpy.random import default_rng as rng
|
|
1187
1250
|
>>>
|
|
1188
|
-
>>>
|
|
1251
|
+
>>> df = pd.DataFrame(
|
|
1189
1252
|
... {
|
|
1190
1253
|
... "col1": list(range(20)) * 3,
|
|
1191
|
-
... "col2":
|
|
1192
|
-
... "col3": ["
|
|
1254
|
+
... "col2": rng(0).standard_normal(60),
|
|
1255
|
+
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
|
|
1193
1256
|
... }
|
|
1194
1257
|
... )
|
|
1195
1258
|
>>>
|
|
1196
|
-
>>> st.bar_chart(
|
|
1259
|
+
>>> st.bar_chart(df, x="col1", y="col2", color="col3")
|
|
1197
1260
|
|
|
1198
1261
|
.. output::
|
|
1199
1262
|
https://doc-bar-chart1.streamlit.app/
|
|
1200
1263
|
height: 440px
|
|
1201
1264
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1265
|
+
**Example 3: Bar chart from wide-format dataframe**
|
|
1266
|
+
|
|
1267
|
+
If your dataframe is in wide format (y-values are in multiple columns),
|
|
1268
|
+
you can pass a list of columns to the ``y`` parameter. Each column
|
|
1269
|
+
name becomes a series label. To override the default colors, pass a
|
|
1270
|
+
list of colors to the ``color`` parameter, one for each series:
|
|
1205
1271
|
|
|
1206
|
-
>>> import streamlit as st
|
|
1207
1272
|
>>> import pandas as pd
|
|
1208
|
-
>>> import
|
|
1273
|
+
>>> import streamlit as st
|
|
1274
|
+
>>> from numpy.random import default_rng as rng
|
|
1209
1275
|
>>>
|
|
1210
|
-
>>>
|
|
1276
|
+
>>> df = pd.DataFrame(
|
|
1211
1277
|
... {
|
|
1212
1278
|
... "col1": list(range(20)),
|
|
1213
|
-
... "col2":
|
|
1214
|
-
... "col3":
|
|
1279
|
+
... "col2": rng(0).standard_normal(20),
|
|
1280
|
+
... "col3": rng(1).standard_normal(20),
|
|
1215
1281
|
... }
|
|
1216
1282
|
... )
|
|
1217
1283
|
>>>
|
|
1218
1284
|
>>> st.bar_chart(
|
|
1219
|
-
...
|
|
1285
|
+
... df,
|
|
1220
1286
|
... x="col1",
|
|
1221
1287
|
... y=["col2", "col3"],
|
|
1222
|
-
... color=["#FF0000", "#0000FF"],
|
|
1288
|
+
... color=["#FF0000", "#0000FF"],
|
|
1223
1289
|
... )
|
|
1224
1290
|
|
|
1225
1291
|
.. output::
|
|
1226
1292
|
https://doc-bar-chart2.streamlit.app/
|
|
1227
1293
|
height: 440px
|
|
1228
1294
|
|
|
1229
|
-
|
|
1295
|
+
**Example 4: Horizontal bar chart**
|
|
1296
|
+
|
|
1297
|
+
You can use the ``horizontal`` parameter to display horizontal bars
|
|
1298
|
+
instead of vertical bars. This is useful when you have long labels on
|
|
1299
|
+
the x-axis, or when you want to display a large number of categories.
|
|
1300
|
+
This example requires ``vega_datasets`` to be installed.
|
|
1230
1301
|
|
|
1231
1302
|
>>> import streamlit as st
|
|
1232
1303
|
>>> from vega_datasets import data
|
|
@@ -1239,7 +1310,11 @@ class VegaChartsMixin:
|
|
|
1239
1310
|
https://doc-bar-chart-horizontal.streamlit.app/
|
|
1240
1311
|
height: 440px
|
|
1241
1312
|
|
|
1242
|
-
|
|
1313
|
+
**Example 5: Unstacked bar chart**
|
|
1314
|
+
|
|
1315
|
+
You can configure the stacking behavior of the bars by setting the
|
|
1316
|
+
``stack`` parameter. Set it to ``False`` to display bars side by side.
|
|
1317
|
+
This example requires ``vega_datasets`` to be installed.
|
|
1243
1318
|
|
|
1244
1319
|
>>> import streamlit as st
|
|
1245
1320
|
>>> from vega_datasets import data
|
|
@@ -1422,33 +1497,48 @@ class VegaChartsMixin:
|
|
|
1422
1497
|
|
|
1423
1498
|
Examples
|
|
1424
1499
|
--------
|
|
1425
|
-
|
|
1500
|
+
**Example 1: Basic scatter chart from a dataframe**
|
|
1501
|
+
|
|
1502
|
+
If you don't use any of the optional parameters, Streamlit plots each
|
|
1503
|
+
column as a color-coded group of points, uses the index as the x
|
|
1504
|
+
values, and labels each group with the column name:
|
|
1505
|
+
|
|
1426
1506
|
>>> import pandas as pd
|
|
1427
|
-
>>> import
|
|
1507
|
+
>>> import streamlit as st
|
|
1508
|
+
>>> from numpy.random import default_rng as rng
|
|
1428
1509
|
>>>
|
|
1429
|
-
>>>
|
|
1510
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
|
|
1430
1511
|
>>>
|
|
1431
|
-
>>> st.scatter_chart(
|
|
1512
|
+
>>> st.scatter_chart(df)
|
|
1432
1513
|
|
|
1433
1514
|
.. output::
|
|
1434
1515
|
https://doc-scatter-chart.streamlit.app/
|
|
1435
1516
|
height: 440px
|
|
1436
1517
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1518
|
+
**Example 2: Scatter chart from specific dataframe columns**
|
|
1519
|
+
|
|
1520
|
+
You can choose different columns to use for the x and y values. If your
|
|
1521
|
+
dataframe is in long format (all y-values in one column), you can set
|
|
1522
|
+
the scatter point colors from another column.
|
|
1523
|
+
|
|
1524
|
+
If the column contains color strings, the colors will be applied
|
|
1525
|
+
directly and each color group will be unlabeled. If the column contains
|
|
1526
|
+
other values, those values will label each group, and the scatter point
|
|
1527
|
+
colors will be selected from the default color palette. You can
|
|
1528
|
+
configure this color palette in the ``theme.chartCategoryColors``
|
|
1529
|
+
configuration option.
|
|
1440
1530
|
|
|
1441
|
-
>>> import streamlit as st
|
|
1442
1531
|
>>> import pandas as pd
|
|
1443
|
-
>>> import
|
|
1532
|
+
>>> import streamlit as st
|
|
1533
|
+
>>> from numpy.random import default_rng as rng
|
|
1444
1534
|
>>>
|
|
1445
|
-
>>>
|
|
1446
|
-
...
|
|
1535
|
+
>>> df = pd.DataFrame(
|
|
1536
|
+
... rng(0).standard_normal((20, 3)), columns=["col1", "col2", "col3"]
|
|
1447
1537
|
... )
|
|
1448
|
-
>>>
|
|
1538
|
+
>>> df["col4"] = rng(0).choice(["a", "b", "c"], 20)
|
|
1449
1539
|
>>>
|
|
1450
1540
|
>>> st.scatter_chart(
|
|
1451
|
-
...
|
|
1541
|
+
... df,
|
|
1452
1542
|
... x="col1",
|
|
1453
1543
|
... y="col2",
|
|
1454
1544
|
... color="col4",
|
|
@@ -1459,24 +1549,28 @@ class VegaChartsMixin:
|
|
|
1459
1549
|
https://doc-scatter-chart1.streamlit.app/
|
|
1460
1550
|
height: 440px
|
|
1461
1551
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1552
|
+
**Example 3: Scatter chart from wide-format dataframe**
|
|
1553
|
+
|
|
1554
|
+
If your dataframe is in wide format (y-values are in multiple columns),
|
|
1555
|
+
you can pass a list of columns to the ``y`` parameter. Each column
|
|
1556
|
+
name becomes a group label. To override the default colors, pass a
|
|
1557
|
+
list of colors to the ``color`` parameter, one for each group:
|
|
1465
1558
|
|
|
1466
|
-
>>> import streamlit as st
|
|
1467
1559
|
>>> import pandas as pd
|
|
1468
|
-
>>> import
|
|
1560
|
+
>>> import streamlit as st
|
|
1561
|
+
>>> from numpy.random import default_rng as rng
|
|
1469
1562
|
>>>
|
|
1470
|
-
>>>
|
|
1471
|
-
...
|
|
1563
|
+
>>> df = pd.DataFrame(
|
|
1564
|
+
... rng(0).standard_normal((20, 4)),
|
|
1565
|
+
... columns=["col1", "col2", "col3", "col4"],
|
|
1472
1566
|
... )
|
|
1473
1567
|
>>>
|
|
1474
1568
|
>>> st.scatter_chart(
|
|
1475
|
-
...
|
|
1569
|
+
... df,
|
|
1476
1570
|
... x="col1",
|
|
1477
1571
|
... y=["col2", "col3"],
|
|
1478
1572
|
... size="col4",
|
|
1479
|
-
... color=["#FF0000", "#0000FF"],
|
|
1573
|
+
... color=["#FF0000", "#0000FF"],
|
|
1480
1574
|
... )
|
|
1481
1575
|
|
|
1482
1576
|
.. output::
|
|
@@ -1642,20 +1736,20 @@ class VegaChartsMixin:
|
|
|
1642
1736
|
Example
|
|
1643
1737
|
-------
|
|
1644
1738
|
|
|
1645
|
-
>>> import streamlit as st
|
|
1646
|
-
>>> import pandas as pd
|
|
1647
|
-
>>> import numpy as np
|
|
1648
1739
|
>>> import altair as alt
|
|
1740
|
+
>>> import pandas as pd
|
|
1741
|
+
>>> import streamlit as st
|
|
1742
|
+
>>> from numpy.random import default_rng as rng
|
|
1649
1743
|
>>>
|
|
1650
|
-
>>>
|
|
1744
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
|
|
1651
1745
|
>>>
|
|
1652
|
-
>>>
|
|
1653
|
-
...
|
|
1654
|
-
...
|
|
1655
|
-
...
|
|
1746
|
+
>>> chart = (
|
|
1747
|
+
... alt.Chart(df)
|
|
1748
|
+
... .mark_circle()
|
|
1749
|
+
... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
|
|
1656
1750
|
... )
|
|
1657
1751
|
>>>
|
|
1658
|
-
>>> st.altair_chart(
|
|
1752
|
+
>>> st.altair_chart(chart)
|
|
1659
1753
|
|
|
1660
1754
|
.. output::
|
|
1661
1755
|
https://doc-vega-lite-chart.streamlit.app/
|
|
@@ -1818,23 +1912,23 @@ class VegaChartsMixin:
|
|
|
1818
1912
|
|
|
1819
1913
|
Example
|
|
1820
1914
|
-------
|
|
1821
|
-
>>> import streamlit as st
|
|
1822
1915
|
>>> import pandas as pd
|
|
1823
|
-
>>> import
|
|
1916
|
+
>>> import streamlit as st
|
|
1917
|
+
>>> from numpy.random import default_rng as rng
|
|
1824
1918
|
>>>
|
|
1825
|
-
>>>
|
|
1919
|
+
>>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
|
|
1826
1920
|
>>>
|
|
1827
1921
|
>>> st.vega_lite_chart(
|
|
1828
|
-
...
|
|
1829
|
-
...
|
|
1830
|
-
...
|
|
1831
|
-
...
|
|
1832
|
-
...
|
|
1833
|
-
...
|
|
1834
|
-
...
|
|
1835
|
-
...
|
|
1836
|
-
...
|
|
1837
|
-
...
|
|
1922
|
+
... df,
|
|
1923
|
+
... {
|
|
1924
|
+
... "mark": {"type": "circle", "tooltip": True},
|
|
1925
|
+
... "encoding": {
|
|
1926
|
+
... "x": {"field": "a", "type": "quantitative"},
|
|
1927
|
+
... "y": {"field": "b", "type": "quantitative"},
|
|
1928
|
+
... "size": {"field": "c", "type": "quantitative"},
|
|
1929
|
+
... "color": {"field": "c", "type": "quantitative"},
|
|
1930
|
+
... },
|
|
1931
|
+
... },
|
|
1838
1932
|
... )
|
|
1839
1933
|
|
|
1840
1934
|
.. output::
|
|
@@ -143,8 +143,8 @@ class AudioInputMixin:
|
|
|
143
143
|
An optional callback invoked when this audio input's value
|
|
144
144
|
changes.
|
|
145
145
|
|
|
146
|
-
args : tuple
|
|
147
|
-
An optional tuple of args to pass to the callback.
|
|
146
|
+
args : list or tuple
|
|
147
|
+
An optional list or tuple of args to pass to the callback.
|
|
148
148
|
|
|
149
149
|
kwargs : dict
|
|
150
150
|
An optional dict of kwargs to pass to the callback.
|