Spaces:
Running
Running
Update app_pyvis_new.py
Browse files- app_pyvis_new.py +9 -5
app_pyvis_new.py
CHANGED
|
@@ -48,13 +48,17 @@ def plot_cgraph_pyvis(grp):
|
|
| 48 |
net.add_node(str(src), label=str(src), shape="circle", color="#ADD8E6", font={'size': 14, 'color': '#000000'})
|
| 49 |
net.add_node(str(tgt), label=str(tgt), shape="circle", color="#ADD8E6", font={'size': 14, 'color': '#000000'})
|
| 50 |
color = edge_colors_dict.get(str(rel).lower(), "#95a5a6")
|
| 51 |
-
# Minimal change: added length, font alignment, and arrow scaleFactor
|
| 52 |
net.add_edge(str(src), str(tgt), label=str(rel), color=color, width=2,
|
| 53 |
-
length=250, font={'align': 'top'}, arrows={'to': {'scaleFactor': 1.5}})
|
| 54 |
|
| 55 |
net.toggle_physics(True)
|
| 56 |
-
#
|
| 57 |
-
net.set_options(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
html = net.generate_html().replace("'", "\"")
|
| 60 |
return html
|
|
@@ -113,7 +117,7 @@ with gr.Blocks(title="Disaster Storylines Explorer") as interface:
|
|
| 113 |
# Header Section
|
| 114 |
gr.Markdown(
|
| 115 |
"""
|
| 116 |
-
#
|
| 117 |
Maintained by **Joint Research Centre (JRC)** Units E1, F7, and T5, this dashboard provides narratives and knowledge graphs for over 3,000 disaster events (EM-DAT).
|
| 118 |
These records were generated using a **Retrieval-Augmented Generation (RAG)** pipeline on **Europe Media Monitor (EMM)** news using **Meta-Llama-3-70B-Instruct** via **GPT@JRC**.
|
| 119 |
Graphs visualize simplified causal dynamics restricted to *'causes'* and *'prevents'* relationships.
|
|
|
|
| 48 |
net.add_node(str(src), label=str(src), shape="circle", color="#ADD8E6", font={'size': 14, 'color': '#000000'})
|
| 49 |
net.add_node(str(tgt), label=str(tgt), shape="circle", color="#ADD8E6", font={'size': 14, 'color': '#000000'})
|
| 50 |
color = edge_colors_dict.get(str(rel).lower(), "#95a5a6")
|
|
|
|
| 51 |
net.add_edge(str(src), str(tgt), label=str(rel), color=color, width=2,
|
| 52 |
+
length=250, font={'align': 'top'}, arrows={'to': {'enabled': True, 'scaleFactor': 1.5}})
|
| 53 |
|
| 54 |
net.toggle_physics(True)
|
| 55 |
+
# Fix: We must explicitly enable arrows inside set_options because it can override the constructor
|
| 56 |
+
net.set_options("""
|
| 57 |
+
{
|
| 58 |
+
"edges": { "arrows": { "to": { "enabled": true } } },
|
| 59 |
+
"physics": { "forceAtlas2Based": { "avoidOverlap": 1 }, "solver": "forceAtlas2Based" }
|
| 60 |
+
}
|
| 61 |
+
""")
|
| 62 |
|
| 63 |
html = net.generate_html().replace("'", "\"")
|
| 64 |
return html
|
|
|
|
| 117 |
# Header Section
|
| 118 |
gr.Markdown(
|
| 119 |
"""
|
| 120 |
+
# Disaster Storylines & Knowledge Graphs Explorer
|
| 121 |
Maintained by **Joint Research Centre (JRC)** Units E1, F7, and T5, this dashboard provides narratives and knowledge graphs for over 3,000 disaster events (EM-DAT).
|
| 122 |
These records were generated using a **Retrieval-Augmented Generation (RAG)** pipeline on **Europe Media Monitor (EMM)** news using **Meta-Llama-3-70B-Instruct** via **GPT@JRC**.
|
| 123 |
Graphs visualize simplified causal dynamics restricted to *'causes'* and *'prevents'* relationships.
|