混合垂直和水平布局(用于水平布局的类图)

时间:2015-07-21 15:17:15

标签: graphviz

我正在尝试在GraphViz中显示类图。我希望它主要是水平布局 - 但是我遇到了一个问题,因为它也是水平分离出每个类的三个部分(即类名,属性和方法)。我已经尝试了每个节点使用rankdir = LR的子图,但它不起作用。

这是我的代码:

digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="20,10"]
rankdir=LR

1[label = "{Hazards|+ ID\n + Description\n + RiskLevel|+f Topics}" ]
2[label = "{Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
3[label = "{User Requirements|+ ID\n + Requirement\n + Status\n +     Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility}"]
4[label = "{Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
5[label = "{Acceptance Test Log|+ TestID\n +DateRun\n + Relevance}"]
6[label = "{Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
7[label = "{State Transition Diagram|+ ID\n + States\n + Transitions\n + Model}"]
8[label = "{System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics}"]
9[label = "{Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity}"]
10[label = "{Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert}"]
11[label = "{Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics}"]
12[label = "{Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
13[label = "{Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems}"]
14[label = "{Components|+ ID\n + Name|+f  Fault Likelihood}"]

1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9
}

不幸的是我不允许发布图片,因为我没有StackOverflow信誉。但是,您可以通过将rankdir = LR替换为rankdir = TB来查看垂直解决方案。

有没有人知道如何组合两个布局,以便类保持堆叠,即类名高于函数等属性,但整体布局是LR?

如果有办法在GraphVis中直接指定,我不想使用UMLGraph.lib。

非常感谢 简

1 个答案:

答案 0 :(得分:1)

答案是:

digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="15,20"]
rankdir=LR

1[label = "Hazards|+ ID\n + Description\n + RiskLevel\n+f Topics"]
2[label = "Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
3[label = "User Requirements|+ ID\n + Requirement\n + Status\n + Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility"]
4[label = "Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
5[label = "Acceptance Test Log|+ TestID\n +DateRun\n + Relevance"]
6[label = "Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
7[label = "State Transition Diagram|+ ID\n + States\n + Transitions\n + Model"]
8[label = "System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics"]
9[label = "Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity"]
10[label = "Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert"]
11[label = "Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics"]
12[label = "Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
13[label = "Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems"]
14[label = "Components|+ ID\n + Name|+f  Fault Likelihood"]

1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9

}