Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an image in a node with "mermaid.js"

Is there any way to embed a picture with mermaid.js in a flow diagram graph node? I tried:

<div class="mermaid">
  graph LR
  A(<img src="pic.svg"></img>) --> B
</div>
like image 686
codie Avatar asked Feb 22 '17 21:02

codie


People also ask

What is Mermaid syntax?

Mermaid is a flowchart and diagram visualization tool based on JavaScript and uses syntax inspired by Markdown in order to create and dynamically modify flowcharts.

What is Mermaid tool?

Mermaid is a JavaScript-based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. The main purpose of Mermaid is to help documentation catch up with development.

Is Mermaid JS open source?

Mermaid. js lets you create various diagrams and flowcharts using only simple markup-like text. It is a free, open source, and easy-to-use JavaScript library.


1 Answers

Here is the API example from this thread

var mermaidAPI = mermaid.mermaidAPI;

mermaidAPI.initialize({
  startOnLoad:false
});

var element = document.getElementById("app");
var insertSvg = function(svgCode, bindFunctions) {
  element.innerHTML = svgCode;
};
var graphDefinition = `graph LR; Systemstart-->SomeIcon(<img src='https://iconscout.com/ms-icon-310x310.png' width='40' height='40' />)`;
var graph = mermaidAPI.render("mermaid", graphDefinition, insertSvg);
<script src="https://unpkg.com/[email protected]/dist/mermaid.min.js"></script>

<div id="app"></div>
like image 177
rpisryan Avatar answered Sep 22 '22 04:09

rpisryan