-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
fix: Prevent Legend Labels from Overlapping Diagram Elements in Journey Diagrams #6274
base: develop
Are you sure you want to change the base?
fix: Prevent Legend Labels from Overlapping Diagram Elements in Journey Diagrams #6274
Conversation
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
Co-authored-by: Shahir Ahmed <ahmeds@dickinson.edu>
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
|
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6274 +/- ##
==========================================
- Coverage 3.88% 3.88% -0.01%
==========================================
Files 399 398 -1
Lines 42055 42084 +29
Branches 638 638
==========================================
Hits 1635 1635
- Misses 40420 40449 +29
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hey @sidharthv96, @pranavm2109 and I have fixed the issue with overlapping legend labels in Journey diagrams #5955. The fix ensures proper spacing by tracking the maximum width of legend text elements during the actor legend drawing phase and using this width to adjust the left margin for the diagram elements. We’ve also added E2E tests to verify that spacing remains correct for both normal and long labels. All GitHub tests and CICD checks are passing, and this is ready to be merged. Full details are in the PR description—let us know if you have any questions or feedback! |
…ations Co-authored-by: pranavm2109 <mishrap@dickinson.edu>
@@ -84,31 +90,32 @@ export const draw = function (text, id, version, diagObj) { | |||
}); | |||
|
|||
drawActorLegend(diagram); | |||
bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50); | |||
leftMargin = conf.leftMargin + maxWidth - 22.328125; |
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.
What is 22.328125
, please avoid magic numbers.
cy.then(() => { | ||
renderGraph( | ||
`journey | ||
title Web hook life cycle | ||
section Darkoob | ||
Make preBuilt:5: Darkoob user | ||
register slug : 5: Darkoob userf deliberately increasing the size of this label to check if distance between legend and diagram is maintained | ||
Map slug to a Prebuilt Job:5: Darkoob user | ||
section External Service | ||
set Darkoob slug as hook for an Event : 5 : admin Exjjjnjjjj qwerty | ||
listen to the events : 5 : External Service | ||
call darkoob endpoint : 5 : External Service | ||
section Darkoob | ||
check for inputs : 5 : DarkoobAPI | ||
run the prebuilt job : 5 : DarkoobAPI | ||
`, | ||
{ journey: { useMaxWidth: true } } | ||
); | ||
}); |
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.
Why is the cy.then required, when it's not used in other functions?
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
const textElement = svgDraw.drawText(diagram, labelData); | ||
const textLength = textElement.node().getBBox().width; | ||
if (textLength > maxWidth) { | ||
maxWidth = textLength; | ||
} |
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.
Not blocker: We should keep this dynamic width part, but should we split the text into more lines, if it's longer that a longer max limit?
…ttps://github.com/Shahir-47/mermaid into bug/5955_adjust-diagram-position-with-legend-width
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
Co-authored-by: Shahir Ahmed <ahmeds@dickinson.edu>
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
…lWidth Co-authored-by: Shahir Ahmed <ahmeds@dickinson.edu>
…fferent lines Co-authored-by: Shahir Ahmed <ahmeds@dickinson.edu>
…ttps://github.com/SeniorSeniorMath-SciLib2k24/mermaid into bug/5955_adjust-diagram-position-with-legend-width
Co-authored-by: Pranav Mishra <mishrap@dickinson.edu>
Hey @sidharthv96, In this PR, @pranavm2109 and I introduced a new journey theme variable called maxLabelWidth:
description: Maximum width of actor labels
type: integer
default: 360
minimum: 240
maximum: 480 Key updates include:
If there’s nothing else, this PR is good to go! |
📑 Summary
Fixed an issue where long legend labels in Journey diagrams could overlap with the diagram elements. In addition, we've added a new journey theme variable,
maxLabelWidth
, which allows users to control the maximum width of actor labels. This variable is configured as follows:By tracking the maximum width of legend text elements, we now ensure proper spacing between the legend and the diagram content. This update also improves text-wrapping by:
Resolves #5955
📏 Design Decisions
The implementation works by:
maxLabelWidth
theme variable to let users set how long each label line should be.maxLabelWidth
constraint.Before:
After:
📋 Tasks
[MERMAID_RELEASE_VERSION](https://mermaid.js.org/community/contributing.html#update-documentation)
is used for all new features.pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.