如何以编程方式绘制组织结构图?
我的程序的用户是按层次结构组织的。每个用户都是树中的一个节点,唯一的其他类型的节点是部门节点。每个节点有且仅有一个父节点(可能是根节点)。
我生成了一个供 graphviz 套件使用的 DOT 文件,但生成的图片无法使用,因为它太宽了。我不知道这个程序是否可以调整以满足我的需要,因为我有一个带有很多兄弟节点的扁平层次结构,所以也许我需要一个专门为此设计的程序(或编写我自己的程序)。我尝试了 unflatten 工具,但没有成功。
这是测试点文件 - 请注意,我的程序经常使用 10 倍的此数据...
Users of my program are organized hierarchically. Each user is a node in a tree, and the only other type of node is the department node. Each node has one and only one parent (possibly the root node).
I generated a DOT file to be used by the graphviz suite, but the resulting picture is unusable because it's too wide. I don't know if this program can be tuned to suit my needs, because I have a flat hierarchy with lots of sibling nodes, so maybe I need a program specifically designed for this (or write my own). I tried the unflatten tool, but without success.
This is the test dot file - note that my program often uses 10x this data...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的评论,这里使用除 dot 以外的其他布局算法进行快速测试。既然你说circle,我尝试了circo和twopi。
我必须对测试脚本进行一些细微的更改:
可能也会有所帮助。
您可能需要打开图像并以原始尺寸查看它们。
Twopi 布局:
Circo 布局:
如果您的部门与部门相互链接,或者一个部门中有很多用户,则 circo 布局可能更合适。
Based on your comment, here's a quick test using other layout algorithms than dot. Since you said circle, I tried with circo and twopi.
I had to make some slight changes to the test script:
Putting the long department names on two lines would probably help, too.
You'll probably have to open the images and look at them in the original size.
Twopi layout:
Circo layout:
The circo layout could probably be more appropriate if you have department linked to departments, or a lot of users in one department.
点语言有很多微妙的方法来修改图像,使其更令人赏心悦目。花几分钟浏览一下点指南。您可以对页面的 X/Y 比率、节点的排斥和布局等几乎任何方面设置约束。
graphviz 提供的 contrib 包之一是 GVEdit,它是一个链接到 graphviz 库的 Qt 小应用程序 - 一个编辑图形的窗口,点击“go”,它将渲染到另一个窗口。很棒的即时反馈方法,让事情变得更漂亮。
The dot language has a lot of subtle ways to modify the image to make it more pleasing. Take a few minutes out and skim the dot guide. You can set constraints on pretty much any aspect from the X/Y ratio of the page, the repulsion and layout of nodes.
One of the contrib packages available with graphviz is GVEdit, which is a little Qt app that links to the graphviz libraries - one window to edit graphs, hit 'go' and it'll render to another window. Great instant feedback method of making things pretty.