Skip to content

Diagram enhancements #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Diagram enhancements #578

wants to merge 7 commits into from

Conversation

pau-hedgehog
Copy link
Contributor

fixes some cosmetic bugs (overlapping labels) and improves diagram rendering for more complex topologies, such as 3 spine ones

@pau-hedgehog pau-hedgehog self-assigned this May 5, 2025
@pau-hedgehog pau-hedgehog requested review from a team as code owners May 5, 2025 09:45
@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch 2 times, most recently from aba7bd4 to c4f796b Compare May 5, 2025 21:08
var nodes []Node

func GenerateDrawio(workDir string, topo Topology, styleType StyleType, outputPath string) error {
slog.Debug("Initializing new diagram generation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any value in that log message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like not :)

@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch from c4f796b to a7628e0 Compare May 6, 2025 13:34
@pau-hedgehog pau-hedgehog requested a review from Frostman May 6, 2025 13:41
@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch 2 times, most recently from 9db6eec to ed23ae2 Compare May 6, 2025 16:29
@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch 3 times, most recently from 5a5e832 to 0fc5e00 Compare May 13, 2025 11:45
@pau-hedgehog pau-hedgehog requested a review from a team as a code owner May 13, 2025 11:45
@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch 3 times, most recently from 72a648d to 8540b5c Compare May 16, 2025 10:55
Copy link
Member

@Frostman Frostman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good, 2 main comments:

  • introduce constants for all magic strings
  • remove all print debug mesages, I didn't mark all occurances, but we shouldn't have print debug in the code
  • remove warn logs that wouldn't mean anything to the end user

var nodes []Node

func GenerateDrawio(workDir string, topo Topology, styleType StyleType, outputPath string) error {
slog.Debug("Initializing new diagram generation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like not :)


for _, link := range links {
// First check for MCLAG links which use "mclagType" property
if mclagType, ok := link.Properties["mclagType"]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please introduce constants for all those strings? it looks very error-prone for future edits right now. Like "mclagType", "mclag_peer", "mclag_session", etc


connectionType := getConnectionType(group.Source, group.Target)

slog.Debug("Processing edge group",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't have any debug messages like that. It seems to be print debug during dev.

sx, sy := fixedConnectionPoint(sourceCell, tgtCenterX, tgtCenterY)
tx, ty := fixedConnectionPoint(targetCell, srcCenterX, srcCenterY)

slog.Debug("Connection centers",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

"targetCenterY", tgtCenterY)

// Calculate connection points
slog.Debug("Calculating optimal connection point for source", "source", group.Source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

srcDefaultX := sourceCell.Geometry.X + sx*float64(sourceCell.Geometry.Width)
srcDefaultY := sourceCell.Geometry.Y + sy*float64(sourceCell.Geometry.Height)
tgtDefaultX := targetCell.Geometry.X + tx*float64(targetCell.Geometry.Width)
tgtDefaultY := targetCell.Geometry.Y + ty*float64(targetCell.Geometry.Height)

slog.Debug("Base connection line",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

vx := tgtDefaultX - srcDefaultX
vy := tgtDefaultY - srcDefaultY
baseLength := math.Sqrt(vx*vx + vy*vy)
if baseLength == 0 {
baseLength = 1
slog.Warn("Zero length edge, using default length of 1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it mean anything to the user? If we can handle it there should be no warn log

px := -uy
py := ux

slog.Debug("Edge vectors",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

var verticalOffset float64
if isLeafToLeaf {
verticalOffset = 12.0
slog.Debug("Leaf-to-leaf connection detected", "verticalOffset", verticalOffset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

// Check for spine-to-distant-leaf connection that needs special handling
isSpineToDistantLeaf, spineLeafOffset := calculateSpineToLeafOffset(group.Source, group.Target, cellMap)
if isSpineToDistantLeaf {
slog.Debug("Spine-to-distant-leaf connection detected", "verticalOffset", spineLeafOffset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

changes labels to text boxes instead of inline

fixes vertical edge label overlap and better style

Signed-off-by: Pau Capdevila <[email protected]>
- Improve edge routing with better connection point distribution
- Enhance label positioning for better readability
- Fix overlapping connections with offsets
- Generate legend based on connections present

Signed-off-by: Pau Capdevila <[email protected]>
groups parallel spine connections for clarity

Signed-off-by: Pau Capdevila <[email protected]>
add legend to mermaid diagram

Signed-off-by: Pau Capdevila <[email protected]>
adds output name option

adds just targets for different vlab diagrams
adds just target for lab-ci env

Signed-off-by: Pau Capdevila <[email protected]>
Signed-off-by: Pau Capdevila <[email protected]>
@pau-hedgehog pau-hedgehog force-pushed the pau/fix_diagram_labels branch from 2e43f89 to 867691d Compare June 26, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants