mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

ZOOM!!!

Open zjslqshqz opened this issue 4 years ago • 20 comments

look!

QQ20210120-134214@2x

live-edito

look this live-edito

I want

When I made a more reproducible flowchart, I wanted a zoom function. Otherwise, I can only save it as a picture for zooming. .

zjslqshqz avatar Jan 20 '21 05:01 zjslqshqz

The main problem of flowcharts is hardnailing width=100% attribute and style={max-width: …px} that render any diagram in completely useless unreadable unscrollable and unzoomable mess.

Internet full of broken recipes how to force mermaid to not forcing, but they are obsolete.

maelstrom256 avatar Apr 27 '21 21:04 maelstrom256

The markup puts a width="100%" - that ensures that if you have a massive flowchart, it will ~~only be readable~~ never be readable. It should be removed. It could be placed in a wrapper with width:100%, which would give you scrollbars.

<svg id="graph-div" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="2283.43505859375" style="max-width: 3595.38232421875px;" viewBox="0 0 3595.38232421875 2283.43505859375">

yringler avatar Jul 15 '21 21:07 yringler

+1 on this. Have created some pretty massive diagrams only to be disappointed when it's so zoomed out nobody can really see it properly. I've played around with directives but haven't been able to find anything that affects the zoom level of a large diagram.

segunak avatar Apr 11 '22 13:04 segunak

Agreed. Please include zoomable results. I love this tool, but it only works with small diagrams. A medium to large database schema is completely unreadable.

dgbittner-sb avatar Jun 23 '22 03:06 dgbittner-sb

+1 also. Nice tool but not suitable for any serious flowcharts as you can not properly see the results if you have more than a few steps in your chart.

oxijas avatar Jul 10 '22 10:07 oxijas

+1 also. Nice tool but not suitable for any serious flowcharts as you can not properly see the results if you have more than a few steps in your chart.

I've found the only real way around this is to make the chart vertical, and then within it have some sub graphs that you force left to right for things that must be shown horizontally. It results in some pretty gnarly diagrams code wise, but that's the only solution I've been able to employ.

segunak avatar Jul 10 '22 11:07 segunak

+1. Please considering it.

0x7FFFFFFFFFFFFFFF avatar Dec 05 '22 20:12 0x7FFFFFFFFFFFFFFF

If you're desperate you can use d3.js to do this quickly, but it's a huge graphing/data document lib on its own so I wouldn't recommend it for regular use. Mentioned in https://github.com/mermaid-js/mermaid/issues/535#issuecomment-373736818 See this fiddle for a working demo: https://jsfiddle.net/zu_min_com/2agy5ehm/26/ Using only the zoom module (https://github.com/d3/d3-zoom) reduces size greatly but it's still not an ideal solution.

Jaciss avatar Dec 11 '22 02:12 Jaciss

+1

otaviosgoncalves avatar Jan 03 '23 13:01 otaviosgoncalves

I've made a little plugin using d3 to zoom in mermaid diagram rendered in Docsify.

https://corentinleberre.github.io/docsify-mermaid-zoom/#/ https://github.com/corentinleberre/docsify-mermaid-zoom

Maybe you can reuse piece of code for your own need.

corentinleberre avatar Jan 10 '23 04:01 corentinleberre

I've made a little plugin using d3 to zoom in mermaid diagram rendered in Docsify.

https://corentinleberre.github.io/docsify-mermaid-zoom/#/ https://github.com/corentinleberre/docsify-mermaid-zoom

Maybe you can reuse piece of code for your own need.

Dude, that's awesome. Good work!

segunak avatar Jan 12 '23 17:01 segunak

GitHub provides the lovely zoom control (recently?)!

sequenceDiagram
  autonumber
  Alice->>John: Hello John, how are you?
  loop Healthcheck
      John->>John: Fight against hypochondria
  end
  Note right of John: Rational thoughts!
  John-->>Alice: Great!
  John->>Bob: How about you?
  Bob-->>John: Jolly good!

guhuajun avatar Mar 13 '23 12:03 guhuajun

Really. Gitlab is lacking that feature, but having a copy button at least

maelstrom256 avatar Mar 13 '23 14:03 maelstrom256

You can use

  1. Obsidian app (markdown editor)
  2. Create a canvas file
  3. Add the markdown file (having the big flowchart) into the canvas file
  4. Then you can zoom into the flowchart (including zoom out, drag left, right, up, down etc) :)

kraditya avatar May 21 '23 09:05 kraditya

This directive worked for me: %%{ init: { "flowchart":{ "useMaxWidth": 0 } } }%%

DmitryGalyuk avatar Jun 15 '23 11:06 DmitryGalyuk

There's just no need for that 100%, just remove it..

corbym avatar Aug 14 '23 20:08 corbym

You can use

  1. Obsidian app (markdown editor)
  2. Create a canvas file
  3. Add the markdown file (having the big flowchart) into the canvas file
  4. Then you can zoom into the flowchart (including zoom out, drag left, right, up, down etc) :)

Great idea. And now you can even import a Mermaid Flowchart into Obsidian Excalidraw, which gives even a better experience. Just make sure your mermaid code is 100% correct as I spent one day searching around why it would fraw the flowchart in Notion and Typora just fine but not in Obsidian or Excalidraw. (Spoiler, it was the last empty comment-sign I had, so really in the last line.) Nearly killed me...

philousoph avatar Nov 02 '23 13:11 philousoph

I know this topic is kinda old, but how this was implemented yet? My guess it's that is not that hard given that Mermaid Editor already have that feature: image

In fact, the Mermaid Editor and GitHub support for zoom were the reasons that I started to script my diagram only to find out that it doesn't have zoom in the final diagram.

senese avatar Dec 13 '23 20:12 senese

this is working as well:

<script type="module">
    
   const defaultConfig = {
   startOnLoad: true,
   securityLevel: 'loose',
   flowchart: {
   useMaxWidth: 0,
   },
   gantt: {
   useMaxWidth: 0,
   },
   }
   import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
   mermaid.initialize(defaultConfig);
    
   </script>

image

Omnibus-ai avatar Mar 04 '24 06:03 Omnibus-ai

this is working as well:

<script type="module">
    
   const defaultConfig = {
   startOnLoad: true,
   securityLevel: 'loose',
   flowchart: {
   useMaxWidth: 0,
   },
   gantt: {
   useMaxWidth: 0,
   },
   }
   import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
   mermaid.initialize(defaultConfig);
    
   </script>

Am I correct in my understanding that this is essentially the same as what @DmitryGalyuk suggested here: https://github.com/mermaid-js/mermaid/issues/1860#issuecomment-1592879401

In other words, we can apparently use the %%{ ... }%%% syntax within the mermaid code to pass a config? (This appears to work well also in markdown preview (nvim) but not in Gitlab (actually in Gitlab the size is ok, but there are no scrollbars for the content, which makes only part of the diagram visible)) Is this documented somewhere and is there a documentation reference for the possible config attributes?

ppenguin avatar Mar 05 '24 11:03 ppenguin