Spaces:
Runtime error
Runtime error
苏泓源
commited on
Commit
·
467801b
1
Parent(s):
9a6fd28
update
Browse files
app.py
CHANGED
@@ -5,31 +5,31 @@ import plotly.graph_objects as go
|
|
5 |
|
6 |
def demo_plot(city, facility):
|
7 |
fig = go.Figure()
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
fig.add_trace(go.Scatter(x=[1, 2, 3, 4
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
fig.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
# Convert Plotly figure to HTML
|
19 |
-
actual_fig_html = fig.to_html(full_html=False)
|
20 |
-
|
21 |
-
return actual_fig_html, actual_fig_html # Return the HTML for both actual and solution figures
|
22 |
-
|
23 |
with gr.Blocks() as demo:
|
24 |
with gr.Column():
|
25 |
city = gr.Radio(choices=["New York", "Boston", "Los Angeles", "Chicago"], value=["New York"], label="Select City:")
|
26 |
facility = gr.CheckboxGroup(choices=["School", "Hospital", "Park"], value=["Hospital"], label="Select Facility:")
|
27 |
btn = gr.Button(value="Generate")
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
demo.load(demo_plot, [city, facility], actual_map, solution_map)
|
32 |
-
btn.click(demo_plot, [city, facility], actual_map, solution_map)
|
33 |
|
34 |
if __name__ == "__main__":
|
35 |
demo.launch()
|
|
|
5 |
|
6 |
def demo_plot(city, facility):
|
7 |
fig = go.Figure()
|
8 |
+
fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4, 5],
|
9 |
+
y=[1, 3, 2, 3, 1, 4],
|
10 |
+
mode='lines+markers',
|
11 |
+
name='City'))
|
12 |
+
fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4, 5],
|
13 |
+
y=[2, 5, 3, 1, 4, 2],
|
14 |
+
mode='lines+markers',
|
15 |
+
name='Facility'))
|
16 |
+
fig.update_layout(title='City and Facility',
|
17 |
+
xaxis_title='X',
|
18 |
+
yaxis_title='Y')
|
19 |
+
actual_fig = fig
|
20 |
+
solution_fig = fig
|
21 |
+
|
22 |
+
return actual_fig, solution_fig
|
23 |
+
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
with gr.Blocks() as demo:
|
26 |
with gr.Column():
|
27 |
city = gr.Radio(choices=["New York", "Boston", "Los Angeles", "Chicago"], value=["New York"], label="Select City:")
|
28 |
facility = gr.CheckboxGroup(choices=["School", "Hospital", "Park"], value=["Hospital"], label="Select Facility:")
|
29 |
btn = gr.Button(value="Generate")
|
30 |
+
map = gr.Plot()
|
31 |
+
demo.load(demo_plot, [city, facility], map)
|
32 |
+
btn.click(demo_plot, [city, facility], map)
|
|
|
|
|
33 |
|
34 |
if __name__ == "__main__":
|
35 |
demo.launch()
|