Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,15 +14,18 @@ num_dots = st.number_input('Number of dots', min_value=1, max_value=10, value=5)
|
|
14 |
chart_placeholder = st.empty()
|
15 |
|
16 |
while True: # This loop will simulate real-time data updates
|
17 |
-
#
|
18 |
-
|
19 |
|
20 |
# Generate random x and y positions within the specified radius for the specified number of dots
|
21 |
for _ in range(num_dots):
|
22 |
new_x = random.uniform(-radius, radius)
|
23 |
new_y = random.uniform(-radius, radius)
|
24 |
-
# Append the new data point to the
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
# Create a new Plotly figure for the scatter plot
|
28 |
fig = px.scatter(new_data, x='x', y='y', title="Random Dots within a Radius")
|
|
|
14 |
chart_placeholder = st.empty()
|
15 |
|
16 |
while True: # This loop will simulate real-time data updates
|
17 |
+
# Create a list to hold the new data points
|
18 |
+
new_data_points = []
|
19 |
|
20 |
# Generate random x and y positions within the specified radius for the specified number of dots
|
21 |
for _ in range(num_dots):
|
22 |
new_x = random.uniform(-radius, radius)
|
23 |
new_y = random.uniform(-radius, radius)
|
24 |
+
# Append the new data point as a dictionary to the list
|
25 |
+
new_data_points.append({'x': new_x, 'y': new_y})
|
26 |
+
|
27 |
+
# Create a new DataFrame from the list of new data points
|
28 |
+
new_data = pd.DataFrame(new_data_points)
|
29 |
|
30 |
# Create a new Plotly figure for the scatter plot
|
31 |
fig = px.scatter(new_data, x='x', y='y', title="Random Dots within a Radius")
|