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.

Configure flowchart to auto-resize so that nodes are always the same size.

See original GitHub issue

I’ve tried playing with various useMaxWidth and HTML/css settings, however I’m unable to achieve the following behavior:

Given a #mermaid container sitting within an auto-width div, I would like to render flow charts so that the nodes are always the same size regardless of chart layout and regardless of the number of nodes.

In other words, I would like to force the flowchart to be as large or as small as it needs to be in order to avoid shrinking or expanding nodes from their default size.

I would then expect to have to scroll/pan for complex charts with many nodes.

I can achieve this manually by setting the width of the #mermaid container to a large value whenever the chart shrinks, however I would prefer an automatic solution.

How can this be achieved? Is the proper solution to use a very large fixed width for the #mermaid container while setting useMaxWidth to false? If so, what if I exceed that max-width, and what if I only want to scroll when there is overflow?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
GDFabercommented, Jul 24, 2019

Possible Workaround

Apparently the svg’s max-width attribute can be used to set the container width directly after creating the flowchart. I’m using the following workaround which works for me (mermaid 8.2.1):

$('#container').html(graphDefinition).removeAttr('data-processed'); mermaid.init(undefined, $('#container')); $('#container').width($('#container svg').css('max-width'));

0reactions
IOrlandonicommented, Oct 21, 2019

The issue was tackled on #964. Will close soon, if no objections.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create a Flowchart in Excel - BreezeTree Software
First, Excel has an autosize feature available in the shape formatting dialog. Don't use it. Excel's idea of flow chart shape autosizing is...
Read more >
Autosize shapes to fit their text labels
Autosize allows you to fit the outer size of your shapes to the height and width of their text labels. Select the shapes...
Read more >
2 Tips for Sizing and Aligning Nodes (Release 8)
This topic describes techniques for controlling the size and alignment of nodes when placed in a JavaFX layout pane.
Read more >
20+ Flow Chart Templates, Design Tips and Examples
Flowcharts help organize projects and communicate processes effectively. 20+ editable flow chart templates for business, marketing, ...
Read more >
Is Excel or Word better for Flowchart Mapping? - Yonyx
Flowchart mapping is about simplifying processes and including the amending of the diagrams - genuine interest to create useful diagrams is ...
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