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

Width fixed to 400px #204

Closed
piranna opened this issue Sep 15, 2015 · 14 comments
Closed

Width fixed to 400px #204

piranna opened this issue Sep 15, 2015 · 14 comments
Milestone

Comments

@piranna
Copy link

piranna commented Sep 15, 2015

In the CLI or when using the API, the flowchart graphs are always width 400px, so when having somewhat complex charts the letters and boxes get small and blurry. Online editor don't happen to have this problem, showing them full size.

@knsv
Copy link
Collaborator

knsv commented Sep 15, 2015

Hello! I think this can be fixed. I am struggling to recreate the problem.

What version do you run?
Also what is the width of the surrounding element? Perhaps there is not room for your graph which possibly could could explain the smaller width.

@piranna
Copy link
Author

piranna commented Sep 15, 2015

What version do you run?

0.5.1

Also what is the width of the surrounding element? Perhaps there is not room for your graph which possibly could could explain the smaller width.

I'm generating it from the command line... I was using it before on GitBook using gitbook-plugin-mermaid but normal images are shown with their real size or its width adjusted to the book width, so I don't think the problem would be here...

If you are interested, the next block:

graph BT
  subgraph initramfs
    / === ibin[bin]
    / --- DEV((dev))
    / === ilib[lib]
    / --- proc((proc))
    / === tmp

    /   === usr
    usr === bin
    bin === ENV(env)

    tmp --- root
    tmp --- users((users))

    root --- RDEV((dev))
    root --- rproc((proc))
    root --- rtmp((tmp))

    root --- home((home))
  end

  subgraph usersfs
    .workdirs
    nodeos
    uroot[root]

    nodeos --- NDEV((dev))
    nodeos --- nproc((proc))
    nodeos --- ntmp((tmp))
  end

  home === .workdirs
  home === nodeos
  home === uroot

  users -.-> home

  DEV  -.- NDEV
  proc -.- nproc

  DEV  -.- RDEV
  proc -.- rproc
Loading

is generating the next image

real mmd

As you can see, the image is 400px width and you can hardly read the text labels or see the lines patterns... :-/

@Daijobou
Copy link

I would like to set a max-width (and max-height). I have a fluid design (responsive), so widescreen have much more space. ;)

@piranna
Copy link
Author

piranna commented Sep 16, 2015

Also, I think the borders width should be removed so image can adjust better and don't waste space...

@knsv
Copy link
Collaborator

knsv commented Sep 17, 2015

@piranna I can reproduce your issue. The easy fix is to not use maxWidth in the mermaid settings. In your case this would mean a width of around 1200 px. With maxWidth set mermaid tries to make the flowchart no wider then the surrounding element. If it is smaller it stays smaller otherwise small flowcharts can look a bit big... :)

I am not sure how the plugin generates the images. If it is using the api in the you use the flowchart config settings to turn this of as outlined below:

        var config = {
            startOnLoad:true,
            htmlLabels:true,
            callback:function(id){
                console.log(id,' rendered');
            },
            flowchart:{
                    useMaxWidth:false,
                }
        };
        mermaid.initialize(config);

The cli needs an update to change the default value of having maxWidth set.

@piranna
Copy link
Author

piranna commented Sep 17, 2015

The easy fix is to not use maxWidth in the mermaid settings. In your case this would mean a width of around 1200 px.

I can confirm that this fix it :-) Lines patterns are not shown, but at least text is now readable :-P

With maxWidth set mermaid tries to make the flowchart no wider then the surrounding element. If it is smaller it stays smaller otherwise small flowcharts can look a bit big... :)

Well, this could be done better with another approach, having elements with a fixed size and getting the graph as big as needed instead of the inverse (having the graph a fixed size and being elements as big as possible). Since first they are generated as SVG graphics, maybe the problem is when converting them to PDF assigning them a fixed width via CSS instead lefting it to auto...

I am not sure how the plugin generates the images.

It works by crafting and ad-hoc html page injecting the graph description and rendering it with PhantomJS. A bit cumbersome (I would have used node-canvas + Raphaël instead to be Node.js pure), but plugin is not mine...

@knsv
Copy link
Collaborator

knsv commented Sep 18, 2015

I'm glad it helped!
tors 17 sep 2015 kl. 22:10 skrev Jesús Leganés Combarro <
notifications@github.com>:

The easy fix is to not use maxWidth in the mermaid settings. In your case
this would mean a width of around 1200 px.

I can confirm that this fix it :-) Lines patterns are not shown, but at
least text is now readable :-P

With maxWidth set mermaid tries to make the flowchart no wider then the
surrounding element. If it is smaller it stays smaller otherwise small
flowcharts can look a bit big... :)

Well, this could be done better with another approach, having elements
with a fixed size and getting the graph as big as needed instead of the
inverse (having the graph a fixed size and being elements as big as
possible). Since first they are generated as SVG graphics, maybe the
problem is when converting them to PDF assigning them a fixed width via CSS
instead lefting it to auto...

I am not sure how the plugin generates the images.

It works by crafting and ad-hoc html page injecting the graph description
and rendering it with PhantomJS. A bit cumbersome (I would have used
node-canvas + Raphaël instead to be Node.js pure), but plugin is not mine...


Reply to this email directly or view it on GitHub
#204 (comment).

@piranna
Copy link
Author

piranna commented Sep 18, 2015

I'm glad it helped!

Thank you! :-) I've fixed it for gitbook-plugin-mermaid at piranna/gitbook-plugin-mermaid@ee9838f :-)

@sgerke
Copy link

sgerke commented Oct 6, 2015

Is the CLI already fixed? I tried to generate a more complex diagram from 0.5.3 (installed via npm) and still see a very low resolution (554 x 241).

@knsv
Copy link
Collaborator

knsv commented Oct 9, 2015

No… :(

Many aspects, default config for flowcharts using CLI is to not use maxWidth and no way to set it. Will fix this in two ways.

  1. default setting should be to have maxWidth false for the CLI for flowcharts
  2. it should be possible to set all options as one object instead of having sequenceConfig/ganttConfig separately

@vertti
Copy link

vertti commented Oct 19, 2015

CLI is pretty much unusable until this is fixed :(

@knsv knsv added this to the 0.5.4 milestone Oct 19, 2015
@knsv
Copy link
Collaborator

knsv commented Oct 19, 2015

Will try to make a small 0.5.4 release fairly soon

knsv added a commit that referenced this issue Oct 19, 2015
…width is 1200.

Added logger using es6 syntax
@vikram-rawat
Copy link

How to fix it now i am still having issues with

Is there any easy command now

@tylerlong
Copy link
Collaborator

Try the new CLI https://github.com/mermaidjs/mermaid.cli

I did a quick test and it can generate image with width bigger than 400px.

mgenereu pushed a commit to mgenereu/mermaid that referenced this issue Jun 25, 2022
…yarn/develop/typescript-eslint/parser-4.26.1

Bump @typescript-eslint/parser from 4.26.0 to 4.26.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants