A phone's wrapped flow stacks into one column: when a graph is still wider than three nodes after wrapping, a last pass centres every rank, so wrapped rows sit under the row above (Demo house 3721 to 947px across at 390, crossings 295 to 263)

This commit is contained in:
2026-10-15 18:32:44 +02:00
parent 453b0be6f6
commit 5ca90ffece
3 changed files with 92 additions and 12 deletions
@@ -270,6 +270,38 @@ for (const [y, count] of rows) {
)
}
/**
* A hub read by eight readers, each feeding a sink of its own: the shape of
* the Demo's house and its dashboards. Wrapped two abreast with straight
* edges, each row landed where its edges pulled it and the graph staircased
* to 1400px across. Centred, the rows stack into one column.
*/
const readers = Array.from({ length: 8 }, (_, i) => `r${i}`)
const hub = await layoutGraph(
["hub", ...readers, ...readers.map((r) => `${r}.sink`)],
readers.flatMap((r) => [
{ id: r, source: "hub", target: r, sourceHandle: "v", targetHandle: "v" },
{
id: `${r}.sink`,
source: r,
target: `${r}.sink`,
sourceHandle: "v",
targetHandle: "v",
},
]),
"TB",
new Map(
["hub", ...readers, ...readers.map((r) => `${r}.sink`)].map((id) => [
id,
one("v"),
]),
),
)
const hubX = [...hub.positions.values()].map((at) => at.x)
const across = Math.max(...hubX) + 220 - Math.min(...hubX)
// Three nodes and their gaps: one more than the two a row holds.
assert.ok(across <= 3 * 260, `a wrapped graph runs ${across}px across`)
/**
* Every edge comes back routed, port to port, square, and around what is in
* the way. `back` closes a cycle over `mid`: drawn straight between its two