【问题标题】:Diagrams package with some items top-to-bottom, others left-to-right图表包,其中一些项目从上到下,其他项目从左到右
【发布时间】:2021-04-18 02:18:09
【问题描述】:

编辑:在我即将提交时找到了答案。这篇文章讨论了不可见的边缘:Graphviz top to bottom AND left to right

我目前正在使用 python 包“diagrams”为我的项目构建流程图。不幸的是,由于从左到右或从上到下的所有方向(据我所知,无法混合两者),它会导致一些难看的显示。

这是我图表代码的 sn-p:

from diagrams import Diagram, Cluster

from diagrams.generic.database import SQL
from diagrams.generic.place import Datacenter
from diagrams.generic.compute import Rack
from diagrams.generic.network import Subnet

from diagrams.aws.general import User


with Diagram('Sample', show=False, outformat='png', direction='LR'):
    database_1 = SQL('Database 1')

    database_2 = SQL('Database 2')

    database_3 = SQL('Database 3')

    server = Datacenter('Datacenter')

    human = User('Human Reviewer')

    with Cluster('Additional items to group separately', direction='TB'):
        process = Subnet('Connection')
        compute = Rack('Compute')
        compute_other = Rack('Compute Other')

    with Cluster('Files to group together'):
        database_4 = SQL('Database 4')
        database_5 = SQL('Database 5')
        database_6 = SQL('Database 6')
    [database_4, database_5, database_6] >> compute

    database_1 >> server
    database_2 >> server
    database_3 >> server

    server >> process >> compute >> compute_other >> human

返回

但所需的图像应该是簇'Files to group together' 水平分布以使图表更紧凑的图像。有关所需的输出,请参见此图。

有没有办法让集群'Files to group together' 水平对齐,同时让图表的其余部分从左到右流动?我在想我只需要在集群中的项目之间创建不可见的边缘,但我似乎无法在 graphviz 中找到将边缘设置为不可见的选项(而且似乎没有独特的选项graphviz 中没有的图表)。

注意:我试过 Edge(color=None),但你仍然可以看到一个箭头,并且没有从 db4 到 db5 到 db6 的流,所以 Edge 只是试图强制对齐

有没有更好的包来构建这些图表?

谢谢!

【问题讨论】:

    标签: python graphviz diagram


    【解决方案1】:

    搜索时找不到类似的帖子,但 AI 大神阅读了我的帖子并指出此帖子为最佳建议: Graphviz top to bottom AND left to right

    在那篇文章中,用户提到了 Edge(style='invis') 的 graphviz 选项。我实现了这一点,而不是我在 Edge(color=None) 上的尝试,并且按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 2019-11-18
      • 1970-01-01
      • 2023-04-10
      • 2016-01-15
      • 2012-06-17
      • 1970-01-01
      相关资源
      最近更新 更多