Skip to content
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

Text is cut off in SVG exported from live editor #790

Closed
p3k opened this issue Feb 3, 2019 · 13 comments
Closed

Text is cut off in SVG exported from live editor #790

p3k opened this issue Feb 3, 2019 · 13 comments
Labels
Contributor needed Retained Nonperishable Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect

Comments

@p3k
Copy link

p3k commented Feb 3, 2019

The following Mermaid markup generates this live view:

graph TD
A[Something] -->|begets| B[Something]
Loading

(Config is {}.)

image

However, in the exported SVG all text boxes are cropped on the right side:

image

Am I missing something?

@CalvinRodo
Copy link

I'm running into this same issue currently

@jcpst
Copy link

jcpst commented Feb 6, 2019

I also run into this same issue when using the library in a web application, where config is {}.

@Uinelj
Copy link

Uinelj commented Feb 19, 2019

Issue present in the generated SVG from the live demo too (tested on Chrome, Firefox):

image

Edit: By changing the font-size in the svg file you can get a readable output.

@hexblot
Copy link

hexblot commented Mar 14, 2019

In some cases text is cropped even in the live editor, see a very basic example here

Exporting to SVG makes the issue more pronounced.

@trueskawka
Copy link

trueskawka commented Apr 2, 2019

I was able to address this issue when using the CLI to generate PNG by adding CSS to the parent element for edgeLabel. The foreignObject width is too narrow for labels to be properly displayed, so it should allow for overflow (I think the math might be slightly off when calculating the label width).

.label foreignObject {
    overflow: visible;
}

It doesn't seem to be working for SVG, but it might be a similar issue.

Edit:
Oh, interesting, it does work if I pass the themeCSS, but not when I'm using a CSS file for the -C flag.

If you add this to the config, it should fix the label width:

"themeCSS": ".label foreignObject { overflow: visible; }"

@FiyaFly
Copy link

FiyaFly commented Apr 30, 2019

I was able to address this issue when using the CLI to generate PNG by adding CSS to the parent element for edgeLabel. The foreignObject width is too narrow for labels to be properly displayed, so it should allow for overflow (I think the math might be slightly off when calculating the label width).

.label foreignObject {
    overflow: visible;
}

It doesn't seem to be working for SVG, but it might be a similar issue.

To add to this, in the SVG every class is marked with an ID, which is noted at the top, e.g. svg id="mermaid-1556643060555". Also, if you add font-size: 90%; as well, it looks almost perfect (at least on my screen, haven't tested elsewhere). Which would make the css similar to this, using the svg line as an example:

#mermaid-1556643060555 .label foreignObject {
    font-size: 90%;
    overflow: visible;
}

I stumbled across this issue trying to figure out why my SVG's were coming out poor, but I've only been using mermaid for a day lol. Hopefully this helps others, and eventually helps to fix it in the editor/mermaid itself. I don't know about using this via CLI. Still working on getting the CLI working for me at all lol.

@stale
Copy link

stale bot commented Jun 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Type: New Shape Request for new shape label Jun 29, 2019
@knsv knsv added the Type: Bug / Error Something isn't working or is incorrect label Jun 30, 2019
@stale stale bot removed the Type: New Shape Request for new shape label Jun 30, 2019
@knsv knsv added this to Release Todo in 8.2.0 Jun 30, 2019
@happycollision
Copy link

happycollision commented Aug 8, 2019

Well, it's not stale! ;-)

We dig the library. Great work on it!

@Drunkman
Copy link

Drunkman commented Aug 14, 2019

I add this to config, and it work well.

{
    "themeCSS": ".label foreignObject { font-size: 14px; }"
}

But I still don't know why mermaid add a style that make the font-size large so that graph label be cut off.

@pdxjohnny
Copy link

I still get clipping on the export

image

pdxjohnny added a commit to pdxjohnny/dffml that referenced this issue Sep 25, 2019
Relavent MermaidJS issues:
- Fix clipping
  - mermaidjs/mermaid.cli#59
- Fix CLI not working
  - mermaid-js/mermaid#790 (comment)

Signed-off-by: John Andersen <john.s.andersen@intel.com>
@IOrlandoni IOrlandoni added Retained Nonperishable Status: Approved Is ready to be worked on and removed Status: Pending Is not to be executed as it currently is labels Sep 26, 2019
@IOrlandoni
Copy link
Member

Note that right now the project has a lot more requests piled up than it can handle.
We would be happy to accept new collaborators!

@knsv knsv removed this from Release Todo in 8.2.0 Oct 8, 2019
@GDFaber
Copy link
Member

GDFaber commented Dec 24, 2019

This issue seems to be solved in mermaid 8.4.4 as the svg download of the new live editor does not show the problem anymore:

https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbkFbU29tZXRoaW5nXSAtLT58YmVnZXRzfCBCW1NvbWV0aGluZ10iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ==

@p3k
Copy link
Author

p3k commented Dec 24, 2019

confirmed! great, thanks a lot. closing this issue.

@p3k p3k closed this as completed Dec 24, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contributor needed Retained Nonperishable Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests