adrai / flowchart.js

Draws simple SVG flow chart diagrams from textual representation of the diagram
http://flowchart.js.org/
MIT License
8.5k stars 1.21k forks source link

use drawSVG method the rect size too small #161

Closed yoqu closed 5 years ago

yoqu commented 5 years ago

Hello,my project use flowchart.js frmaework support markdown flow , but when I use drawSVG method ,svg image rect size too small, image: image

the code

$(scope).find(".flowchart").each(function ( index,container) {
        try {
            var codeElement = $(container).children('.flowchart-code');
            var graphElement = $(container).children('.flowchart-graph');
            var diagram = flowchart.parse(codeElement[0].innerText);
            diagram.drawSVG(graphElement[0]);
        } catch (e) {
            console.error(e);
        }
    })

html code:

<div class="flowchart"><script  type="text/template" class="flowchart-code">
st=>start: Start|past:>http://www.google.com[blank]
e=>end: Ende|future:>http://www.google.com
op1=>operation: My Operation|past
op2=>operation: Stuff|current
sub1=>subroutine: My Subroutine|invalid
cond=>condition: Yes
or No?|approved:>http://www.google.com
c2=>condition: Good idea|rejected
io=>inputoutput: catch something...|future

st->op1(right)->cond
cond(yes, right)->c2
cond(no)->sub1(left)->op1
c2(yes)->io->e
c2(no)->op2->e</script><div class="flowchart-graph"></div></div>
adrai commented 5 years ago

Can you try to draw your chart outside of your layout? There is probably a size outside of the charts that influences the drawing...

yoqu commented 5 years ago

@adrai I found the problem, because of my website use vue, The page is not fully loaded but I have started calling the draw function. I set timeout function resolve it. thanks.

adrai commented 5 years ago

nice to know 👍