Page 3 · 2D Diagram — Pylon & Cable Fan (v1.3)
v1.3: VIEW 1 is now a true side view — one tower shaft with the far leg as a dashed hidden line, not the transverse portal silhouette it used to draw. The pylon shape lives in VIEW 2 (Front), where it belongs.
← Brief 1. Inventory Form 2. Update Progress 3. 2D Diagram

Drawing a cable-stayed bridge in the 2D diagram

This is the largest piece of front-end work in the CR. Read the three constraints first — they explain why the design looks the way it does — then the two views, which explain why one elevation is not enough.

CONSTRAINT 1
The diagram has no scale — at all

Every span renders at exactly 140 px wide regardless of real length. Every pier is exactly 140 px tall regardless of real height. length_of_span is captured on the form but never read by the diagram. Real pier height is used only for the partial-fill ratio.

CONSTRAINT 2
It's four copy-pasted files

single_pier, portal_pier, double_pier, double_portal_pier — each ~100 KB of inline JS with the same helpers redefined. No shared module. The last SVG bugfix was applied identically four times. A fifth variant makes it five.

CONSTRAINT 3
Grow and scroll — never scale to fit

There's no viewBox. A past commit explicitly removed max-width:100% because it shrank the diagram instead of letting it overflow. That was a deliberate product decision — keep it. The cable-stayed canvas gets wider and taller and scrolls.

Why the diagram needs two views

Stand at the side of the bridge and the second pylon leg is directly behind the first, with its whole cable plane hidden. No amount of detail in the side view recovers that — it needs a second view. Both views are live in the diagram below and are driven by the same four controls: cable arrangement, span width, legs and pylon type. Switch VIEW to Front to cut a transverse section at every pylon.

View 1 · Longitudinal elevation

What the diagram draws today. Supports keep the boxed tag below the ground line — A1 · P1 … P8 · A2 — from the same addBoxedLabel(px, baseY + 70, 'P' + n) call the four existing partials use. Each pylon is one shaft: from the side the two legs coincide, so the far one is drawn as a dashed hidden line.

View 2 · Transverse section

One section per pylon, drawn from the same seed data. Two legs, two cable planes, the deck passing between them — and the pylon shape is finally unambiguous, because you are no longer sighting along the legs.

LHS and RHS are the same view, one leg each

Picking LHS or RHS renders a single elevation band for that cable plane. Both stacks the two. Superimposed collapses them and falls back to the lesser of the two stages — safe, but it hides real progress.

The leg suffix is the only addition

At a pylon, P3 resolves to two progress locations — pl_3 and pr_3 — exactly as portal_pier.blade.php already does. No new key format, no schema change.

Live · Mindhola River Bridge — two views
CABLE ARRANGEMENT
SPAN WIDTH
VIEW · LEGS
PYLON TYPE
VIEW 1 · LONGITUDINAL ELEVATION
TRANSVERSE
shape visible here
PLAN
2 anchor lines
H-Frame

Deck anchor lines: 2 Cables drawn in elevation: 82 Physical cables: 164 Cross beams: 2 per pylon

Changing this redraws the pylons in VIEW 2. A true longitudinal elevation sights along the legs, so every pylon type looks like the same vertical tower from the side — which is why VIEW 1 now draws a plain shaft with the far leg as a dashed hidden line, and the silhouette appears only in VIEW 2. Earlier drafts drew the transverse silhouette in elevation to make the type visible; that was the right call before a front view existed, and the wrong one now — it made the side view read as a front view. The type still changes VIEW 1 in one real way: the anchorage zone, and therefore where the fan starts.

LEGEND Not started Pylon in progress Complete | Cable — not started Anchorage Installed Initial tension Final stress | Expansion joint Far leg, hidden behind (elevation only)

Span width must become proportional

Toggle "Equal (today)" above. With fixed 140 px spans, Mindhola's three 150 m main spans render the same width as its 35 m approach spans — and the cable fans collide because there's no room between pylons. On a girder bridge nobody noticed. On a cable-stayed bridge it's unreadable.

pxPerM = TARGET_WIDTH / totalLength
spanPx[i] = max(MIN_SPAN_PX, len[i] × pxPerM)

Scope this to the new partial only. Don't retrofit proportional width onto the four existing partials in this CR — that changes how every live bridge looks and needs its own client sign-off.

Why each leg must be drawn separately

Mindhola has two cable planes, one carried by each pylon leg. BMS already keys the legs of a portal pier separately — pl_n and pr_n — and stay cables follow that exactly, because the cable plane is the leg.

The problem with superimposing the legs

Cables are stressed one plane at a time. If leg L cable 5 at P3 is finally stressed but leg R cable 5 is only installed, a superimposed view has one line and two different truths. Whatever colour you pick is wrong for one of them.

Switch the VIEW · LEGS control to "Superimposed" above — the diagram falls back to showing the lesser of the two stages, which is safe but silently hides real progress from the client.

Splitting by leg solves it

Each leg gets its own 82 cables and its own colours — 164 in total, matching the component plan quantity exactly. No arithmetic to explain, no hidden state.

This follows the portal pier pattern already in BMS, not the dual-carriageway one. Portal legs are keyed pl_n/pr_n with their own heights and their own progress — a pylon is simply a taller version. See the two views at the top of this page.

The data model already supports it. The side lives in the location key, as it already does for portal legs: pl_2 + item a1_cable_1, and pr_2 + the same item name. No schema change, no invented prefix. Single Mast is the exception — one central tower, so there is no L/R split and the toggle collapses to a single band automatically.

Cables anchor in a band at the pylon head

In a semi-fan the anchorages sit on the upper part of the pylon, spread over a short length rather than concentrated at one point — spacing them avoids the stress concentration a pure fan creates and leaves room to re-tension each cable later.

The New Panama Canal Bridge is a documented example: an anchorage zone roughly 45 m tall at 2.5 m vertical spacing between adjacent anchor points.

A-frame · diamond · vase → 3–30% of mast (apex, tight)
H-frame → 4–42% of upper legs
Inverted-Y · single mast → 5–55% (long mast)
Applies to VIEW 2. The fan once spread to mid-mast on every shape, and the H-frame's portal arch sat at 9–34% — exactly where the cables anchored, so they appeared to emerge from the opening. The arch now sits below the anchorage zone, just above the deck, which is where a real H-pylon puts it: anchorages need solid leg. In VIEW 1 the same numbers set where the fan leaves the shaft.

Cream doesn't work for cables

Every existing component uses #fff9d9 for "not started" — which also happens to be the canvas background. That's fine for a filled rect with a black stroke around it. A 1–2 px line in that colour on that background is invisible.

✗ not-started cable = #fff9d9 → invisible
✓ not-started cable = #C9CBD0 dashed → reads as "planned"

This is a genuine new rule, not a style preference — the existing palette simply has no case for line-shaped components.

The cable fan geometry

One pylon, one direction. Every cable is a straight line from a point on the pylon to a point on the deck — the arrangement only changes how those two point-sets are distributed.

// ---- LAYOUT CONSTANTS (cable_stayed variant) ----
const PYLON_HEADROOM = 240;          // NEW: room above deck
const baseY  = 320 + PYLON_HEADROOM; // ground line
const deckY  = 180 + PYLON_HEADROOM; // deck top
const MAX_UPPER_PX = 200;            // tallest mast on screen

// every existing y-constant shifts down by PYLON_HEADROOM;
// svg height grows 950 -> 1190 (common carriageway)

// ---- PYLON ----
upperPx   = MAX_UPPER_PX * (upperH / maxUpperH);
pylonTopY = deckY - upperPx;

// lower pylon: deckY..baseY, fills UP from baseY
// upper pylon: pylonTopY..deckY, fills UP from deckY
// both reuse drawPier()'s partial-fill algorithm verbatim:
h = fullPx * Math.min(done, total) / total;
color = done >= total ? '#7ED321' : '#D9A526';

// ---- CABLE FAN ----  dir = -1 (A1 side) | +1 (A2 side)
const nearX = 26;
const farX  = adjacentSpanPx * 0.45;
const fanTopY = pylonTopY + 10;
const fanBotY = pylonTopY + upperPx * 0.50;

for (let i = 0; i < n; i++) {
  const t = (n === 1) ? 0 : i / (n - 1);
  let ay, ax;

  if (arrangement === 'semi_fan') {
    ay = fanBotY - t * (fanBotY - fanTopY);
    ax = px + dir * (nearX + t * (farX - nearX));

  } else if (arrangement === 'fan') {
    ay = fanTopY;                       // all from one point
    ax = px + dir * (nearX + t * (farX - nearX));

  } else /* harp — parallel, equal slopes */ {
    const k = farX / upperPx;
    ay = pylonTopY + t * upperPx * 0.85;
    ax = px + dir * k * (deckY - ay);
  }

  drawCable(px, ay, ax, deckY, stageColor(cableStage(i)));
}

Three views, and what each one is for

In a strict longitudinal elevation, an H-frame, an A-frame and an inverted-Y all look like the same single tower — you're sighting along the line of the legs, so one hides the other. The shape is only visible looking across or down.

So we draw two views instead of bending one. VIEW 1 is a true elevation — one shaft per pylon, far leg as a dashed hidden line. VIEW 2 is the transverse section, where the shape is unambiguous. An earlier draft put the transverse silhouette inside the elevation band so the type would be recognisable at a glance; that was right while there was no front view, and wrong once there was — it made the side view read as a front view. Reversed 2026-09-28. Flag the two-view split to the client as a decision, not an accident.
ELEVATION · VIEW 1 (what we draw)
H / A / Y all identical — correctly so dashed = far leg, hidden behind
TRANSVERSE · VIEW 2 (what we draw)
H-frame: two legs + cross beams
PLAN (already exists in BMS)
Two legs = two cable planes
Practical consequence: pylon_shape resolves to a small set of line segments in normalised space (see shapeSegments() in this page's source — it's about 10 lines and can be lifted directly). Those segments scale into the pylon's box in VIEW 2 and drive the plan view. VIEW 1 doesn't touch them at all — it draws a plain rect, so the elevation renderer stays shape-agnostic and needs no per-shape branching. The one thing shape changes in VIEW 1 is the anchorage zone (fanFrom / fanTo), which is two numbers, not a path.
⚠ Expect 82 cables in the elevation, not 164. Mindhola has 164 physical stay cables — but the two legs sit directly behind one another in side view, so they render as one line each. The elevation draws cable_count_a1 + cable_count_a2 per pylon (82 total); the component plan still counts × planes (164). Both numbers are correct — they answer different questions. Worth a code comment, or someone will "fix" it.

Cables need an invisible hit area

A 2 px diagonal line is almost impossible to click. Draw each cable twice: a transparent fat line for hit-testing, then the visible thin one on top.

// hit area first (underneath)
hit = line(x1,y1,x2,y2);
hit.setAttribute('stroke','transparent');
hit.setAttribute('stroke-width','12');
hit.addEventListener('click', () =>
  loadComponentData(STAY_CABLE_ID, 'p_2'));

// visible cable on top
vis = line(x1,y1,x2,y2);
vis.setAttribute('stroke', stageColor);
vis.setAttribute('stroke-width','2');

Keep the existing convention: click handlers are attached only to components with progress. A not-started cable stays non-clickable, same as every other component today.

Tooltips use a <title> child, as today — hover a cable in the diagram above to see it.

Build order

  1. 1
    Add the @else fallback to both dispatch sites first. Five minutes, and it stops an unknown pier type silently rendering a blank box.
  2. 2
    Create 2d-image/cable_stayed.blade.php by copying single_pier.blade.php — it's the closest base (common carriageway, one pier per support).
  3. 3
    Shift every y-constant by PYLON_HEADROOM and switch the horizontal loop to proportional span widths.
  4. 4
    Add drawPylon() — literally drawPier() with a taller box, called twice (lower, upper).
  5. 5
    Add drawCableFan() and the stage colour map.
  6. 6
    Branch the plan-view band on pylon_shape for 1 vs 2 legs.
  7. 7
    Add a legend. The current diagram has none — with four cable stages plus pylon states, it stops being self-explanatory.

One thing to decide before starting: extract the renderer, or copy a fifth time?

Step 2 above says "copy single_pier.blade.php" because that's what the codebase does today. It's also how we got to four near-identical 100 KB files where every bugfix has to be applied four times.

Copy a fifth time

Fastest to ship, zero risk to existing bridges. Cost: every future SVG fix becomes a 5× edit, and the cable-stayed file will drift from the others.

Extract the shared renderer first

Pull the common helpers into one JS module, then add cable-stayed as a variant. Costs maybe a week up front and needs regression testing on all four existing pier types — but it's the last cheap moment to do it.

This is a PM/client decision about paying down debt, not a technical unknown. Flagging it here because it's the single biggest hidden cost in the CR and it gets more expensive with every variant added.

Page 3 of 3 · ← Back to the brief