-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Diagram enhancements #578
Conversation
aba7bd4
to
c4f796b
Compare
var nodes []Node | ||
|
||
func GenerateDrawio(workDir string, topo Topology, styleType StyleType, outputPath string) error { | ||
slog.Debug("Initializing new diagram generation") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like not :)
c4f796b
to
a7628e0
Compare
9db6eec
to
ed23ae2
Compare
5a5e832
to
0fc5e00
Compare
72a648d
to
8540b5c
Compare
There was a problem hiding this 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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]>
Fixes #640 Signed-off-by: Pau Capdevila <[email protected]>
2e43f89
to
867691d
Compare
fixes some cosmetic bugs (overlapping labels) and improves diagram rendering for more complex topologies, such as 3 spine ones