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

mermaidAPI.render generated different svg code from mermaid.int() #374

Closed
shd101wyy opened this issue Jul 13, 2016 · 4 comments
Closed

mermaidAPI.render generated different svg code from mermaid.int() #374

shd101wyy opened this issue Jul 13, 2016 · 4 comments

Comments

@shd101wyy
Copy link

shd101wyy commented Jul 13, 2016

Hi,

After I ran the code below ( I am using mermaid 6.0.0)

var text = 'graph TD\nA-->B\nA-->C\nB-->D\nD-->A\n'
var element = document.getElementById('mermaid0')
mermaidAPI.render(element.id, text, function(svgCode){ element.innerHTML = svgCode })

the generated graph looked like
screen shot 2016-07-13 at 12 57 22 pm

While by calling mermaid.init() , I got graph like
screen shot 2016-07-13 at 1 01 06 pm

Any idea how to solve this problem?

Thanks

@shd101wyy shd101wyy changed the title mermaidAPI.render generate different svg code from mermaid.int() mermaidAPI.render generated different svg code from mermaid.int() Jul 13, 2016
@shd101wyy
Copy link
Author

I hacked the code a bit and I resolve the problem by modifying the code to

var text = 'graph TD\nA-->B\nA-->C\nB-->D\nD-->A\n'
var element = document.getElementById('mermaid0')
mermaidAPI.render(element.id, text, function(svgCode){ 
    element.innerHTML = svgCode 
    element.firstChild.style.height = element.getAttribute('viewbox').split(' ')[3] + 'px'
})

It seems that the original height of svg block is wrong.

@shd101wyy
Copy link
Author

shd101wyy commented Jul 13, 2016

Also, mermaidAPI.render doesn't work properly with sequenceDiagram graph. It seems that the callback function passed in mermaidAPI.render is not called.

@yangxiaokun
Copy link

@shd101wyy Met this error when I use mermaidAPI.render too. Thank you for your solution

@tylerlong
Copy link
Collaborator

tylerlong commented Mar 17, 2018

I don't use the render method very often. I always just invoke the mermaid.init method.

Let me know if there are something that mermaid.init cannot do.

mgenereu pushed a commit to mgenereu/mermaid that referenced this issue Jun 25, 2022
…yarn/develop/svelte-3.42.6

chore(deps-dev): bump svelte from 3.42.5 to 3.42.6
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

3 participants