|
17 | 17 | from geopolitical_app import create_threat_density_map |
18 | 18 | from pages.chart1 import create_3d_surface_figure |
19 | 19 | from pages.chart3 import create_3d_scatter_figure, create_choropleth_figure |
| 20 | +from pages.choropleth_map import create_choropleth_map |
20 | 21 | from pages.chart4 import create_radar_figure |
21 | 22 | from pages.chart5 import create_heatmap_figure |
22 | 23 | from pages.chart7 import create_connection_map_figure |
23 | 24 | from chart_data import get_data, filter_data |
24 | 25 |
|
| 26 | + |
| 27 | +def combine_choropleth_with_chart(fig_chart, chart_title): |
| 28 | + """Combine a chart with a choropleth map overlay.""" |
| 29 | + from plotly.subplots import make_subplots |
| 30 | + |
| 31 | + fig_choropleth = create_choropleth_map("Geographic Overview") |
| 32 | + |
| 33 | + combined_fig = make_subplots( |
| 34 | + rows=2, cols=1, |
| 35 | + subplot_titles=("Geographic Overview", chart_title), |
| 36 | + specs=[[{"type": "geo"}], [{"type": fig_chart.data[0].type if fig_chart.data else "scatter"}]], |
| 37 | + vertical_spacing=0.15 |
| 38 | + ) |
| 39 | + |
| 40 | + # Add choropleth traces |
| 41 | + for trace in fig_choropleth.data: |
| 42 | + combined_fig.add_trace(trace, row=1, col=1) |
| 43 | + |
| 44 | + # Add chart traces |
| 45 | + for trace in fig_chart.data: |
| 46 | + combined_fig.add_trace(trace, row=2, col=1) |
| 47 | + |
| 48 | + # Update layout |
| 49 | + combined_fig.update_layout( |
| 50 | + height=1200, |
| 51 | + showlegend=True, |
| 52 | + title_text=chart_title |
| 53 | + ) |
| 54 | + |
| 55 | + return combined_fig |
| 56 | + |
25 | 57 | def wrap_with_filters_and_nav(html_content, chart_id, chart_title, filters_html=""): |
26 | 58 | """Wrap chart HTML with navigation and filters""" |
27 | 59 |
|
@@ -270,7 +302,8 @@ def main(): |
270 | 302 | # Chart 1: Supplier Influence with filters |
271 | 303 | print("📊 Chart 1: Supplier Influence Surface") |
272 | 304 | try: |
273 | | - fig = create_3d_surface_figure("Influence", True) |
| 305 | + fig_chart = create_3d_surface_figure("Influence", True) |
| 306 | + fig = combine_choropleth_with_chart(fig_chart, "Supplier Influence Surface") |
274 | 307 | html = fig.to_html(include_plotlyjs='cdn') |
275 | 308 | filters_html = ''' |
276 | 309 | <div class="filter-group"> |
@@ -351,7 +384,8 @@ def main(): |
351 | 384 | # Chart 4: Multi-Country Radar with filters |
352 | 385 | print("�� Chart 4: Multi-Country Radar") |
353 | 386 | try: |
354 | | - fig = create_radar_figure(None, "influence") |
| 387 | + fig_chart = create_radar_figure(None, "influence") |
| 388 | + fig = combine_choropleth_with_chart(fig_chart, "Multi-Country Radar Analysis") |
355 | 389 | html = fig.to_html(include_plotlyjs='cdn') |
356 | 390 | filters_html = ''' |
357 | 391 | <div class="filter-group"> |
@@ -381,7 +415,8 @@ def main(): |
381 | 415 | # Chart 5: Priorities Heatmap with filters |
382 | 416 | print("📊 Chart 5: Priorities Heatmap") |
383 | 417 | try: |
384 | | - fig = create_heatmap_figure("country", "influence") |
| 418 | + fig_chart = create_heatmap_figure("country", "influence") |
| 419 | + fig = combine_choropleth_with_chart(fig_chart, "Priorities Heatmap") |
385 | 420 | html = fig.to_html(include_plotlyjs='cdn') |
386 | 421 | filters_html = ''' |
387 | 422 | <div class="filter-group"> |
@@ -410,7 +445,8 @@ def main(): |
410 | 445 | # Chart 7: Supplier Connections with filters |
411 | 446 | print("📊 Chart 7: Supplier Connections") |
412 | 447 | try: |
413 | | - fig = create_connection_map_figure("all") |
| 448 | + fig_chart = create_connection_map_figure("all") |
| 449 | + fig = combine_choropleth_with_chart(fig_chart, "Supplier Connections") |
414 | 450 | html = fig.to_html(include_plotlyjs='cdn') |
415 | 451 | filters_html = ''' |
416 | 452 | <div class="filter-group"> |
|
0 commit comments