Dev1107 commited on
Commit
04c5a65
·
verified ·
1 Parent(s): 8edf3dd

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +28 -11
src/streamlit_app.py CHANGED
@@ -1,19 +1,36 @@
 
1
  import altair as alt
2
  import numpy as np
3
  import pandas as pd
4
- import streamlit as st
5
 
6
- """
7
- # Welcome to Streamlit!
8
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
9
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
10
- forums](https://discuss.streamlit.io).
11
- In the meantime, below is an example of what you can do with just a few lines of code:
12
- """
13
 
14
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
15
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
 
 
 
16
 
17
  indices = np.linspace(0, 1, num_points)
18
  theta = 2 * np.pi * num_turns * indices
19
- radius = indices
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
  import altair as alt
3
  import numpy as np
4
  import pandas as pd
 
5
 
6
+ st.set_page_config(page_title="Spiral Demo", layout="centered")
 
 
 
 
 
 
7
 
8
+ st.title("🎨 Spiral Generator with Streamlit")
9
+ st.write("Adjust the sliders to generate a customizable spiral. Perfect for HuggingFace Spaces!")
10
+
11
+ num_points = st.slider("Number of points in the spiral", 100, 10000, 1500)
12
+ num_turns = st.slider("Number of turns in the spiral", 1, 300, 30)
13
 
14
  indices = np.linspace(0, 1, num_points)
15
  theta = 2 * np.pi * num_turns * indices
16
+ radius = indices
17
+
18
+ x = radius * np.cos(theta)
19
+ y = radius * np.sin(theta)
20
+
21
+ df = pd.DataFrame({"x": x, "y": y, "t": indices})
22
+
23
+ chart = (
24
+ alt.Chart(df)
25
+ .mark_line(color="orange")
26
+ .encode(
27
+ x="x:Q",
28
+ y="y:Q",
29
+ tooltip=["x", "y", "t"]
30
+ )
31
+ .properties(width=600, height=600)
32
+ )
33
+
34
+ st.altair_chart(chart, use_container_width=True)
35
+
36
+ st.write("Made for HuggingFace Spaces 🚀")