我第一次使用dot + GraphViz来帮助规划图表数据库架构。
随着我添加更多节点,输出看起来不太理想。特别是,语言和国家看起来相当混乱。
我已经尝试了一些基本的排名,但却无法影响它。
如何获得更清晰的输出?
代码:
digraph ReferenceGraph {
nodesep = 2;
edge [color=gray50, fontname=Calibri, fontsize=11]
node [shape=record, fontname=Calibri, fontsize=11]
root [label="Reference Node", color=darkgreen, fontcolor=darkgreen, fontname=Calibri, fontsize=11]
sue [label="{{User}|{GivenName=Sue}|{FamilyName=Williams}|{Username=swilliams}|{EmailAddress=Sue.Williams@foo.com}|{BusinessPhone=02 1234 5678}|{MobilePhone=0414 123 456}|{PasswordSalt=fcd376dc}|{PasswordHash=a8635cfd2930ebc0cc78}|{PreviousPasswordSalt=gggf6dc}|{PreviousPasswordHash=wer435cfd2930ebc0cc78}|{RequirePasswordChangeOnNextLogin=true}|FailedLoginAttempts=0|LastLoginAttemptUtc=21 Jun 2011 16:43:01 UTC|{DateCreatedUtc=20 Jun 2011 15:43:07 UTC}}", color=blue, fontcolor=blue]
sue -> root [label="ADMINISTERS"]
clint [label="{{Client}|{UniqueId=100}|{GivenName=Clint}|{MiddleNames=ian bill}|{FamilyName=Wood}|{PreferredName=Woods}|{Gender=Male Female Unknown}|{PlaceOfBirthTown}|{PlaceOfBirthState}|{PlaceOfBirthCountry}|{Email=clint.wood@foo.com}|{LanguageComments}|{InterpreterRequired=true false}|{InterpreterComments}|{Religion=Buddhist}|{LegalOrders=order1}|{DateOfBirth=21 June 1979}|{DateOfBirthCertainty=Confirmed Unconfirmed Estimated}}", color=blue, fontcolor=blue]
clint -> acme [label="CLIENT_BELONGS_TO"]
clint -> english [label ="SPEAKS"]
cat [label="Cat (Client)"]
cat -> acme [label="CLIENT_BELONGS_TO"]
cat -> english [label ="SPEAKS"]
cat -> mandarin [label ="SPEAKS"]
acme [label="{{Agency}|{UniqueId=100}|{Key=acme}|{Name=Acme Australia}}", color=blue, fontcolor=blue]
root -> acme [label="HOSTS"]
john [label="John (User)"]
john -> acme [label="USER_BELONGS_TO"]
jack [label="Jack (User)"]
jack -> acme [label="USER_BELONGS_TO"]
centreA [label="{{Centre}|{Name=CentreA}|{BusinessPhone=02 1234 5678}|{Fax=0414 123 456}|{Email=xyz@bcb.com}|{Status=Active}}", color=blue, fontcolor=blue]
centreA -> acme [label="CENTRE_BELONGS_TO"]
centreAStreetAddress [label="{{PhysicalAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue]
centreA -> centreAStreetAddress [label="HAS_STREET_ADDRESS"]
centreAPostalAddress [label="PO Box 123 (PhysicalAddress)"]
centreA -> centreAPostalAddress [label="HAS_POSTAL_ADDRESS"]
clintCurrentAddress [label="{{CurrentAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue]
clint -> clintCurrentAddress [label="HAS_STREET_ADDRESS"]
referenceData [label="Reference Data"]
root -> referenceData [label="HAS_REFERENCE_DATA"]
languagesReferenceData [label="Languages"]
referenceData -> languagesReferenceData [label="HAS_LANGUAGES"]
english [label="{{Language}|{Name=English}}", color=blue, fontcolor=blue]
languagesReferenceData -> english [label="HAS_LANGUAGE"]
mandarin [label="Mandarin (Language)"]
languagesReferenceData -> mandarin [label="HAS_LANGUAGE"]
japanese [label="Japanese (Language)"]
languagesReferenceData -> japanese [label="HAS_LANGUAGE"]
countriesReferenceData [label="Countries"]
referenceData -> countriesReferenceData [label="HAS_COUNTRIES"]
australia [label="{{Country}|{Name=Australia}}", color=blue, fontcolor=blue]
countriesReferenceData -> australia [label="HAS_COUNTRY"]
china [label="China (Country)"]
countriesReferenceData -> china[label="HAS_COUNTRY"]
}
答案 0 :(得分:7)
您可以尝试添加
splines=true;
overlap=prism;
而不是nodesep=2;
并使用 neato 而不是 dot 呈现图表。这将导致更紧凑的布局标签确实与某些节点重叠,并且基于记录的节点非常接近彼此。
请注意,尽管使用graphviz可能永远无法获得完美的数据库模式 - 但几乎总会有一些交叉边缘可以以更好的方式布局。手动布局的数据库架构将击败graphviz输出。