File size: 3,232 Bytes
4d935c6
 
 
 
 
6aab391
4afe0d8
 
6aab391
4afe0d8
 
4d935c6
6aab391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4afe0d8
 
 
 
 
 
 
e696fe3
 
4afe0d8
 
4d935c6
6aab391
4afe0d8
4d935c6
4afe0d8
e696fe3
4afe0d8
 
 
4d935c6
4afe0d8
4d935c6
 
 
 
 
 
 
 
 
 
 
 
4afe0d8
4d935c6
4afe0d8
e696fe3
4afe0d8
6aab391
4afe0d8
 
 
 
6aab391
4afe0d8
 
 
 
6aab391
 
4afe0d8
 
6aab391
 
 
4afe0d8
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st

# 1. Force the page configuration to a clean wide layout
st.set_page_config(
    page_title="Interactive Spiral Visualizer", 
    page_icon="📊",
    layout="wide"
)

# 2. Custom CSS to absolutely force white backgrounds, blue headings, and crisp black text
st.markdown(
    """
    <style>
    /* Force main app background to pure white and text to solid black */
    .stApp {
        background-color: #FFFFFF !important;
        color: #000000 !important;
    }
    
    /* Style all main text, body markdown, and labels to crisp black */
    p, span, label, .stSlider p, .stMarkdown p {
        color: #000000 !important;
        font-weight: 500 !important;
    }
    
    /* Force headings to a brilliant, clean blue */
    h1, h2, h3, .blue-heading {
        color: #1E3A8A !important; /* Premium Navy/Corporate Blue */
        font-weight: 700 !important;
    }
    
    /* Clean styling for links */
    a {
        color: #2563EB !important;
        text-decoration: underline !important;
    }
    </style>
    """,
    unsafe_transform=True,
)

# 3. Clean Header Section (Inherits Blue Headings and Black Text)
st.markdown("<h1>✨ Welcome to Streamlit!</h1>", unsafe_html=True)
st.markdown(
    """
    Edit `/streamlit_app.py` to customize this app to your heart's desire ❤️.  
    If you have any questions, check out our [documentation](https://docs.streamlit.io) 
    and [community forums](https://discuss.streamlit.io).
    
    ---
    ### **Example Simulation**
    *Adjust the controls on the left to watch the spiral update in real-time.*
    """
)

# 4. Two-Column Layout (Controls on the left, Chart on the right)
col1, col2 = st.columns([1, 2], gap="large")

with col1:
    st.markdown("### **🎛️ Control Panel**")
    with st.container(border=True):  
        num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
        num_turns = st.slider("Number of turns in spiral", 1, 300, 31)

# --- EXACTLY UNCHANGED DATA LOGIC ---
indices = np.linspace(0, 1, num_points)
theta = 2 * np.pi * num_turns * indices
radius = indices
x = radius * np.cos(theta)
y = radius * np.sin(theta)

df = pd.DataFrame({
    "x": x,
    "y": y,
    "idx": indices,
    "rand": np.random.randn(num_points),
})
# -----------------------------------

with col2:
    st.markdown("### **📊 Generated Visualization**")
    
    # 5. Styled Altair Chart matching the White & Blue aesthetic
    chart = (
        alt.Chart(df, height=600, width=600)
        .mark_point(
            filled=True, 
            opacity=0.85
        )
        .encode(
            x=alt.X("x", axis=None),
            y=alt.Y("y", axis=None),
            # CHANGED: 'blues' scheme creates a premium transition from soft light blue to deep royal blue
            color=alt.Color("idx", legend=None, scale=alt.Scale(scheme="blues")),
            size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
        )
        .configure_view(
            strokeWidth=0 # Removes any unnecessary dark bounding boxes around the chart
        )
    )
    
    # Render the chart responsively
    st.altair_chart(chart, use_container_width=True)