Skip to content

Commit 0034923

Browse files
fix(#1532): place parts below master (LR) / right of master (TB)
The prior ordering edges were being overridden: inside the entity cluster, the master is anchored by its derivation-chain edges and the real master->part FK edge forced the part above (LR). Fix by (a) marking master->part FK edges constraint=false so they don't vote on within-rank order, and (b) adding an invisible ordering edge whose direction depends on rankdir — reversed (part->master) for LR to put parts below, forward (master->part) for TB to put parts to the right. Both recipes verified empirically.
1 parent 4ad3637 commit 0034923

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/datajoint/diagram.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,12 @@ def make_dot(self, theme=None):
16411641
edge.set_penwidth(0.75 if multi else 2)
16421642
edge.set_weight(1 if multi else 3)
16431643
edge.set_arrowhead("none")
1644+
# A master→part edge is drawn but must NOT constrain the within-rank
1645+
# order, so the invisible ordering edges (added per entity below) can
1646+
# place the part below the master (LR) / to its right (TB).
1647+
dst = edge.get_destination().strip('"')
1648+
if dst in part_names and part_master.get(dst) == edge.get_source().strip('"'):
1649+
edge.set_constraint("false")
16441650

16451651
# Group nodes into schema clusters (always on)
16461652
if schema_map:
@@ -1704,12 +1710,15 @@ def make_dot(self, theme=None):
17041710
rank = pydot.Subgraph(rank="same")
17051711
for nm in same_rank:
17061712
rank.add_node(pydot.Node(nm))
1707-
# Pin the within-rank order: master first, then its
1708-
# parts. As flat (same-rank) edges, these place the parts
1709-
# after the master — below it in LR, to its right in TB —
1710-
# rather than leaving the order to Graphviz's heuristic.
1713+
# Pin the within-rank order so parts sit below the master
1714+
# in LR and to its right in TB. Inside a cluster whose
1715+
# master is anchored by external (derivation-chain) edges,
1716+
# Graphviz's flat-edge ordering is inverted between the two
1717+
# orientations, so the invisible ordering edge direction
1718+
# is chosen per rankdir (verified empirically).
17111719
for a, b in zip(same_rank, same_rank[1:]):
1712-
rank.add_edge(pydot.Edge(a, b, style="invis"))
1720+
tail, head = (a, b) if direction == "TB" else (b, a)
1721+
rank.add_edge(pydot.Edge(tail, head, style="invis"))
17131722
entity.add_subgraph(rank)
17141723
cluster.add_subgraph(entity)
17151724

0 commit comments

Comments
 (0)