-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade Streamlit to 1.36.0 * Update Streamlit version in stlite-server * Update the streamlit submodule * Update samples
- Loading branch information
Showing
40 changed files
with
626 additions
and
39 deletions.
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
74 changes: 74 additions & 0 deletions
74
packages/sharing-editor/public/samples/011_component_gallery/pages/annotations-in-altair.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,74 @@ | ||
import streamlit as st | ||
import altair as alt | ||
import pandas as pd | ||
from vega_datasets import data | ||
|
||
|
||
@st.cache_data | ||
def get_data(): | ||
source = data.stocks() | ||
source = source[source.date.gt("2004-01-01")] | ||
return source | ||
|
||
|
||
stock_data = get_data() | ||
|
||
hover = alt.selection_single( | ||
fields=["date"], | ||
nearest=True, | ||
on="mouseover", | ||
empty="none", | ||
) | ||
|
||
lines = ( | ||
alt.Chart(stock_data, title="Evolution of stock prices") | ||
.mark_line() | ||
.encode( | ||
x="date", | ||
y="price", | ||
color="symbol", | ||
) | ||
) | ||
|
||
points = lines.transform_filter(hover).mark_circle(size=65) | ||
|
||
tooltips = ( | ||
alt.Chart(stock_data) | ||
.mark_rule() | ||
.encode( | ||
x="yearmonthdate(date)", | ||
y="price", | ||
opacity=alt.condition(hover, alt.value(0.3), alt.value(0)), | ||
tooltip=[ | ||
alt.Tooltip("date", title="Date"), | ||
alt.Tooltip("price", title="Price (USD)"), | ||
], | ||
) | ||
.add_selection(hover) | ||
) | ||
|
||
data_layer = lines + points + tooltips | ||
|
||
|
||
event_picker = alt.selection_point("events") | ||
|
||
|
||
ANNOTATIONS = [ | ||
("Sep 01, 2007", 400, "🙂", "Something's going well for GOOG & AAPL."), | ||
("Nov 01, 2008", 180, "🙂", "The market is recovering."), | ||
("Dec 01, 2007", 700, "😱", "Something's going wrong for GOOG & AAPL."), | ||
("Dec 01, 2009", 650, "😱", "A hiccup for GOOG."), | ||
] | ||
annotations_df = pd.DataFrame( | ||
ANNOTATIONS, columns=["date", "y", "marker", "description"] | ||
) | ||
annotations_df.date = pd.to_datetime(annotations_df.date) | ||
|
||
annotation_layer = ( | ||
alt.Chart(annotations_df) | ||
.mark_text(size=20, dx=-8, dy=-10, align="left") | ||
.encode(x="date:T", y=alt.Y("y:Q"), text="marker", tooltip="description") | ||
) | ||
|
||
combined_chart = data_layer + annotation_layer | ||
st.altair_chart(combined_chart, use_container_width=True) |
10 changes: 10 additions & 0 deletions
10
.../sharing-editor/public/samples/011_component_gallery/pages/charts.bar_chart_horizontal.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,10 @@ | ||
import streamlit as st | ||
from vega_datasets import data | ||
|
||
@st.cache_data | ||
def get_data(): | ||
return data.barley() | ||
|
||
source = get_data() | ||
|
||
st.bar_chart(source, x="variety", y="yield", color="site", horizontal=True) |
96 changes: 96 additions & 0 deletions
96
...ges/sharing-editor/public/samples/011_component_gallery/pages/dataframe-row-selections.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,96 @@ | ||
import random | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
|
||
@st.cache_data | ||
def get_profile_dataset(number_of_items: int = 20, seed: int = 0) -> pd.DataFrame: | ||
from faker import Faker | ||
|
||
new_data = [] | ||
|
||
fake = Faker() | ||
random.seed(seed) | ||
Faker.seed(seed) | ||
|
||
for i in range(number_of_items): | ||
profile = fake.profile() | ||
new_data.append( | ||
{ | ||
"avatar": f"https://picsum.photos/400/200?lock={i}", | ||
"name": profile["name"], | ||
"daily_activity": np.random.rand(25), | ||
"activity": np.random.randint(2, 90, size=12), | ||
} | ||
) | ||
|
||
profile_df = pd.DataFrame(new_data) | ||
return profile_df | ||
|
||
|
||
column_configuration = { | ||
"name": st.column_config.TextColumn( | ||
"Name", help="The name of the user", max_chars=100, width="medium" | ||
), | ||
"avatar": st.column_config.ImageColumn("Avatar", help="The user's avatar"), | ||
"activity": st.column_config.LineChartColumn( | ||
"Activity (1 year)", | ||
help="The user's activity over the last 1 year", | ||
width="large", | ||
y_min=0, | ||
y_max=100, | ||
), | ||
"daily_activity": st.column_config.BarChartColumn( | ||
"Activity (daily)", | ||
help="The user's activity in the last 25 days", | ||
width="medium", | ||
y_min=0, | ||
y_max=1, | ||
), | ||
} | ||
|
||
select, compare = st.tabs(["Select members", "Compare selected"]) | ||
|
||
with select: | ||
st.header("All members") | ||
|
||
df = get_profile_dataset() | ||
|
||
event = st.dataframe( | ||
df, | ||
column_config=column_configuration, | ||
use_container_width=True, | ||
hide_index=True, | ||
on_select="rerun", | ||
selection_mode="multi-row", | ||
) | ||
|
||
st.header("Selected members") | ||
people = event.selection.rows | ||
filtered_df = df.iloc[people] | ||
st.dataframe( | ||
filtered_df, | ||
column_config=column_configuration, | ||
use_container_width=True, | ||
) | ||
|
||
with compare: | ||
activity_df = {} | ||
for person in people: | ||
activity_df[df.iloc[person]["name"]] = df.iloc[person]["activity"] | ||
activity_df = pd.DataFrame(activity_df) | ||
|
||
daily_activity_df = {} | ||
for person in people: | ||
daily_activity_df[df.iloc[person]["name"]] = df.iloc[person]["daily_activity"] | ||
daily_activity_df = pd.DataFrame(daily_activity_df) | ||
|
||
if len(people) > 0: | ||
st.header("Daily activity comparison") | ||
st.bar_chart(daily_activity_df) | ||
st.header("Yearly activity comparison") | ||
st.line_chart(activity_df) | ||
else: | ||
st.markdown("No members selected.") |
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
14 changes: 14 additions & 0 deletions
14
...s/sharing-editor/public/samples/011_component_gallery/pages/execution.fragment_balloon.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,14 @@ | ||
import streamlit as st | ||
import asyncio | ||
|
||
|
||
@st.experimental_fragment | ||
def release_the_balloons(): | ||
st.button("Release the balloons", help="Fragment rerun") | ||
st.balloons() | ||
|
||
|
||
with st.spinner("Inflating balloons..."): | ||
await asyncio.sleep(5) | ||
release_the_balloons() | ||
st.button("Inflate more balloons", help="Full rerun") |
7 changes: 7 additions & 0 deletions
7
...haring-editor/public/samples/011_component_gallery/pages/layout.columns_bottom_widgets.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,7 @@ | ||
import streamlit as st | ||
|
||
left, middle, right = st.columns(3, vertical_alignment="bottom") | ||
|
||
left.text_input("Write something") | ||
middle.button("Click me", use_container_width=True) | ||
right.checkbox("Check me") |
14 changes: 14 additions & 0 deletions
14
...ng-editor/public/samples/011_component_gallery/pages/layout.columns_vertical_alignment.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,14 @@ | ||
import streamlit as st | ||
import numpy as np | ||
|
||
vertical_alignment = st.selectbox( | ||
"Vertical alignment", ["top", "center", "bottom"], index=2 | ||
) | ||
|
||
left, middle, right = st.columns(3, vertical_alignment=vertical_alignment) | ||
left.image("https://static.streamlit.io/examples/cat.jpg") | ||
left.markdown("By [@phonvanna](https://unsplash.com/photos/0g7BJEXq7sU)") | ||
middle.image("https://static.streamlit.io/examples/dog.jpg") | ||
middle.markdown("By [@shotbyrain](https://unsplash.com/photos/rmkIqi_C3cA)") | ||
right.image("https://static.streamlit.io/examples/owl.jpg") | ||
right.markdown("By [@zmachacek](https://unsplash.com/photos/ZN4CzqizIyI)") |
10 changes: 1 addition & 9 deletions
10
packages/sharing-editor/public/samples/011_component_gallery/pages/utilities.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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
import streamlit as st | ||
|
||
code = """ | ||
<style> | ||
p { | ||
color: red; | ||
} | ||
</style> | ||
""" | ||
st.html(code) | ||
st.markdown("Lorem ipsum") | ||
st.html("<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>") |
Binary file not shown.
Oops, something went wrong.