Spaces:
Running
Running
Update app_pyvis_new.py
Browse files- app_pyvis_new.py +6 -1
app_pyvis_new.py
CHANGED
|
@@ -48,9 +48,14 @@ 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 |
-
|
|
|
|
|
|
|
| 52 |
|
| 53 |
net.toggle_physics(True)
|
|
|
|
|
|
|
|
|
|
| 54 |
html = net.generate_html().replace("'", "\"")
|
| 55 |
return html
|
| 56 |
except Exception:
|
|
|
|
| 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 |
+
# Added one line to ensure big nodes don't overlap labels
|
| 57 |
+
net.set_options('{"physics": {"forceAtlas2Based": {"avoidOverlap": 1}}, "solver": "forceAtlas2Based"}')
|
| 58 |
+
|
| 59 |
html = net.generate_html().replace("'", "\"")
|
| 60 |
return html
|
| 61 |
except Exception:
|