streamlit-nightly 1.36.1.dev20240707__py2.py3-none-any.whl → 1.36.1.dev20240709__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/code_util.py +1 -1
- streamlit/commands/execution_control.py +6 -2
- streamlit/commands/logo.py +5 -1
- streamlit/commands/navigation.py +5 -5
- streamlit/connections/base_connection.py +1 -1
- streamlit/connections/snowpark_connection.py +1 -1
- streamlit/connections/sql_connection.py +5 -1
- streamlit/delta_generator.py +14 -14
- streamlit/elements/arrow.py +19 -11
- streamlit/elements/bokeh_chart.py +2 -6
- streamlit/elements/code.py +1 -1
- streamlit/elements/deck_gl_json_chart.py +32 -29
- streamlit/elements/doc_string.py +1 -1
- streamlit/elements/empty.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +7 -8
- streamlit/elements/graphviz_chart.py +13 -13
- streamlit/elements/heading.py +6 -6
- streamlit/elements/html.py +3 -1
- streamlit/elements/image.py +1 -1
- streamlit/elements/json.py +12 -10
- streamlit/elements/layouts.py +21 -21
- streamlit/elements/lib/built_in_chart_utils.py +21 -7
- streamlit/elements/markdown.py +3 -3
- streamlit/elements/media.py +2 -2
- streamlit/elements/metric.py +4 -4
- streamlit/elements/spinner.py +1 -1
- streamlit/elements/text.py +1 -1
- streamlit/elements/vega_charts.py +87 -43
- streamlit/elements/widgets/button.py +5 -5
- streamlit/elements/widgets/file_uploader.py +3 -1
- streamlit/elements/widgets/multiselect.py +2 -1
- streamlit/elements/widgets/number_input.py +6 -2
- streamlit/elements/widgets/radio.py +6 -1
- streamlit/elements/widgets/select_slider.py +21 -3
- streamlit/elements/widgets/selectbox.py +6 -5
- streamlit/elements/widgets/slider.py +5 -6
- streamlit/elements/widgets/text_widgets.py +1 -1
- streamlit/elements/write.py +17 -13
- streamlit/runtime/caching/cache_data_api.py +3 -3
- streamlit/runtime/caching/cache_resource_api.py +3 -3
- streamlit/runtime/caching/legacy_cache_api.py +1 -1
- streamlit/runtime/connection_factory.py +10 -4
- streamlit/static/asset-manifest.json +5 -5
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{2736.4336e2b9.chunk.js → 2736.7d516fcc.chunk.js} +1 -1
- streamlit/static/static/js/3301.0cd98943.chunk.js +1 -0
- streamlit/static/static/js/7175.4cdaec13.chunk.js +1 -0
- streamlit/static/static/js/{main.28e3c6e9.js → main.2bfed63a.js} +2 -2
- streamlit/testing/v1/util.py +2 -2
- streamlit/type_util.py +1 -1
- {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/RECORD +58 -58
- {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/3301.1d1b10bb.chunk.js +0 -1
- streamlit/static/static/js/7175.8f4014ec.chunk.js +0 -1
- /streamlit/static/static/js/{main.28e3c6e9.js.LICENSE.txt → main.2bfed63a.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240707.data → streamlit_nightly-1.36.1.dev20240709.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/top_level.txt +0 -0
streamlit/code_util.py
CHANGED
@@ -73,7 +73,7 @@ def get_method_args_from_code(args: list[Any], line: str) -> list[str]:
|
|
73
73
|
|
74
74
|
Example
|
75
75
|
-------
|
76
|
-
>>> line =
|
76
|
+
>>> line = "foo(bar, baz, my(func, tion))"
|
77
77
|
>>>
|
78
78
|
>>> get_method_args_from_code(range(0, 3), line)
|
79
79
|
['bar', 'baz', 'my(func, tion)']
|
@@ -39,11 +39,11 @@ def stop() -> NoReturn: # type: ignore[misc]
|
|
39
39
|
-------
|
40
40
|
>>> import streamlit as st
|
41
41
|
>>>
|
42
|
-
>>> name = st.text_input(
|
42
|
+
>>> name = st.text_input("Name")
|
43
43
|
>>> if not name:
|
44
44
|
>>> st.warning('Please input a name.')
|
45
45
|
>>> st.stop()
|
46
|
-
>>> st.success(
|
46
|
+
>>> st.success("Thank you for inputting a name.")
|
47
47
|
|
48
48
|
"""
|
49
49
|
ctx = get_script_run_ctx()
|
@@ -151,6 +151,10 @@ def switch_page(page: str | StreamlitPage) -> NoReturn: # type: ignore[misc]
|
|
151
151
|
|
152
152
|
page_script_hash = matched_pages[0]["page_script_hash"]
|
153
153
|
|
154
|
+
# We want to reset query params (with exception of embed) when switching pages
|
155
|
+
with ctx.session_state.query_params() as qp:
|
156
|
+
qp.clear()
|
157
|
+
|
154
158
|
ctx.script_requests.request_rerun(
|
155
159
|
RerunData(
|
156
160
|
query_string=ctx.query_string,
|
streamlit/commands/logo.py
CHANGED
@@ -81,7 +81,11 @@ def logo(
|
|
81
81
|
|
82
82
|
>>> import streamlit as st
|
83
83
|
>>>
|
84
|
-
>>> st.logo(
|
84
|
+
>>> st.logo(
|
85
|
+
... LOGO_URL_LARGE,
|
86
|
+
... link="https://streamlit.io/gallery",
|
87
|
+
... icon_image=LOGO_URL_SMALL,
|
88
|
+
... )
|
85
89
|
|
86
90
|
Try switching logos around in the following example:
|
87
91
|
|
streamlit/commands/navigation.py
CHANGED
@@ -126,14 +126,14 @@ def navigation(
|
|
126
126
|
>>> import streamlit as st
|
127
127
|
>>>
|
128
128
|
>>> pages = {
|
129
|
-
... "Your account"
|
129
|
+
... "Your account": [
|
130
130
|
... st.Page("create_account.py", title="Create your account"),
|
131
|
-
... st.Page("manage_account.py", title="Manage your account")
|
131
|
+
... st.Page("manage_account.py", title="Manage your account"),
|
132
132
|
... ],
|
133
|
-
... "Resources"
|
133
|
+
... "Resources": [
|
134
134
|
... st.Page("learn.py", title="Learn about us"),
|
135
|
-
... st.Page("trial.py", title="Try it out")
|
136
|
-
... ]
|
135
|
+
... st.Page("trial.py", title="Try it out"),
|
136
|
+
... ],
|
137
137
|
... }
|
138
138
|
>>>
|
139
139
|
>>> pg = st.navigation(pages)
|
@@ -164,7 +164,7 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
|
|
164
164
|
>>> # Note: is_healthy() isn't a real method and is just shown for example here.
|
165
165
|
>>> if not conn.is_healthy():
|
166
166
|
... conn.reset()
|
167
|
-
|
167
|
+
>>>
|
168
168
|
>>> # Do stuff with conn...
|
169
169
|
"""
|
170
170
|
self._raw_instance = None
|
@@ -205,7 +205,7 @@ class SnowparkConnection(BaseConnection["Session"]):
|
|
205
205
|
>>> conn = st.connection("snowpark")
|
206
206
|
>>> with conn.safe_session() as session:
|
207
207
|
... df = session.table("mytable").limit(10).to_pandas()
|
208
|
-
|
208
|
+
>>>
|
209
209
|
>>> st.dataframe(df)
|
210
210
|
"""
|
211
211
|
with self._lock:
|
@@ -186,7 +186,11 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
186
186
|
>>> import streamlit as st
|
187
187
|
>>>
|
188
188
|
>>> conn = st.connection("sql")
|
189
|
-
>>> df = conn.query(
|
189
|
+
>>> df = conn.query(
|
190
|
+
... "select * from pet_owners where owner = :owner",
|
191
|
+
... ttl=3600,
|
192
|
+
... params={"owner": "barbara"},
|
193
|
+
... )
|
190
194
|
>>> st.dataframe(df)
|
191
195
|
"""
|
192
196
|
|
streamlit/delta_generator.py
CHANGED
@@ -577,15 +577,13 @@ class DeltaGenerator(
|
|
577
577
|
>>> import numpy as np
|
578
578
|
>>>
|
579
579
|
>>> df1 = pd.DataFrame(
|
580
|
-
...
|
581
|
-
...
|
582
|
-
...
|
580
|
+
... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
|
581
|
+
... )
|
583
582
|
>>> my_table = st.table(df1)
|
584
583
|
>>>
|
585
584
|
>>> df2 = pd.DataFrame(
|
586
|
-
...
|
587
|
-
...
|
588
|
-
...
|
585
|
+
... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
|
586
|
+
... )
|
589
587
|
>>> my_table.add_rows(df2)
|
590
588
|
>>> # Now the table shown in the Streamlit app contains the data for
|
591
589
|
>>> # df1 followed by the data for df2.
|
@@ -602,14 +600,16 @@ class DeltaGenerator(
|
|
602
600
|
And for plots whose datasets are named, you can pass the data with a
|
603
601
|
keyword argument where the key is the name:
|
604
602
|
|
605
|
-
>>> my_chart = st.vega_lite_chart(
|
606
|
-
...
|
607
|
-
...
|
608
|
-
...
|
609
|
-
...
|
610
|
-
...
|
611
|
-
...
|
612
|
-
... }
|
603
|
+
>>> my_chart = st.vega_lite_chart(
|
604
|
+
... {
|
605
|
+
... "mark": "line",
|
606
|
+
... "encoding": {"x": "a", "y": "b"},
|
607
|
+
... "datasets": {
|
608
|
+
... "some_fancy_name": df1, # <-- named dataset
|
609
|
+
... },
|
610
|
+
... "data": {"name": "some_fancy_name"},
|
611
|
+
... }
|
612
|
+
... )
|
613
613
|
>>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
|
614
614
|
|
615
615
|
"""
|
streamlit/elements/arrow.py
CHANGED
@@ -587,7 +587,9 @@ class ArrowMixin:
|
|
587
587
|
>>> import pandas as pd
|
588
588
|
>>> import numpy as np
|
589
589
|
>>>
|
590
|
-
>>> df = pd.DataFrame(
|
590
|
+
>>> df = pd.DataFrame(
|
591
|
+
... np.random.randn(10, 5), columns=("col %d" % i for i in range(5))
|
592
|
+
... )
|
591
593
|
>>>
|
592
594
|
>>> st.table(df)
|
593
595
|
|
@@ -633,11 +635,15 @@ class ArrowMixin:
|
|
633
635
|
>>> import pandas as pd
|
634
636
|
>>> import numpy as np
|
635
637
|
>>>
|
636
|
-
>>> df1 = pd.DataFrame(
|
638
|
+
>>> df1 = pd.DataFrame(
|
639
|
+
... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
|
640
|
+
... )
|
637
641
|
>>>
|
638
642
|
>>> my_table = st.table(df1)
|
639
643
|
>>>
|
640
|
-
>>> df2 = pd.DataFrame(
|
644
|
+
>>> df2 = pd.DataFrame(
|
645
|
+
... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
|
646
|
+
... )
|
641
647
|
>>>
|
642
648
|
>>> my_table.add_rows(df2)
|
643
649
|
>>> # Now the table shown in the Streamlit app contains the data for
|
@@ -655,14 +661,16 @@ class ArrowMixin:
|
|
655
661
|
And for plots whose datasets are named, you can pass the data with a
|
656
662
|
keyword argument where the key is the name:
|
657
663
|
|
658
|
-
>>> my_chart = st.vega_lite_chart(
|
659
|
-
...
|
660
|
-
...
|
661
|
-
...
|
662
|
-
...
|
663
|
-
...
|
664
|
-
...
|
665
|
-
... }
|
664
|
+
>>> my_chart = st.vega_lite_chart(
|
665
|
+
... {
|
666
|
+
... "mark": "line",
|
667
|
+
... "encoding": {"x": "a", "y": "b"},
|
668
|
+
... "datasets": {
|
669
|
+
... "some_fancy_name": df1, # <-- named dataset
|
670
|
+
... },
|
671
|
+
... "data": {"name": "some_fancy_name"},
|
672
|
+
... }
|
673
|
+
... )
|
666
674
|
>>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
|
667
675
|
|
668
676
|
"""
|
@@ -70,12 +70,8 @@ class BokehMixin:
|
|
70
70
|
>>> x = [1, 2, 3, 4, 5]
|
71
71
|
>>> y = [6, 7, 2, 4, 5]
|
72
72
|
>>>
|
73
|
-
>>> p = figure(
|
74
|
-
|
75
|
-
... x_axis_label='x',
|
76
|
-
... y_axis_label='y')
|
77
|
-
...
|
78
|
-
>>> p.line(x, y, legend_label='Trend', line_width=2)
|
73
|
+
>>> p = figure(title="simple line example", x_axis_label="x", y_axis_label="y")
|
74
|
+
>>> p.line(x, y, legend_label="Trend", line_width=2)
|
79
75
|
>>>
|
80
76
|
>>> st.bokeh_chart(p, use_container_width=True)
|
81
77
|
|
streamlit/elements/code.py
CHANGED
@@ -91,37 +91,40 @@ class PydeckMixin:
|
|
91
91
|
>>> import pydeck as pdk
|
92
92
|
>>>
|
93
93
|
>>> chart_data = pd.DataFrame(
|
94
|
-
...
|
95
|
-
...
|
94
|
+
... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
95
|
+
... columns=["lat", "lon"],
|
96
|
+
... )
|
96
97
|
>>>
|
97
|
-
>>> st.pydeck_chart(
|
98
|
-
...
|
99
|
-
...
|
100
|
-
...
|
101
|
-
...
|
102
|
-
...
|
103
|
-
...
|
104
|
-
...
|
105
|
-
... layers=[
|
106
|
-
... pdk.Layer(
|
107
|
-
... 'HexagonLayer',
|
108
|
-
... data=chart_data,
|
109
|
-
... get_position='[lon, lat]',
|
110
|
-
... radius=200,
|
111
|
-
... elevation_scale=4,
|
112
|
-
... elevation_range=[0, 1000],
|
113
|
-
... pickable=True,
|
114
|
-
... extruded=True,
|
98
|
+
>>> st.pydeck_chart(
|
99
|
+
... pdk.Deck(
|
100
|
+
... map_style=None,
|
101
|
+
... initial_view_state=pdk.ViewState(
|
102
|
+
... latitude=37.76,
|
103
|
+
... longitude=-122.4,
|
104
|
+
... zoom=11,
|
105
|
+
... pitch=50,
|
115
106
|
... ),
|
116
|
-
...
|
117
|
-
...
|
118
|
-
...
|
119
|
-
...
|
120
|
-
...
|
121
|
-
...
|
122
|
-
...
|
123
|
-
...
|
124
|
-
...
|
107
|
+
... layers=[
|
108
|
+
... pdk.Layer(
|
109
|
+
... "HexagonLayer",
|
110
|
+
... data=chart_data,
|
111
|
+
... get_position="[lon, lat]",
|
112
|
+
... radius=200,
|
113
|
+
... elevation_scale=4,
|
114
|
+
... elevation_range=[0, 1000],
|
115
|
+
... pickable=True,
|
116
|
+
... extruded=True,
|
117
|
+
... ),
|
118
|
+
... pdk.Layer(
|
119
|
+
... "ScatterplotLayer",
|
120
|
+
... data=chart_data,
|
121
|
+
... get_position="[lon, lat]",
|
122
|
+
... get_color="[200, 30, 0, 160]",
|
123
|
+
... get_radius=200,
|
124
|
+
... ),
|
125
|
+
... ],
|
126
|
+
... )
|
127
|
+
... )
|
125
128
|
|
126
129
|
.. output::
|
127
130
|
https://doc-pydeck-chart.streamlit.app/
|
streamlit/elements/doc_string.py
CHANGED
streamlit/elements/empty.py
CHANGED
streamlit/elements/exception.py
CHANGED
streamlit/elements/form.py
CHANGED
@@ -162,15 +162,14 @@ class FormMixin:
|
|
162
162
|
>>> import streamlit as st
|
163
163
|
>>>
|
164
164
|
>>> with st.form("my_form"):
|
165
|
-
...
|
166
|
-
...
|
167
|
-
...
|
168
|
-
...
|
169
|
-
... # Every form must have a submit button.
|
170
|
-
... submitted = st.form_submit_button("Submit")
|
171
|
-
... if submitted:
|
172
|
-
... st.write("slider", slider_val, "checkbox", checkbox_val)
|
165
|
+
... st.write("Inside the form")
|
166
|
+
... slider_val = st.slider("Form slider")
|
167
|
+
... checkbox_val = st.checkbox("Form checkbox")
|
173
168
|
...
|
169
|
+
... # Every form must have a submit button.
|
170
|
+
... submitted = st.form_submit_button("Submit")
|
171
|
+
... if submitted:
|
172
|
+
... st.write("slider", slider_val, "checkbox", checkbox_val)
|
174
173
|
>>> st.write("Outside the form")
|
175
174
|
|
176
175
|
.. output::
|
@@ -66,19 +66,19 @@ class GraphvizMixin:
|
|
66
66
|
>>>
|
67
67
|
>>> # Create a graphlib graph object
|
68
68
|
>>> graph = graphviz.Digraph()
|
69
|
-
>>> graph.edge(
|
70
|
-
>>> graph.edge(
|
71
|
-
>>> graph.edge(
|
72
|
-
>>> graph.edge(
|
73
|
-
>>> graph.edge(
|
74
|
-
>>> graph.edge(
|
75
|
-
>>> graph.edge(
|
76
|
-
>>> graph.edge(
|
77
|
-
>>> graph.edge(
|
78
|
-
>>> graph.edge(
|
79
|
-
>>> graph.edge(
|
80
|
-
>>> graph.edge(
|
81
|
-
>>> graph.edge(
|
69
|
+
>>> graph.edge("run", "intr")
|
70
|
+
>>> graph.edge("intr", "runbl")
|
71
|
+
>>> graph.edge("runbl", "run")
|
72
|
+
>>> graph.edge("run", "kernel")
|
73
|
+
>>> graph.edge("kernel", "zombie")
|
74
|
+
>>> graph.edge("kernel", "sleep")
|
75
|
+
>>> graph.edge("kernel", "runmem")
|
76
|
+
>>> graph.edge("sleep", "swap")
|
77
|
+
>>> graph.edge("swap", "runswap")
|
78
|
+
>>> graph.edge("runswap", "new")
|
79
|
+
>>> graph.edge("runswap", "runmem")
|
80
|
+
>>> graph.edge("new", "runmem")
|
81
|
+
>>> graph.edge("sleep", "runmem")
|
82
82
|
>>>
|
83
83
|
>>> st.graphviz_chart(graph)
|
84
84
|
|
streamlit/elements/heading.py
CHANGED
@@ -94,8 +94,8 @@ class HeadingMixin:
|
|
94
94
|
--------
|
95
95
|
>>> import streamlit as st
|
96
96
|
>>>
|
97
|
-
>>> st.header(
|
98
|
-
>>> st.header(
|
97
|
+
>>> st.header("This is a header with a divider", divider="rainbow")
|
98
|
+
>>> st.header("_Streamlit_ is :blue[cool] :sunglasses:")
|
99
99
|
|
100
100
|
.. output::
|
101
101
|
https://doc-header.streamlit.app/
|
@@ -167,8 +167,8 @@ class HeadingMixin:
|
|
167
167
|
--------
|
168
168
|
>>> import streamlit as st
|
169
169
|
>>>
|
170
|
-
>>> st.subheader(
|
171
|
-
>>> st.subheader(
|
170
|
+
>>> st.subheader("This is a subheader with a divider", divider="rainbow")
|
171
|
+
>>> st.subheader("_Streamlit_ is :blue[cool] :sunglasses:")
|
172
172
|
|
173
173
|
.. output::
|
174
174
|
https://doc-subheader.streamlit.app/
|
@@ -234,8 +234,8 @@ class HeadingMixin:
|
|
234
234
|
--------
|
235
235
|
>>> import streamlit as st
|
236
236
|
>>>
|
237
|
-
>>> st.title(
|
238
|
-
>>> st.title(
|
237
|
+
>>> st.title("This is a title")
|
238
|
+
>>> st.title("_Streamlit_ is :blue[cool] :sunglasses:")
|
239
239
|
|
240
240
|
.. output::
|
241
241
|
https://doc-title.streamlit.app/
|
streamlit/elements/html.py
CHANGED
@@ -57,7 +57,9 @@ class HtmlMixin:
|
|
57
57
|
-------
|
58
58
|
>>> import streamlit as st
|
59
59
|
>>>
|
60
|
-
>>> st.html(
|
60
|
+
>>> st.html(
|
61
|
+
... "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
|
62
|
+
... )
|
61
63
|
|
62
64
|
.. output::
|
63
65
|
https://doc-html.streamlit.app/
|
streamlit/elements/image.py
CHANGED
@@ -140,7 +140,7 @@ class ImageMixin:
|
|
140
140
|
Example
|
141
141
|
-------
|
142
142
|
>>> import streamlit as st
|
143
|
-
>>> st.image(
|
143
|
+
>>> st.image("sunrise.jpg", caption="Sunrise by the mountains")
|
144
144
|
|
145
145
|
.. output::
|
146
146
|
https://doc-image.streamlit.app/
|
streamlit/elements/json.py
CHANGED
@@ -58,16 +58,18 @@ class JsonMixin:
|
|
58
58
|
-------
|
59
59
|
>>> import streamlit as st
|
60
60
|
>>>
|
61
|
-
>>> st.json(
|
62
|
-
...
|
63
|
-
...
|
64
|
-
...
|
65
|
-
...
|
66
|
-
...
|
67
|
-
...
|
68
|
-
...
|
69
|
-
...
|
70
|
-
...
|
61
|
+
>>> st.json(
|
62
|
+
... {
|
63
|
+
... "foo": "bar",
|
64
|
+
... "baz": "boz",
|
65
|
+
... "stuff": [
|
66
|
+
... "stuff 1",
|
67
|
+
... "stuff 2",
|
68
|
+
... "stuff 3",
|
69
|
+
... "stuff 5",
|
70
|
+
... ],
|
71
|
+
... }
|
72
|
+
... )
|
71
73
|
|
72
74
|
.. output::
|
73
75
|
https://doc-json.streamlit.app/
|
streamlit/elements/layouts.py
CHANGED
@@ -73,11 +73,11 @@ class LayoutsMixin:
|
|
73
73
|
>>> import streamlit as st
|
74
74
|
>>>
|
75
75
|
>>> with st.container():
|
76
|
-
...
|
77
|
-
...
|
78
|
-
... # You can call any Streamlit command, including custom components:
|
79
|
-
... st.bar_chart(np.random.randn(50, 3))
|
76
|
+
... st.write("This is inside the container")
|
80
77
|
...
|
78
|
+
... # You can call any Streamlit command, including custom components:
|
79
|
+
... st.bar_chart(np.random.randn(50, 3))
|
80
|
+
>>>
|
81
81
|
>>> st.write("This is outside the container")
|
82
82
|
|
83
83
|
.. output ::
|
@@ -201,16 +201,16 @@ class LayoutsMixin:
|
|
201
201
|
>>> col1, col2, col3 = st.columns(3)
|
202
202
|
>>>
|
203
203
|
>>> with col1:
|
204
|
-
...
|
205
|
-
...
|
206
|
-
|
204
|
+
... st.header("A cat")
|
205
|
+
... st.image("https://static.streamlit.io/examples/cat.jpg")
|
206
|
+
>>>
|
207
207
|
>>> with col2:
|
208
|
-
...
|
209
|
-
...
|
210
|
-
|
208
|
+
... st.header("A dog")
|
209
|
+
... st.image("https://static.streamlit.io/examples/dog.jpg")
|
210
|
+
>>>
|
211
211
|
>>> with col3:
|
212
|
-
...
|
213
|
-
...
|
212
|
+
... st.header("An owl")
|
213
|
+
... st.image("https://static.streamlit.io/examples/owl.jpg")
|
214
214
|
|
215
215
|
.. output ::
|
216
216
|
https://doc-columns1.streamlit.app/
|
@@ -386,16 +386,14 @@ class LayoutsMixin:
|
|
386
386
|
>>> tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"])
|
387
387
|
>>>
|
388
388
|
>>> with tab1:
|
389
|
-
...
|
390
|
-
...
|
391
|
-
...
|
389
|
+
... st.header("A cat")
|
390
|
+
... st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
|
392
391
|
>>> with tab2:
|
393
|
-
...
|
394
|
-
...
|
395
|
-
...
|
392
|
+
... st.header("A dog")
|
393
|
+
... st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
|
396
394
|
>>> with tab3:
|
397
|
-
...
|
398
|
-
...
|
395
|
+
... st.header("An owl")
|
396
|
+
... st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
|
399
397
|
|
400
398
|
.. output ::
|
401
399
|
https://doc-tabs1.streamlit.app/
|
@@ -799,7 +797,9 @@ class LayoutsMixin:
|
|
799
797
|
... time.sleep(1)
|
800
798
|
... st.write("Downloading data...")
|
801
799
|
... time.sleep(1)
|
802
|
-
... status.update(
|
800
|
+
... status.update(
|
801
|
+
... label="Download complete!", state="complete", expanded=False
|
802
|
+
... )
|
803
803
|
>>>
|
804
804
|
>>> st.button("Rerun")
|
805
805
|
|
@@ -117,6 +117,17 @@ _MELTED_COLOR_COLUMN_NAME: Final = _MELTED_COLOR_COLUMN_TITLE + _PROTECTION_SUFF
|
|
117
117
|
_NON_EXISTENT_COLUMN_NAME: Final = "DOES_NOT_EXIST" + _PROTECTION_SUFFIX
|
118
118
|
|
119
119
|
|
120
|
+
def maybe_raise_stack_warning(
|
121
|
+
stack: bool | ChartStackType | None, command: str | None, docs_link: str
|
122
|
+
):
|
123
|
+
# Check that the stack parameter is valid, raise more informative error message if not
|
124
|
+
if stack not in (None, True, False, "normalize", "center", "layered"):
|
125
|
+
raise StreamlitAPIException(
|
126
|
+
f'Invalid value for stack parameter: {stack}. Stack must be one of True, False, "normalize", "center", "layered" or None. '
|
127
|
+
f"See documentation for `{command}` [here]({docs_link}) for more information."
|
128
|
+
)
|
129
|
+
|
130
|
+
|
120
131
|
def generate_chart(
|
121
132
|
chart_type: ChartType,
|
122
133
|
data: Data | None,
|
@@ -128,7 +139,7 @@ def generate_chart(
|
|
128
139
|
size_from_user: str | float | None = None,
|
129
140
|
width: int | None = None,
|
130
141
|
height: int | None = None,
|
131
|
-
# Bar charts only:
|
142
|
+
# Bar & Area charts only:
|
132
143
|
stack: bool | ChartStackType | None = None,
|
133
144
|
) -> tuple[alt.Chart, AddRowsMetadata]:
|
134
145
|
"""Function to use the chart's type, data columns and indices to figure out the chart's spec."""
|
@@ -457,11 +468,13 @@ def _melt_data(
|
|
457
468
|
--------
|
458
469
|
|
459
470
|
>>> import pandas as pd
|
460
|
-
>>> df = pd.DataFrame(
|
461
|
-
...
|
462
|
-
...
|
463
|
-
...
|
464
|
-
...
|
471
|
+
>>> df = pd.DataFrame(
|
472
|
+
... {
|
473
|
+
... "a": [1, 2, 3],
|
474
|
+
... "b": [4, 5, 6],
|
475
|
+
... "c": [7, 8, 9],
|
476
|
+
... }
|
477
|
+
... )
|
465
478
|
>>> _melt_data(df, ["a"], ["b", "c"], "value", "color")
|
466
479
|
>>> a color value
|
467
480
|
>>> 0 1 b 4
|
@@ -673,6 +686,7 @@ def _get_opacity_encoding(
|
|
673
686
|
) -> alt.OpacityValue | None:
|
674
687
|
import altair as alt
|
675
688
|
|
689
|
+
# Opacity set to 0.7 for all area charts
|
676
690
|
if color_column and chart_type == ChartType.AREA:
|
677
691
|
return alt.OpacityValue(0.7)
|
678
692
|
|
@@ -759,7 +773,7 @@ def _get_axis_encodings(
|
|
759
773
|
)
|
760
774
|
stack_encoding = y_encoding
|
761
775
|
|
762
|
-
# Handle stacking - only relevant for bar charts
|
776
|
+
# Handle stacking - only relevant for bar & area charts
|
763
777
|
_update_encoding_with_stack(stack, stack_encoding)
|
764
778
|
|
765
779
|
return x_encoding, y_encoding
|
streamlit/elements/markdown.py
CHANGED
@@ -141,7 +141,7 @@ class MarkdownMixin:
|
|
141
141
|
>>>
|
142
142
|
>>> code = '''def hello():
|
143
143
|
... print("Hello, Streamlit!")'''
|
144
|
-
>>> st.code(code, language=
|
144
|
+
>>> st.code(code, language="python")
|
145
145
|
|
146
146
|
"""
|
147
147
|
code_proto = MarkdownProto()
|
@@ -206,8 +206,8 @@ class MarkdownMixin:
|
|
206
206
|
--------
|
207
207
|
>>> import streamlit as st
|
208
208
|
>>>
|
209
|
-
>>> st.caption(
|
210
|
-
>>> st.caption(
|
209
|
+
>>> st.caption("This is a string that explains something above.")
|
210
|
+
>>> st.caption("A caption with _italics_ :blue[colors] and emojis :sunglasses:")
|
211
211
|
|
212
212
|
"""
|
213
213
|
caption_proto = MarkdownProto()
|