javascript – Flowchart.js SVG渲染在弹出窗口中搞砸了
作者:互联网
我正在使用flowchart.js库来获取流程图的SVG渲染.
我需要在带有动态引导面板的弹出窗口中包含流程图渲染,但结果搞砸了(框上的标签和小渲染:
我的代码是:
<div class="panel panel-default">
<div class="panel-body">
<div id="diagram"></div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var diagram = flowchart.parse('st=>start: Start:>http://www.google.com[blank]\n' +
'e=>end:>http://www.google.com\n' +
'op1=>operation: My Operation\n' +
'op2=>operation: Stuff|current\n' +
'sub1=>subroutine: My Subroutine\n' +
'cond=>condition: Yes \n' + // use cond(align-next=no) to disable vertical align of symbols below
'or No?\n:>http://www.google.com\n' +
'c2=>condition: Good idea|rejected\n' +
'io=>inputoutput: catch something...|request\n' +
'\n' +
'st->op1(right)->cond\n' +
'cond(yes, right)->c2\n' + // conditions can also be redirected like cond(yes, bottom) or cond(yes, right)
'cond(no)->sub1(left)->op1\n' + // the other symbols too...
'c2(true)->io->e\n' +
'c2(false)->op2->e' //allow for true and false in conditionals
);
diagram.drawSVG('diagram');
});
</script>
怎么办呢?
非常感谢
解决方法:
这段代码工作正常:
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.2.7/raphael.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flowchart/1.8.0/flowchart.min.js"></script>
</head>
<body>
<div class="panel panel-default">
<div class="panel-body">
<div id="diagram"></div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var diagram = flowchart.parse('st=>start: Start:>http://www.google.com[blank]\n' +
'e=>end:>http://www.google.com\n' +
'op1=>operation: My Operation\n' +
'op2=>operation: Stuff|current\n' +
'sub1=>subroutine: My Subroutine\n' +
'cond=>condition: Yes \n' + // use cond(align-next=no) to disable vertical align of symbols below
'or No?\n:>http://www.google.com\n' +
'c2=>condition: Good idea|rejected\n' +
'io=>inputoutput: catch something...|request\n' +
'\n' +
'st->op1(right)->cond\n' +
'cond(yes, right)->c2\n' + // conditions can also be redirected like cond(yes, bottom) or cond(yes, right)
'cond(no)->sub1(left)->op1\n' + // the other symbols too...
'c2(true)->io->e\n' +
'c2(false)->op2->e' //allow for true and false in conditionals
);
diagram.drawSVG('diagram');
});
</script>
</body>
</html>
输出:
也许您正在混合不兼容的版本,或者您的问题中缺少一些重要信息.
标签:javascript,svg,rendering,raphael,flowchart 来源: https://codeday.me/bug/20190701/1347566.html