-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/bypass-arrow-serialization
- Loading branch information
Showing
162 changed files
with
7,743 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/sharing-editor/public/samples/015_chart_theme/pages/charts.altair_chart.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import altair as alt | ||
import streamlit as st | ||
from vega_datasets import data | ||
|
||
|
||
@st.cache_data | ||
def get_chart(use_container_width: bool): | ||
import altair as alt | ||
from vega_datasets import data | ||
|
||
source = data.cars() | ||
|
||
chart = ( | ||
alt.Chart(source) | ||
.mark_circle() | ||
.encode( | ||
x="Horsepower", | ||
y="Miles_per_Gallon", | ||
color="Origin", | ||
) | ||
.interactive() | ||
) | ||
|
||
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"]) | ||
|
||
with tab1: | ||
st.altair_chart( | ||
chart, use_container_width=use_container_width, theme="streamlit" | ||
) | ||
with tab2: | ||
st.altair_chart(chart, use_container_width=use_container_width, theme=None) | ||
|
||
|
||
try: | ||
get_chart(use_container_width=True) | ||
except Exception as e: | ||
st.exception(e) |
75 changes: 75 additions & 0 deletions
75
packages/sharing-editor/public/samples/015_chart_theme/pages/charts.altair_custom_colors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import altair as alt | ||
import streamlit as st | ||
from vega_datasets import data | ||
|
||
|
||
@st.cache_data | ||
def get_chart(use_container_width: bool): | ||
import altair as alt | ||
from vega_datasets import data | ||
|
||
source = data.seattle_weather() | ||
|
||
scale = alt.Scale( | ||
domain=["sun", "fog", "drizzle", "rain", "snow"], | ||
range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"], | ||
) | ||
color = alt.Color("weather:N", scale=scale) | ||
|
||
# We create two selections: | ||
# - a brush that is active on the top panel | ||
# - a multi-click that is active on sthe bottom panel | ||
brush = alt.selection_interval(encodings=["x"]) | ||
click = alt.selection_multi(encodings=["color"]) | ||
|
||
# Top panel is scatter plot of temperature vs time | ||
points = ( | ||
alt.Chart() | ||
.mark_point() | ||
.encode( | ||
alt.X("monthdate(date):T", title="Date"), | ||
alt.Y( | ||
"temp_max:Q", | ||
title="Maximum Daily Temperature (C)", | ||
scale=alt.Scale(domain=[-5, 40]), | ||
), | ||
color=alt.condition(brush, color, alt.value("lightgray")), | ||
size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])), | ||
) | ||
.properties(width=550, height=300) | ||
.add_selection(brush) | ||
.transform_filter(click) | ||
) | ||
|
||
# Bottom panel is a bar chart of weather type | ||
bars = ( | ||
alt.Chart() | ||
.mark_bar() | ||
.encode( | ||
x="count()", | ||
y="weather:N", | ||
color=alt.condition(click, color, alt.value("lightgray")), | ||
) | ||
.transform_filter(brush) | ||
.properties( | ||
width=550, | ||
) | ||
.add_selection(click) | ||
) | ||
|
||
chart = alt.vconcat(points, bars, data=source, title="Seattle Weather: 2012-2015") | ||
|
||
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"]) | ||
|
||
with tab1: | ||
st.altair_chart( | ||
chart, use_container_width=use_container_width, theme="streamlit" | ||
) | ||
with tab2: | ||
st.altair_chart(chart, use_container_width=use_container_width, theme=None) | ||
|
||
|
||
try: | ||
get_chart(use_container_width=True) | ||
except Exception as e: | ||
st.exception(e) |
30 changes: 30 additions & 0 deletions
30
packages/sharing-editor/public/samples/015_chart_theme/pages/charts.plotly_chart_theme.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import plotly.express as px | ||
import streamlit as st | ||
|
||
|
||
@st.cache_data | ||
def get_chart(use_container_width: bool): | ||
df = px.data.gapminder() | ||
|
||
fig = px.scatter( | ||
df.query("year==2007"), | ||
x="gdpPercap", | ||
y="lifeExp", | ||
size="pop", | ||
color="continent", | ||
hover_name="country", | ||
log_x=True, | ||
size_max=60, | ||
) | ||
|
||
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Plotly native theme"]) | ||
with tab1: | ||
st.plotly_chart(fig, use_container_width=use_container_width, theme="streamlit") | ||
with tab2: | ||
st.plotly_chart(fig, use_container_width=use_container_width, theme=None) | ||
|
||
|
||
try: | ||
get_chart(use_container_width=True) | ||
except Exception as e: | ||
st.exception(e) |
28 changes: 28 additions & 0 deletions
28
packages/sharing-editor/public/samples/015_chart_theme/pages/charts.plotly_custom_colors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import plotly.express as px | ||
import plotly.graph_objects as go | ||
import streamlit as st | ||
|
||
|
||
@st.cache_data | ||
def get_chart_1111(use_conatiner_width: bool): | ||
st.subheader("Define a custom colorscale") | ||
df = px.data.iris() # replace with your own data source | ||
fig = px.scatter( | ||
df, | ||
x="sepal_width", | ||
y="sepal_length", | ||
color="sepal_length", | ||
color_continuous_scale="reds", | ||
) | ||
|
||
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Plotly native theme"]) | ||
with tab1: | ||
st.plotly_chart(fig, use_conatiner_width=use_conatiner_width, theme="streamlit") | ||
with tab2: | ||
st.plotly_chart(fig, use_conatiner_width=use_conatiner_width, theme=None) | ||
|
||
|
||
try: | ||
get_chart_1111(use_conatiner_width=True) | ||
except Exception as e: | ||
st.exception(e) |
40 changes: 40 additions & 0 deletions
40
packages/sharing-editor/public/samples/015_chart_theme/pages/charts.vega_lite_theme.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import streamlit as st | ||
from vega_datasets import data | ||
|
||
|
||
@st.cache_data | ||
def get_chart(use_container_width: bool): | ||
source = data.cars() | ||
|
||
chart = { | ||
"mark": "point", | ||
"encoding": { | ||
"x": { | ||
"field": "Horsepower", | ||
"type": "quantitative", | ||
}, | ||
"y": { | ||
"field": "Miles_per_Gallon", | ||
"type": "quantitative", | ||
}, | ||
"color": {"field": "Origin", "type": "nominal"}, | ||
"shape": {"field": "Origin", "type": "nominal"}, | ||
}, | ||
} | ||
|
||
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Vega-Lite native theme"]) | ||
|
||
with tab1: | ||
st.vega_lite_chart( | ||
source, chart, use_container_width=use_container_width, theme="streamlit" | ||
) | ||
with tab2: | ||
st.vega_lite_chart( | ||
source, chart, use_container_width=use_container_width, theme=None | ||
) | ||
|
||
|
||
try: | ||
get_chart(use_container_width=True) | ||
except Exception as e: | ||
st.exception(e) |
2 changes: 2 additions & 0 deletions
2
packages/sharing-editor/public/samples/015_chart_theme/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vega_datasets | ||
plotly==5.1.0 |
4 changes: 4 additions & 0 deletions
4
packages/sharing-editor/public/samples/015_chart_theme/stlite.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"title": "Theme", | ||
"entrypoint": "streamlit_app.py" | ||
} |
Empty file.
17 changes: 17 additions & 0 deletions
17
packages/sharing-editor/public/samples/020_streamlit_e2e_tests/pages/app_hotkeys.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit as st | ||
|
||
st.text_input("text_input") |
30 changes: 30 additions & 0 deletions
30
...ng-editor/public/samples/020_streamlit_e2e_tests/pages/cached_widget_replay_widget_key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit as st | ||
|
||
st.button("click to rerun") | ||
|
||
side_effects = [] | ||
|
||
|
||
@st.experimental_memo(experimental_allow_widgets=True) | ||
def foo(): | ||
side_effects.append("function ran") | ||
r = st.radio("radio", ["foo", "bar", "baz", "qux"], index=1) | ||
return r | ||
|
||
|
||
foo() | ||
st.text(side_effects) |
20 changes: 20 additions & 0 deletions
20
...aring-editor/public/samples/020_streamlit_e2e_tests/pages/components_declare_component.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit.components.v1 as components | ||
|
||
url = "http://not.a.real.url" | ||
test_component = components.declare_component("test_component", url=url) | ||
|
||
test_component() |
18 changes: 18 additions & 0 deletions
18
packages/sharing-editor/public/samples/020_streamlit_e2e_tests/pages/components_html.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit.components.v1 as components | ||
|
||
html = r"<h1>Hello, Streamlit!</h1>" | ||
components.html(html, width=200, height=500, scrolling=False) |
18 changes: 18 additions & 0 deletions
18
packages/sharing-editor/public/samples/020_streamlit_e2e_tests/pages/components_iframe.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit.components.v1 as components | ||
|
||
src = "http://not.a.real.url" | ||
components.iframe(src, width=200, height=500, scrolling=True) |
18 changes: 18 additions & 0 deletions
18
packages/sharing-editor/public/samples/020_streamlit_e2e_tests/pages/deploy_button.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit as st | ||
|
||
# no need to set it using this since we add ?_stcore_testing=true to the url param | ||
# st.experimental_set_query_params(_stcore_testing="true") |
19 changes: 19 additions & 0 deletions
19
packages/sharing-editor/public/samples/020_streamlit_e2e_tests/pages/empty_labels.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit as st | ||
|
||
a, b = st.columns(2) | ||
a.selectbox("With label", []) | ||
b.selectbox("", []) # No label |
Oops, something went wrong.