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

Update graph #311

Closed
LeonardoRamos opened this issue Mar 1, 2016 · 12 comments
Closed

Update graph #311

LeonardoRamos opened this issue Mar 1, 2016 · 12 comments
Assignees

Comments

@LeonardoRamos
Copy link

Hi, I have a question, I have a graph in my page that is loaded as soon the page is fully loaded. I have some menus that allow the user to add nodes and remove nodes, manipulating the graph definition that is inside a textarea, but I'm having difficulties trying to "redraw" the graph. I tried calling "init" again, I tried calling the API, but I have no success in both options. So my question is, how can I re-render the graph?

@LeonardoRamos
Copy link
Author

Actually, it works in Firefox, it's not re-rendering the graph only in chrome (I'm using chrome 48) and I tested mermaid versions 5.7, 5.6 and 4.0, none of them worked, only a very old version worked fine (The one used in the editor folder).

@knsv
Copy link
Collaborator

knsv commented Mar 12, 2016

Are you using the API for this rendering? It sounds like you should use the render function for this.

Se example in the docs:
http://knsv.github.io/mermaid/#api-usage

I hope that helps.

@radmilabord
Copy link

Render function works only ones. Did anyone found solution for this? I'm facing same problem.

@knsv
Copy link
Collaborator

knsv commented Dec 13, 2016

Looking at this one.

@knsv knsv self-assigned this Dec 13, 2016
@radmilabord
Copy link

I solved it by removing div with graph, adding it back, setting text, calling init method.
Same approach is done in "try it" demo.
However if rerender function could work, it would be great.

@knsv
Copy link
Collaborator

knsv commented Dec 13, 2016

OK. Will continue with it anyway then.

knsv added a commit that referenced this issue Dec 14, 2016
knsv added a commit that referenced this issue Dec 14, 2016
knsv added a commit that referenced this issue Dec 14, 2016
knsv added a commit that referenced this issue Dec 14, 2016
@roidayan
Copy link

roidayan commented Jul 6, 2017

i know its old but wanted to say i do not delete the entire div but remove the attribute "data-processed". after that calling init on it again seems to work.

@radmilabord
Copy link

Thanks! That sounds like a less intrusive approach.

@dianaeneida
Copy link

roidayan, ¿could you expose the complete solution here?, please

@roidayan
Copy link

my html is:

<div id="mermaid"></div>

and in js I do this on init and each time my data in node.data.graph changes:

$('#mermaid').html(node.data.graph).removeAttr('data-processed');
mermaid.init(undefined, $("#mermaid"));

@tylerlong
Copy link
Collaborator

@roidayan 's solution works and I use it too.

@hikari-He
Copy link

my html is:

<div id="mermaid"></div>

and in js I do this on init and each time my data in node.data.graph changes:

$('#mermaid').html(node.data.graph).removeAttr('data-processed');
mermaid.init(undefined, $("#mermaid"));

You solved my problem.
In addition, this method can work in mermaid 9.1.0, but not work in mermaid 9.4.3.

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