10

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>
user7637745
  • 965
  • 2
  • 14
  • 27
codie
  • 343
  • 4
  • 12
  • 2
    Here is an example: https://github.com/mermaid-js/mermaid/issues/1133#issuecomment-564036333 – Motin Jan 14 '22 at 17:54

2 Answers2

10

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/mermaid@8.0.0-rc.8/dist/mermaid.min.js"></script>

<div id="app"></div>
rpggio
  • 2,447
  • 1
  • 19
  • 13
8

Example without Javascript:

graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[<img src='https://iconscout.com/ms-icon-310x310.png' width='40' height='40' />]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]

enter image description here

Stav Alfi
  • 13,139
  • 23
  • 99
  • 171