#142

maxWidth leaves a flowchart's label wrapping at 120px and its subgraph titles unwrapped

Openmax-sixtyopened 20d ago

With maxWidth, a left-to-right flowchart turns top-down and spacing tightens, but a top-down flowchart whose rank holds boxes side by side keeps the 120px wrappingWidth, so it stays wider than maxWidth. In 1.13.0, under Node:

render(`flowchart TD
  A[Agent writes the page] --> B[Browser draws the widgets and the page]
  A --> C[Agent fixes the markup and tries again]`, { maxWidth: 342 });
// width 494 (514 without maxWidth)

The same source parsed with config: { flowchart: { wrappingWidth: 84, nodeSpacing: 8 } } renders 246px wide. A subgraph's title doesn't wrap under either config: subgraph S[The operations that prepare and validate every incoming request] around two boxes renders 486px wide at maxWidth: 342. The Narrow screens docs say Pele "may wrap labels, reduce spacing, or rearrange the diagram"; would maxWidth narrowing a flowchart's wrapping width and node spacing, down to a floor, and wrapping subgraph titles, fit Pele's design?

This was written by Claude Code on behalf of max-sixty

Activity

1
clemlesne2d ago

Use case: diagrams rendered into a phone-width column (about 300–360px) with maxWidth, so their text keeps its size instead of being scaled down. Today most of the flowcharts I tried still come out wider than that column.

On the title: as #144 says, a plain flowchart wraps at 200px in 1.13.0; the 120px is the agentflow default.

A four-box example: it turns down under maxWidth, but two boxes on one rank keep their 200px labels, so it stays wider than maxWidth:

Reproduction (pele 1.13.0, Node 26, default measurer)
import { render } from 'pele';

const source = `flowchart LR
  A[Receive the incoming request from the client] --> B[Check the request against the stored rules]
  A --> C[Write the request to the log for later review]
  B --> D[Send the response back to the client]
  C --> D`;

console.log(render(source).width);                     // 761
console.log(render(source, { maxWidth: 320 }).width);  // 486
console.log(render(source, { maxWidth: 320, config: { flowchart: { wrappingWidth: 100 } } }).width); // 310

With the change from #144 applied to the 1.13.0 build, maxWidth: 320 gives 290px. On a set of 20 real-world flowcharts rendered with maxWidth: 328 and fontSize: 14, 1 fits in 1.13.0 and 12 fit with the #144 change, the same 12 that fit with wrappingWidth: 100.