2015-07-21 221 views
2

我想在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。

非常感謝 簡因此

+0

我要回答我的問題 - 因爲我一直試圖在過去幾年來解決這個天。事實證明,我只需要在標籤中定義文本的開頭和結尾處省略{}。 因此,現在單個標籤看起來像這樣: 這給了我正是我想要的東西。一個架構(類似於一個類圖)從左到右佈置,「類」的三個部分垂直堆疊。 –

回答

0

答案是:

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 

}