forked from streamlit/streamlit-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5bb3896
Showing
3 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Welcome to Streamlit! | ||
|
||
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart: | ||
|
||
If you have any questions, checkout out our [documentation](https://docs.streamlit.io) and | ||
[community forums](https://discuss.streamlit.io). |
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,3 @@ | ||
altair | ||
pandas | ||
streamlit |
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,38 @@ | ||
from collections import namedtuple | ||
import altair as alt | ||
import math | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
""" | ||
# Welcome to Streamlit! | ||
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart: | ||
If you have any questions, checkout out our [documentation](https://docs.streamlit.io) and | ||
[community forums](https://discuss.streamlit.io). | ||
In the meantime, below is an example of what you can do with just a few lines of code: | ||
""" | ||
|
||
|
||
with st.echo(code_location='below'): | ||
total_points = st.slider("Number of points in spiral", 1, 5000, 2000) | ||
num_turns = st.slider("Number of turns in spiral", 1, 100, 9) | ||
|
||
Point = namedtuple('Point', 'x y') | ||
data = [] | ||
|
||
points_per_turn = total_points / num_turns | ||
|
||
for curr_point_num in range(total_points): | ||
curr_turn, i = divmod(curr_point_num, points_per_turn) | ||
angle = (curr_turn + 1) * 2 * math.pi * i / points_per_turn | ||
radius = curr_point_num / total_points | ||
x = radius * math.cos(angle) | ||
y = radius * math.sin(angle) | ||
data.append(Point(x, y)) | ||
|
||
st.altair_chart(alt.Chart(pd.DataFrame(data), height=500, width=500) | ||
.mark_circle(color='#0068c9', opacity=0.5) | ||
.encode(x='x:Q', y='y:Q')) |