Skip to content

Commit 24edc15

Browse files
committed
fix: Allow edges to have both names and weights
1 parent 85eaf63 commit 24edc15

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/features/graph-view/components/Edges.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export function Edges({ positionedEdges, arrangement, highlights }: EdgesProps)
2222
const { x: toX, y: toY } = arrangement[edge.to] ?? centerPosition;
2323
const isCircular = edge.from === edge.to;
2424

25+
let name = edge.name ?? undefined;
26+
if (edge.weight !== null) {
27+
if (name) {
28+
name += `: ${edge.weight}`;
29+
} else {
30+
name = edge.weight.toString();
31+
}
32+
}
33+
2534
return (
2635
<Edge
2736
key={edge.id}
@@ -34,7 +43,7 @@ export function Edges({ positionedEdges, arrangement, highlights }: EdgesProps)
3443
circular={isCircular}
3544
color={color}
3645
thicken={!!color}
37-
name={edge.weight?.toString() ?? edge.name ?? undefined}
46+
name={name}
3847
/>
3948
);
4049
});

0 commit comments

Comments
 (0)