Position edge labels near their respective nodes

This commit is contained in:
Ian Gulliver
2026-01-24 14:44:23 -08:00
parent 8acda6902d
commit 77e523a302

View File

@@ -114,16 +114,13 @@
const idB = idMap.get(link.node_b?.typeid); const idB = idMap.get(link.node_b?.typeid);
if (!idA || !idB) return; if (!idA || !idB) return;
let label = '';
if (link.interface_a) label = link.interface_a;
if (link.interface_b) label += (label ? ' ↔ ' : '') + link.interface_b;
elements.push({ elements.push({
data: { data: {
id: 'e' + i, id: 'e' + i,
source: idA, source: idA,
target: idB, target: idB,
label: label sourceLabel: link.interface_a || '',
targetLabel: link.interface_b || ''
} }
}); });
}); });
@@ -167,13 +164,17 @@
'width': 2, 'width': 2,
'line-color': '#666', 'line-color': '#666',
'curve-style': 'bezier', 'curve-style': 'bezier',
'label': 'data(label)', 'source-label': 'data(sourceLabel)',
'target-label': 'data(targetLabel)',
'source-text-offset': 40,
'target-text-offset': 40,
'source-text-rotation': 'autorotate',
'target-text-rotation': 'autorotate',
'font-size': 9, 'font-size': 9,
'color': '#aaa', 'color': '#aaa',
'text-background-color': '#1a1a1a', 'text-background-color': '#1a1a1a',
'text-background-opacity': 1, 'text-background-opacity': 1,
'text-background-padding': 2, 'text-background-padding': 2
'text-rotation': 'autorotate'
} }
} }
], ],