question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Massive whitespace above and below graph

See original GitHub issue

Describe the bug Very large charts result in massive amounts of excess whitespace above and below the diagram making it practically unusable. I was using mermaid to chart a family tree with approximately 400 relationships/nodes. Performance is very acceptable for such an application, so it’s unfortunate that I’ve encountered this issue.

To Reproduce Steps to reproduce the behavior: The family tree contains confidential information so I cannot post it, but the problem can easily be reproduced by repeating the simple relationship below. I’m showing 5 repetitions below. The problem starts manifesting itself after about 50 repetitions and becomes extremely problematic at around 150, getting progressively worse as more elements are added to the graph.

flowchart BT
A-->B-->C-->D-->E
A-->B-->C-->D-->E
A-->B-->C-->D-->E
A-->B-->C-->D-->E
A-->B-->C-->D-->E

50 repetitions: Selection_055

150 repetitions: Selection_056

Here’s what I’m experiencing with the actual family tree. The first example is using the VS Code mermaid extension. Please note the size of the scrollbar handle on the right to get an idea how much empty space is above and below the diagram in addition to the empty space in the visible portion.

Selection_053

The second example is using mermaid in Joplin. Here’s what PDF output looks like, and the same amount of empty space is present in the live view.

Selection_054

The problem can also be reproduced in the Live Mermaid Editor. Here’s what happens with 500 repetitions of the aforementioned example:

Selection_057

Expected behavior The size should be limited to the visible extent of the graph.

Screenshots See above.

Desktop (please complete the following information):

  • any OS

Smartphone (please complete the following information):

  • any device

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:32
  • Comments:30 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
tessuscommented, Nov 8, 2021

We have the same problem in Joplin. People have found a workaround by adding the following css:

.mermaid svg { height: auto; }

@knsv ^^^

10reactions
listxcommented, Apr 14, 2022

For context, there was a fix for this in #2312 but it was reverted in 38ef0611753fcc1e8ef7de024300614cd4768b8a (presumably because it broke other things).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I reduce the white space on the sides of my Excel ...
I am trying to reduce the space on the sides of my chart in Excel 2016. I need to fit several graphs on...
Read more >
mermaid diagrams: Adjust white space around graph
I'm using mermaid diagrams in my Rmd reports compiled with Rstudio. In the HTML/PDF output, there is a lot of blank space above...
Read more >
Excessive whitespace around sequence diagrams - Features
As noted here: Massive whitespace above and below graph · Issue #1984 · mermaid-js/mermaid · GitHub it seems like Mermaid is adding a...
Read more >
Remove excess white space above figure - TeX
The screenshot show why \vspace should not be used. The problem seems that the image sizes are too big to fit the float...
Read more >
How to increase space above graph to make room for a title in ...
I would like to put the title above the axis but when I try to resize the graph with the dots it resize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found