streamlit-nightly 1.36.1.dev20240708__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/commands/execution_control.py +4 -0
- streamlit/elements/lib/built_in_chart_utils.py +14 -2
- streamlit/elements/vega_charts.py +31 -10
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{main.8729b772.js → main.2bfed63a.js} +2 -2
- {streamlit_nightly-1.36.1.dev20240708.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240708.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/RECORD +13 -13
- {streamlit_nightly-1.36.1.dev20240708.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/WHEEL +1 -1
- /streamlit/static/static/js/{main.8729b772.js.LICENSE.txt → main.2bfed63a.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240708.data → streamlit_nightly-1.36.1.dev20240709.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240708.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240708.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/top_level.txt +0 -0
@@ -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,
|
@@ -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."""
|
@@ -675,6 +686,7 @@ def _get_opacity_encoding(
|
|
675
686
|
) -> alt.OpacityValue | None:
|
676
687
|
import altair as alt
|
677
688
|
|
689
|
+
# Opacity set to 0.7 for all area charts
|
678
690
|
if color_column and chart_type == ChartType.AREA:
|
679
691
|
return alt.OpacityValue(0.7)
|
680
692
|
|
@@ -761,7 +773,7 @@ def _get_axis_encodings(
|
|
761
773
|
)
|
762
774
|
stack_encoding = y_encoding
|
763
775
|
|
764
|
-
# Handle stacking - only relevant for bar charts
|
776
|
+
# Handle stacking - only relevant for bar & area charts
|
765
777
|
_update_encoding_with_stack(stack, stack_encoding)
|
766
778
|
|
767
779
|
return x_encoding, y_encoding
|
@@ -42,6 +42,7 @@ from streamlit.elements.lib.built_in_chart_utils import (
|
|
42
42
|
ChartStackType,
|
43
43
|
ChartType,
|
44
44
|
generate_chart,
|
45
|
+
maybe_raise_stack_warning,
|
45
46
|
)
|
46
47
|
from streamlit.elements.lib.event_utils import AttributeDictionary
|
47
48
|
from streamlit.elements.lib.policies import check_widget_policies
|
@@ -754,6 +755,7 @@ class VegaChartsMixin:
|
|
754
755
|
x_label: str | None = None,
|
755
756
|
y_label: str | None = None,
|
756
757
|
color: str | Color | list[Color] | None = None,
|
758
|
+
stack: bool | ChartStackType | None = None,
|
757
759
|
width: int | None = None,
|
758
760
|
height: int | None = None,
|
759
761
|
use_container_width: bool = True,
|
@@ -837,6 +839,13 @@ class VegaChartsMixin:
|
|
837
839
|
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
838
840
|
for three lines).
|
839
841
|
|
842
|
+
stack : bool, "normalize", "center", or None
|
843
|
+
Whether to stack the areas. If this is ``None`` (default), uses
|
844
|
+
Vega's default. If ``True``, stacks the areas on top of one another.
|
845
|
+
If ``False``, overlays the areas without stacking. If "normalize",
|
846
|
+
the areas are stacked and normalized to 100%. If "center", the areas
|
847
|
+
are stacked and shifted to center their baseline (produces steamgraph).
|
848
|
+
|
840
849
|
width : int or None
|
841
850
|
Desired width of the chart expressed in pixels. If ``width`` is
|
842
851
|
``None`` (default), Streamlit sets the width of the chart to fit
|
@@ -920,6 +929,18 @@ class VegaChartsMixin:
|
|
920
929
|
|
921
930
|
"""
|
922
931
|
|
932
|
+
# Check that the stack parameter is valid, raise more informative error message if not
|
933
|
+
maybe_raise_stack_warning(
|
934
|
+
stack,
|
935
|
+
"st.area_chart",
|
936
|
+
"https://docs.streamlit.io/develop/api-reference/charts/st.area_chart",
|
937
|
+
)
|
938
|
+
|
939
|
+
# st.area_chart's stack=False option translates to a "layered" area chart for vega. We reserve stack=False for
|
940
|
+
# grouped/non-stacked bar charts, so we need to translate False to "layered" here.
|
941
|
+
if stack is False:
|
942
|
+
stack = "layered"
|
943
|
+
|
923
944
|
chart, add_rows_metadata = generate_chart(
|
924
945
|
chart_type=ChartType.AREA,
|
925
946
|
data=data,
|
@@ -931,6 +952,7 @@ class VegaChartsMixin:
|
|
931
952
|
size_from_user=None,
|
932
953
|
width=width,
|
933
954
|
height=height,
|
955
|
+
stack=stack,
|
934
956
|
)
|
935
957
|
return cast(
|
936
958
|
"DeltaGenerator",
|
@@ -1045,8 +1067,8 @@ class VegaChartsMixin:
|
|
1045
1067
|
|
1046
1068
|
stack : bool, "normalize", "center", "layered", or None
|
1047
1069
|
Whether to stack the bars. If this is ``None`` (default), uses Vega's
|
1048
|
-
default. If
|
1049
|
-
If
|
1070
|
+
default. If ``True``, the bars are stacked on top of each other.
|
1071
|
+
If ``False``, the bars are displayed side by side. If "normalize",
|
1050
1072
|
the bars are stacked and normalized to 100%. If "center", the bars are
|
1051
1073
|
stacked around a central axis. If "layered", the bars are stacked on top
|
1052
1074
|
of one another.
|
@@ -1151,20 +1173,19 @@ class VegaChartsMixin:
|
|
1151
1173
|
|
1152
1174
|
"""
|
1153
1175
|
|
1176
|
+
# Check that the stack parameter is valid, raise more informative error message if not
|
1177
|
+
maybe_raise_stack_warning(
|
1178
|
+
stack,
|
1179
|
+
"st.bar_chart",
|
1180
|
+
"https://docs.streamlit.io/develop/api-reference/charts/st.bar_chart",
|
1181
|
+
)
|
1182
|
+
|
1154
1183
|
# Offset encodings (used for non-stacked/grouped bar charts) are not supported in Altair < 5.0.0
|
1155
1184
|
if type_util.is_altair_version_less_than("5.0.0") and stack is False:
|
1156
1185
|
raise StreamlitAPIException(
|
1157
1186
|
"Streamlit does not support non-stacked (grouped) bar charts with Altair 4.x. Please upgrade to Version 5."
|
1158
1187
|
)
|
1159
1188
|
|
1160
|
-
# Check that the stack parameter is valid, raise more informative error message if not
|
1161
|
-
VALID_STACK_TYPES = (None, True, False, "normalize", "center", "layered")
|
1162
|
-
if stack not in VALID_STACK_TYPES:
|
1163
|
-
raise StreamlitAPIException(
|
1164
|
-
f'Invalid value for stack parameter: {stack}. Stack must be one of True, False, "normalize", "center", "layered" or None. '
|
1165
|
-
"See documentation for `st.bar_chart` [here](https://docs.streamlit.io/develop/api-reference/charts/st.bar_chart) for more information."
|
1166
|
-
)
|
1167
|
-
|
1168
1189
|
bar_chart_type = (
|
1169
1190
|
ChartType.HORIZONTAL_BAR if horizontal else ChartType.VERTICAL_BAR
|
1170
1191
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.29bca1b5.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.2bfed63a.js",
|
5
5
|
"static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
|
6
6
|
"static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
|
7
7
|
"static/js/2736.7d516fcc.chunk.js": "./static/js/2736.7d516fcc.chunk.js",
|
@@ -151,6 +151,6 @@
|
|
151
151
|
},
|
152
152
|
"entrypoints": [
|
153
153
|
"static/css/main.29bca1b5.css",
|
154
|
-
"static/js/main.
|
154
|
+
"static/js/main.2bfed63a.js"
|
155
155
|
]
|
156
156
|
}
|
streamlit/static/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.2bfed63a.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|