Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow chart support #593

Closed
abakhru opened this issue Sep 4, 2021 · 2 comments
Closed

flow chart support #593

abakhru opened this issue Sep 4, 2021 · 2 comments

Comments

@abakhru
Copy link

abakhru commented Sep 4, 2021

@clayms
Copy link

clayms commented Sep 4, 2021

All of the Graphviz generic shapes are available. Just create a Node class object directly and set the shape parameter equal to the the name of the shape you want as a string, e.g. Node("label", shape="star").

Graphviz shapes: https://graphviz.gitlab.io/doc/info/shapes.html

Have a look at the following issue comments for example code.
#290 (comment)
#185 (comment)

Also have a look at html nodes:
#389 (comment)
#389 (comment)
#389 (comment)

@clayms
Copy link

clayms commented Sep 8, 2021

Here is the flowchart.js Demo 1 in this library.

from diagrams import Diagram, Cluster, Node, Edge

cluster_attr = {
    "label":"", 
    "bgcolor":"transparent",
    "penwidth":"0",
}

with Diagram("\n\nflowchart.js Demo 1", direction="TB", show=False) :
    """     """
    with Cluster("1", graph_attr=cluster_attr):
        start = Node(label="start a_pyflow_test", labelloc="c", 
            shape="rectangle", style="rounded", width="2", height="0.5", )
        loopback = Node(label="", labelloc="c", 
            shape="plaintext", style="solid", width="0", height="0", )
        operation = Node(label="do something", labelloc="c", 
            shape="rectangle", style="solid", width="2", height="0.5", )
        condition = Node(label="Yes or No?", labelloc="c", 
            shape="diamond", style="solid", width="2", height="1", )
        inputoutput = Node(label="output: something...", labelloc="c", 
            shape="parallelogram", style="solid", width="2.5", height="0.5", )
        end = Node(label="end a_pyflow_test", labelloc="c", 
            shape="rectangle", style="rounded", width="2", height="0.5", )


    with Cluster("2", graph_attr=cluster_attr):
        subroutine = Node(label="<f0> |<f1>A Subroutine|<f2> ", labelloc="c", 
            shape="record", style="solid", width="2", height="0.5", )
        subroutine_out = Node(label="", labelloc="c", 
            shape="plaintext", style="solid", width="0", height="0", )


    (
        start - Edge(tailport="s", headport="n",) -
        loopback >> Edge(tailport="s", headport="n",) >>
        operation >> 
        condition >> Edge(taillabel="yes") >>
        inputoutput >> 
        end
    )
    (
        condition >> Edge(taillabel="no", headport="f0", tailport="e", minlen="0",) >>
        subroutine
    )
    (
        subroutine - Edge(tailport="f2", minlen="0",) -
        subroutine_out
    )
    (
        subroutine_out - 
        loopback
    )

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants