如何使用“mermaid.js”在节点中嵌入图像

时间:2017-02-22 21:47:31

标签: javascript html mermaid

有没有办法在流程图图节点中嵌入带mermaid.js的图片?我试过了:

<div class="mermaid">
  graph LR
  A(<img src="pic.svg"></img>) --> B
</div>

1 个答案:

答案 0 :(得分:1)

这是this thread

中的API示例

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>