Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -354,36 +354,48 @@ with gr.Blocks() as demo:
|
|
354 |
|
355 |
with gr.Tab("Dashboard"):
|
356 |
gr.Markdown("## Exploratory Data Analysis of NYC Urban Data")
|
|
|
|
|
357 |
with gr.Row():
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
max_date = panel_df['month'].max().strftime('%Y-%m-%d')
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
|
|
|
|
382 |
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
|
388 |
# Function to update both plots at once
|
389 |
def update_dashboard(metric, start_date, end_date):
|
|
|
354 |
|
355 |
with gr.Tab("Dashboard"):
|
356 |
gr.Markdown("## Exploratory Data Analysis of NYC Urban Data")
|
357 |
+
|
358 |
+
# Horizontal controls layout
|
359 |
with gr.Row():
|
360 |
+
metric_selector = gr.Dropdown(
|
361 |
+
label="Select Metric",
|
362 |
+
choices=['crime_total', 'sr311_total', 'dob_permits_total'],
|
363 |
+
value='crime_total',
|
364 |
+
scale=2
|
365 |
+
)
|
366 |
+
|
367 |
+
# Get date range from data
|
368 |
+
min_date = panel_df['month'].min().strftime('%Y-%m-%d')
|
369 |
+
max_date = panel_df['month'].max().strftime('%Y-%m-%d')
|
|
|
370 |
|
371 |
+
start_date_picker = gr.Textbox(
|
372 |
+
label="Start Date (YYYY-MM-DD)",
|
373 |
+
value=min_date,
|
374 |
+
placeholder="2023-01-01",
|
375 |
+
scale=1
|
376 |
+
)
|
377 |
+
end_date_picker = gr.Textbox(
|
378 |
+
label="End Date (YYYY-MM-DD)",
|
379 |
+
value=max_date,
|
380 |
+
placeholder="2023-12-31",
|
381 |
+
scale=1
|
382 |
+
)
|
383 |
+
|
384 |
+
update_button = gr.Button("Update Dashboard", scale=1)
|
385 |
|
386 |
+
# Side-by-side visualizations
|
387 |
+
with gr.Row():
|
388 |
+
with gr.Column(scale=1):
|
389 |
+
gr.Markdown("### Spatial Distribution")
|
390 |
+
# Initialize with default data
|
391 |
+
initial_map = create_choropleth_map('crime_total', min_date, max_date)
|
392 |
+
map_plot = gr.Plot(value=initial_map)
|
393 |
+
|
394 |
+
with gr.Column(scale=1):
|
395 |
+
gr.Markdown("### Time Series Analysis")
|
396 |
+
# Initialize with default data
|
397 |
+
initial_ts = create_time_series_plot('crime_total', min_date, max_date)
|
398 |
+
ts_plot = gr.Plot(value=initial_ts)
|
399 |
|
400 |
# Function to update both plots at once
|
401 |
def update_dashboard(metric, start_date, end_date):
|