alidenewade commited on
Commit
1b8e9ed
·
verified ·
1 Parent(s): 9a2f907

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -27
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
- with gr.Column(scale=1):
359
- gr.Markdown("### Controls")
360
- metric_selector = gr.Dropdown(
361
- label="Select Metric",
362
- choices=['crime_total', 'sr311_total', 'dob_permits_total'],
363
- value='crime_total'
364
- )
365
-
366
- # Get date range from data
367
- min_date = panel_df['month'].min().strftime('%Y-%m-%d')
368
- max_date = panel_df['month'].max().strftime('%Y-%m-%d')
369
 
370
- start_date_picker = gr.Textbox(
371
- label="Start Date (YYYY-MM-DD)",
372
- value=min_date,
373
- placeholder="2023-01-01"
374
- )
375
- end_date_picker = gr.Textbox(
376
- label="End Date (YYYY-MM-DD)",
377
- value=max_date,
378
- placeholder="2023-12-31"
379
- )
380
-
381
- update_button = gr.Button("Update Dashboard")
 
 
382
 
383
- with gr.Column(scale=3):
384
- gr.Markdown("### Visualizations")
385
- map_plot = gr.Plot()
386
- ts_plot = gr.Plot()
 
 
 
 
 
 
 
 
 
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):