Skip to content

Commit 85d2500

Browse files
DanShepsjeremystretch
authored andcommitted
Fixes: netbox-community#15948 - Fixes cable fanin/fanout when both are required (netbox-community#15953)
* Preliminary fix for netbox-community#15948 * Tweaking of line height
1 parent 552c815 commit 85d2500

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

netbox/dcim/svg/cables.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
LINE_HEIGHT = 20
1818
FANOUT_HEIGHT = 35
1919
FANOUT_LEG_HEIGHT = 15
20-
CABLE_HEIGHT = 4 * LINE_HEIGHT + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT
20+
CABLE_HEIGHT = 5 * LINE_HEIGHT + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT
2121

2222

2323
class Node(Hyperlink):
@@ -405,7 +405,17 @@ def render(self):
405405
end = far[0].top_center
406406
text_offset = 0
407407

408-
if len(near) > 1:
408+
if len(near) > 1 and len(far) > 1:
409+
start_center = sum([pos.bottom_center[0] for pos in near]) / len(near)
410+
end_center = sum([pos.bottom_center[0] for pos in far]) / len(far)
411+
center_x = (start_center + end_center) / 2
412+
413+
start = (center_x, start[1] + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
414+
end = (center_x, end[1] - FANOUT_HEIGHT - FANOUT_LEG_HEIGHT)
415+
text_offset -= (FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
416+
self.draw_fanin(start, near, color)
417+
self.draw_fanout(end, far, color)
418+
elif len(near) > 1:
409419
# Handle Fan-In - change start position to be directly below start
410420
start = (end[0], start[1] + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
411421
self.draw_fanin(start, near, color)

0 commit comments

Comments
 (0)