我可以在graphviz中做这种形状吗?

问题描述 投票:0回答:1

我想尽可能忠实地在 graphviz 中重新创建一个类似于以下的图表。

API Diagram

但是我在边缘方面失败了。似乎没有办法将图像添加到边缘。我还尝试将图像添加为具有自定义图像的单独节点,但这不会正确旋转图像。另外,我不知道如何将文本放在边缘(但不太重要)。节点的位置并不重要,但图标的旋转很重要。

特别是对于边缘中心的图标:使用 graphviz 是否可以实现类似的效果?具体来说就是应该能够处理不同的角度,以便边缘在正确的位置进入和退出。

以下是我尝试过的:

graph {
  api1 [style="invisible" image="api.png"]
  api2 [style="invisible" image="api.png"]
  api3 [style="invisible" image="api.png"]
  
  A -- api1 -- B
  A -- api2 -- C
  A -- api3 -- D
}

这是 api.png:

api.png

这是输出:

Output

graphviz
1个回答
0
投票

虽然您似乎无法使用单个 Graphviz 引擎重现图表,但您似乎可以使用多个 Graphviz 程序加上一些后处理来生成所需的图表。
这是一个“非常接近”的概念验证以及生成它的 Graphviz 输入。
使用``neato -n2 ...` 生成图表。
除了两个半圆之外,概念验证是手动创建的,只是因为它更快。 对于“真实”使用,您需要使用 python 或 gvpr 等后处理器(https://www.graphviz)生成边缘标签节点、小圆和半圆组件(具有所需的旋转) .org/pdf/gvcolor.1.pdf).

enter image description here

graph cnc {
  // all layout done be "eye"
  // use neato -n to produce result

  "component 1" [pos="100,400"]
  "component 2" [pos="500,400"]
  "component 3" [pos="100,100"]
  "component 4" [pos="500,100"]

  lbl1  [pos="330,400" shape=plaintext label="API 1\nHTTP"]
  c1a   [pos="230,400" label="" shape=circle height=".3"]
  c1b   [pos="230,400" label="" shape=circle height=".5" style=invis]

  lbl2  [pos="330,220" shape=plaintext label="API 2\nHTTP"]
  c2a   [pos="230,300" label="" shape=circle height=".3"]
  c2b   [pos="230,300" label="" shape=circle height=".5" style=invis]

  "component 1" -- c1b
  c1a -- lbl1 -- "component 2"

  "component 1" -- c2b
  c2a -- lbl2 -- "component 4"

  __Xnode__1  [label=" ",
               pos="210,400 ",
               shape=point,
               style=invis];
  __Xnode__2  [label=" ",
               pos="230,420 ",
               shape=point,
               style=invis];
  __Xnode__3  [label=" ",
               pos="250,400 ",
               shape=point,
               style=invis];
  __Xnode__4  [label=" ",
               pos="230,380 ",
               shape=point,
               style=invis];

  __Xnode__1 -- __Xnode__1  [cmd=cw,
                             color=black,
                             dir=none,
                             pos="210,400 210,411.046 218.954,420 230,420 "];

  __Xnode__4 -- __Xnode__4  [cmd=cw,
                             color=black,
                             dir=none,
                             pos="230,380 218.954,380 210,388.954 210,400 "];



  __Xnode__21 [label=" ",
               pos="210,300 ",
               shape=point,
               style=invis];
  __Xnode__22 [label=" ",
               pos="230,320 ",
               shape=point,
               style=invis];
  __Xnode__23 [label=" ",
               pos="250,300 ",
               shape=point,
               style=invis];
  __Xnode__24 [label=" ",
               pos="230,280 ",
               shape=point,
               style=invis];

  __Xnode__21 -- __Xnode__21  [cmd=cw,
                               color=black,
                               dir=none,
                               pos="210,300 210,311.046 218.954,320 230,320 "];

  __Xnode__24 -- __Xnode__24  [cmd=cw,
                               color=black,
                               dir=none,
                               pos="230,280 218.954,280 210,288.954 210,300 "];

}
© www.soinside.com 2019 - 2024. All rights reserved.