-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Label texts in flowcharts are not centered horizontally with "htmlLabels" disabled #1177
Comments
Hi. Anyone looking at this bug. Any workaround sugested? It is enough of an error that we are not using the awesome power of Mermeid yet. :-/ |
Hi all. The solution is simple rather simple. Currently SVG generated by Mermaid for labels looks like this: <g class="label" style="" transform="translate(-18.234375, -11.5)">
<text style="">
<tspan xml:space="preserve" dy="1em" x="0" class="row">volume</tspan>
<tspan xml:space="preserve" dy="1em" x="0" class="row">0</tspan>
</text>
</g> Since all the labels start from the center of the node, we use explicit <g class="label" style="" transform="translate(0, -11.5)" >
<text style="" text-anchor="middle">
<tspan xml:space="preserve" dy="1em" x="0" class="row">volume</tspan>
<tspan xml:space="preserve" dy="1em" x="0" class="row">0</tspan>
</text>
</g> I think this is relatively trivial change, that can be easily implemented, I just need to make NPM package out of it. Unless some existing contributor e.g. @jgreywolf has everything in place I can send a PR for it. |
@nanoant Are you still willing to submit a PR on this? I would say - never wait, if an issue is not assigned say you are working on it and we will ensure you are assigned and then "bug" you accordingly :) |
Describe the bug
If
htmlLabels
is set tofalse
in the flowchart configuration, the multiline texts for nodes and lines are not horizontally centered.To Reproduce
Steps to reproduce the behavior:
-> label text is centered
htmlLabels
tofalse
-> label text is aligned left
Expected behavior
Multiline texts should be centered for non-html labels as well.
Additional context
Maybe the SVG text attribute
text-anchor
can be used here, but I have not looked into it enough to be sure about that.The text was updated successfully, but these errors were encountered: