【问题标题】:Forcing subgraphs to align with newrank=true强制子图与 newrank=true 对齐
【发布时间】:2022-01-27 03:21:02
【问题描述】:

这是我的图表:

是否可以将“面向用户的选项”子图向下移动,以便“面向用户的内容”位于该子图和“内部标签”子图的上方?我尝试使用https://stackoverflow.com/a/18410951/2954547 中描述的技术来强制topicroletag 对齐,但出于某种原因,它真的很想将另一个节点放在该子图中上方 tag 节点,而不是在它下面。

我看到你也可以乱用weight参数来调整输出,就像https://stackoverflow.com/a/14348263/2954547一样,但这只是让行越来越短。

我想要的输出是像这样移动左子图:

当前源代码:

digraph G {
  compound=true;
  newrank=true;

  subgraph cluster_userFacing {
    label="User-facing options";
    labelloc="bottom";
    role [label="User Role\n(User Classification)"];
    topic [label="Topic\n(External Tag)"];
  }

  subgraph cluster_content {
    label="User-facing Content";
    article [label="Article"];
    podcastEpisode [label="Podcast Episode"];
  }
  
  subgraph cluster_internal {
    label="Internal tags";
    labelloc="bottom";
    tag [label="Tag\n(Internal Tag)"];
    tagCategory [label="Tag Category"];
    tag -> tagCategory;
  }

  role -> tag [dir="none"];
  topic -> tag [dir="none"];

  article -> tag;
  podcastEpisode -> tag;
  
  { rank="min"; podcastEpisode; article; }
  
  { rank="same"; topic; tag; }
}

【问题讨论】:

    标签: graphviz


    【解决方案1】:

    将两个集群封闭在一个新的不可见 (peripheries=0) 集群中。 设置约束 = false 以覆盖排名。并添加了一个不可见的边缘。

    digraph G {
    
      node [height=.78]  // make all nodes same height
      subgraph clusterGroup{
        peripheries=0
      subgraph cluster_userFacing {
        peripheries=1
        label="User-facing options";
        labelloc="bottom";
        role [label="User Role\n(User Classification)" ]
        topic [label="Topic\n(External Tag)"];
      }
      subgraph cluster_internal {
        peripheries=1
        label="Internal tags";
        labelloc="bottom";
        tag [label="Tag\n(Internal Tag)" group=G];
        tagCategory [label="Tag Category"]; 
        tag -> tagCategory;
      }
     }
    
      subgraph cluster_content {
        label="User-facing Content";
        article [label="Article" ]
        podcastEpisode [label="Podcast Episode" group=G];
      }
      role  -> tag  [dir="none" constraint=false];
      topic -> tag  [dir="none" constraint=false];
      article -> tag  
      podcastEpisode -> tag;
    
      role -> topic [style=invis]
    }
    

    捐赠:

    【讨论】:

    • 那很乱。我喜欢基本的 Dot 语言,但有时你必须通过这些扭曲来促使布局引擎产生良好的结果,这很烦人。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 2017-08-06
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多