4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mermaid.jsの描画を再ロードする

Posted at

#mermaid.jsとは

公式サイト
ライブエディターもあるよ!

#結論

  • 描画するAttributeを削除
     removeAttribute('data-processed');
  • 再びinitすればOK
    mermaid.init();

##ソースコード


<!DOCTYPE html>
<html lang="jp">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="mermaid.min.css">
</head>
<body>
<input id="chart-src" onchange="changechart()" textarea value="
  graph TD;
    あ-->B;
    あ-->C;
    B-->D;
    C-->D;">
 </input>
 <div id="flowchart" class="mermaid">
 </div>
 <script src="https://unpkg.com/mermaid@7.1.0/dist/mermaid.min.js"></script>
 <script>mermaid.initialize({startOnLoad:false});</script>
<script>
	let aa = document.getElementById("chart-src").value;
	document.getElementById("flowchart").innerHTML = aa;
	mermaid.init();
</script>

<script>
function changechart(){
    document.getElementById("flowchart").removeAttribute('data-processed');
    let aa = document.getElementById("chart-src").value;
	document.getElementById("flowchart").innerHTML = aa;
	mermaid.init();
}
</script>
<body>
</html>

※汚いソースコードなのはご勘弁ください。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?