danielrosehill Claude commited on
Commit
18f002e
·
1 Parent(s): 2bedd25

Redesign UI with country-first and category-first exploration modes

Browse files

- Add two distinct exploration tabs: "Explore by Country" and "Explore by Category"
- Country mode: Select countries first, then optionally filter by categories
- Category mode: Select categories first, then optionally filter by countries
- Update UI with clear instructions for each exploration path
- Make primary selection required and secondary filter optional
- Improve user experience with focused navigation paths

This addresses the requirement to allow users to explore data starting from
either country or category as their primary dimension.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +35 -15
app.py CHANGED
@@ -231,23 +231,42 @@ with gr.Blocks(title="GVFD Navigator", theme=gr.themes.Soft()) as demo:
231
  **Data Source**: [IFVI Global Value Factor Database V2](https://huggingface.co/datasets/danielrosehill/Global-Value-Factor-Database-Refactor-V2)
232
  """)
233
 
234
- with gr.Row():
235
- with gr.Column(scale=1):
236
- gr.Markdown("### Filters")
 
 
 
237
  country_selector = gr.Dropdown(
238
  choices=get_countries(),
239
  multiselect=True,
240
- label="Select Countries",
241
- info="Leave empty to show all countries"
242
  )
243
- category_selector = gr.CheckboxGroup(
244
  choices=get_categories(),
245
- label="Select Categories",
246
- info="Leave empty to show all categories"
247
  )
 
248
 
249
- gr.Markdown("---")
250
- refresh_btn = gr.Button("Update Visualizations", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
  with gr.Row():
253
  with gr.Column():
@@ -423,16 +442,17 @@ with gr.Blocks(title="GVFD Navigator", theme=gr.themes.Soft()) as demo:
423
  get_data_table(countries, categories)
424
  )
425
 
426
- refresh_btn.click(
 
427
  fn=update_all,
428
- inputs=[country_selector, category_selector],
429
  outputs=[bar_chart, map_chart, comparison_chart, box_plot, stats_output, data_table]
430
  )
431
 
432
- # Load initial visualizations
433
- demo.load(
434
  fn=update_all,
435
- inputs=[country_selector, category_selector],
436
  outputs=[bar_chart, map_chart, comparison_chart, box_plot, stats_output, data_table]
437
  )
438
 
 
231
  **Data Source**: [IFVI Global Value Factor Database V2](https://huggingface.co/datasets/danielrosehill/Global-Value-Factor-Database-Refactor-V2)
232
  """)
233
 
234
+ with gr.Tabs() as exploration_mode:
235
+ with gr.Tab("Explore by Country"):
236
+ gr.Markdown("""
237
+ ### Select a Country
238
+ Choose one or more countries to see all their environmental value factors across different categories.
239
+ """)
240
  country_selector = gr.Dropdown(
241
  choices=get_countries(),
242
  multiselect=True,
243
+ label="Select Country/Countries",
244
+ info="Start typing to search..."
245
  )
246
+ country_category_filter = gr.CheckboxGroup(
247
  choices=get_categories(),
248
+ label="Filter by Categories (Optional)",
249
+ info="Leave empty to show all categories for selected countries"
250
  )
251
+ country_refresh_btn = gr.Button("Show Country Data", variant="primary", size="lg")
252
 
253
+ with gr.Tab("Explore by Category"):
254
+ gr.Markdown("""
255
+ ### Select a Category
256
+ Choose an environmental impact category to compare value factors across different countries.
257
+ """)
258
+ category_selector = gr.Dropdown(
259
+ choices=get_categories(),
260
+ multiselect=True,
261
+ label="Select Category/Categories"
262
+ )
263
+ category_country_filter = gr.Dropdown(
264
+ choices=get_countries(),
265
+ multiselect=True,
266
+ label="Filter by Countries (Optional)",
267
+ info="Leave empty to show all countries for selected categories"
268
+ )
269
+ category_refresh_btn = gr.Button("Show Category Data", variant="primary", size="lg")
270
 
271
  with gr.Row():
272
  with gr.Column():
 
442
  get_data_table(countries, categories)
443
  )
444
 
445
+ # Handler for country exploration mode
446
+ country_refresh_btn.click(
447
  fn=update_all,
448
+ inputs=[country_selector, country_category_filter],
449
  outputs=[bar_chart, map_chart, comparison_chart, box_plot, stats_output, data_table]
450
  )
451
 
452
+ # Handler for category exploration mode
453
+ category_refresh_btn.click(
454
  fn=update_all,
455
+ inputs=[category_country_filter, category_selector],
456
  outputs=[bar_chart, map_chart, comparison_chart, box_plot, stats_output, data_table]
457
  )
458