Docs / Layout problems

Diagram line crosses a box: how to fix it

The message means a line runs through a block it does not join, and disappears behind that block.

Updated

{"title": "Bookshop orders",
 "columns": [[{"id": "shop", "title": "Online shop", "tiles": ["Checkout"]}],
             [{"id": "orders", "title": "Order service", "tiles": ["Orders"]}],
             [{"id": "post", "title": "Parcel desk", "tiles": ["Labels"]}]],
 "links": [{"from": "shop", "to": "orders"}, {"from": "orders", "to": "post"},
           {"from": "shop", "to": "post"}]}
Bookshop orders

The check: 1 layout problem(s)

line 'shop' -> 'post' crosses 'orders'; route it with via_x/via_y, move a block, or pass cross_ok=True

Why does it happen?

The shortest path between the two blocks leads through a third, and blocks are drawn over lines. The check walks along every line and reports each block it enters, apart from the two it joins.

In the columns layout, a line from the first column to the third must pass the second. Here shop to post runs behind orders, and looks like a second line into orders and a second line out of it.

How do I fix it?

Send the line around the block, or move the blocks so its path is clear. The message gives the Python names. JSON uses the same keys, via_x, via_y and cross_ok, and adds lane.

  1. In JSON, add "lane": "top" or "lane": "bottom" to the link.
  2. In Python, pass via_y, a height above or below every block, such as min(p.y for p in d.placed) - 80.
  3. Or pass via_x, a position beside the blocks, for a line that should run down the side.
  4. Or set start and end to other sides of the two blocks.
  5. Or move a block, so the two ends sit side by side.
  6. Run the check again.

A top lane runs 70 px above the highest block, and each further line in it 30 px higher. A line through a lane always turns at right angles. With the third line in the top lane, the check reports 0 layout problems:

{"title": "Bookshop orders",
 "columns": [[{"id": "shop", "title": "Online shop", "tiles": ["Checkout"]}],
             [{"id": "orders", "title": "Order service", "tiles": ["Orders"]}],
             [{"id": "post", "title": "Parcel desk", "tiles": ["Labels"]}]],
 "links": [{"from": "shop", "to": "orders"}, {"from": "orders", "to": "post"},
           {"from": "shop", "to": "post", "lane": "top"}]}
Bookshop orders

The check: 0 layout problems

What if the line should pass behind the box?

Set "cross_ok": true on the link, or cross_ok=True in Python. The line is still drawn behind the block, and the check stops reporting it.

See also