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

ZOOM!!! #1860

Open
zjslqshqz opened this issue Jan 20, 2021 · 21 comments
Open

ZOOM!!! #1860

zjslqshqz opened this issue Jan 20, 2021 · 21 comments
Labels
Area: Development Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request

Comments

@zjslqshqz
Copy link

zjslqshqz commented Jan 20, 2021

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 zjslqshqz added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Jan 20, 2021
@maelstrom256
Copy link

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.

@yringler
Copy link

yringler commented Jul 15, 2021

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">

@segunak
Copy link

segunak commented Apr 11, 2022

+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.

@dgbittner-sb
Copy link

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.

@oxijas
Copy link

oxijas commented Jul 10, 2022

+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.

@segunak
Copy link

segunak commented Jul 10, 2022

+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.

@0x7FFFFFFFFFFFFFFF
Copy link

+1. Please considering it.

@Jaciss
Copy link

Jaciss commented Dec 11, 2022

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 #535 (comment) 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.

@otaviosgoncalves
Copy link

+1

@corentinleberre
Copy link

corentinleberre commented Jan 10, 2023

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.

@segunak
Copy link

segunak commented Jan 12, 2023

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!

@guhuajun
Copy link

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!
Loading

@maelstrom256
Copy link

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

@kraditya
Copy link

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) :)

@DmitryGalyuk
Copy link

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

@corbym
Copy link

corbym commented Aug 14, 2023

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

@philousoph
Copy link

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...

@senese
Copy link

senese commented Dec 13, 2023

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.

@Omnibus-ai
Copy link

Omnibus-ai commented Mar 4, 2024

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

@ppenguin
Copy link

ppenguin commented Mar 5, 2024

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: #1860 (comment)

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?

@sanchezzzhak
Copy link

https://github.com/sanchezzzhak/node-proxy-logger/wiki/Display-logs-mermaid.js

use mermaid to visualize how method invocation behaves under different parameters. Yes, the diagrams are not perfect, but at least something. Not the point

in this wiki, I described how to fix pan-zoom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Development Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests