# Pitfalls Checklist Run through this list after writing the SVG and before saving the file. Most diagram failures are one of these ten, and they all happen silently — the SVG is "valid" but looks wrong when rendered. Read this as a code review on yourself. If any item fails, fix the SVG and re-check. ## 1. viewBox clips content **Symptom**: the bottom row of boxes is cut off, or a label disappears past the right edge. **Check**: - Find the lowest element. For rects: `y + height`. For text: `y + 4` (descender). For circles: `cy + r`. - `viewBox` height must be `max(those) + 20` or more. - Find the rightmost element. For rects: `x + width`. No rect's right edge should exceed 640. **Fix**: increase `H` in `viewBox="0 0 680 H"`, or shrink the content horizontally. **Exception — subsystem architecture pattern.** The 2-up sibling containers (see `structural.md` → "Subsystem architecture pattern" and `layout-math.md` → "Sibling subsystem containers (2-up)") deliberately sacrifice the 40px horizontal safe margin so each sibling interior is wide enough for a short internal flow. With `container_A.x=20` and `container_B.x=345, width=315`, container B's right edge lands at **660**. That is the documented layout; rects belonging to the 2-up pattern may extend up to x=660 instead of 640. All content *inside* each container (internal nodes, cross-system labels) still respects its own interior edge — no individual flowchart rect inside a sibling should touch the dashed border. ## 2. Text overflows its box **Symptom**: a label spills out past the border of its container. **Check**: for every labeled rect, compute `label_chars × char_width + 24` (8 for 14px latin, 7 for 12px latin, 15 for 14px CJK). The rect's width must be ≥ that number. **Fix**: widen the rect, or shorten the label. Subtitles > 5 words are always a smell — cut them. ## 3. Arrow crosses an unrelated box **Symptom**: an arrow visibly slashes through the interior of a rect it's not anchored to. **Check**: for every arrow, trace its line segment(s). For every other rect in the diagram, does the arrow cross the rect's interior? If yes, it's a bug. **Fix**: replace the straight `` with an L-bend `` that routes around the obstacle: ```svg ``` Pick `ymid` so the horizontal channel runs through empty space between rows. ## 4. Connector path is missing `fill="none"` **Symptom**: a curved connector renders as a giant black blob instead of a thin line. **Check**: every `` or `` used as a connector must have `fill="none"` as an explicit attribute. SVG defaults paths to `fill: black`. **Fix**: add `fill="none"` — or use the `arr` class, which already sets it. ## 5. Text has no class, renders as default **Symptom**: a label looks slightly different from the rest — wrong size, wrong color, or black in dark mode. **Check**: every `` element must have a class: `t`, `ts`, `th`, or (in poster flowcharts only) `title`, `eyebrow`, `caption`, `anno`. No unclassed text. No `fill="inherit"`. No hardcoded `fill="black"`. **Fix**: add the appropriate class. `t` for single-line body, `th` for titles (bold), `ts` for subtitles and callouts. In a poster flowchart, `title` for the top label, `eyebrow` for section dividers, `caption` for the footer hook, `anno` for right-column side notes. ## 6. Title and subtitle use the same color stop **Symptom**: a two-line node looks visually flat — the title and subtitle blur together. **Check**: inside any `c-{ramp}` box, the `th` and `ts` children must land on different stops. The template handles this automatically (th → stop 800, ts → stop 600), so this only breaks if you manually override a fill. Don't. **Fix**: remove the inline `fill=` override; let the template classes do their job. ## 7. `text-anchor="end"` at low x **Symptom**: a label is missing from the left side of the diagram — it's actually there, but it extends past x=0 and is clipped by the viewBox. **Check**: for every `` with `text-anchor="end"`, the label's width must fit to the left of its x coordinate: `label_chars × char_width < x`. **Fix**: use `text-anchor="start"` and right-align the column manually, or move the text to a higher x. ## 8. Color rainbow (colors cycle instead of encoding meaning) **Symptom**: a 5-step flowchart uses blue-teal-amber-coral-purple, one per step. Reader can't tell if the colors mean anything. **Check**: do colors encode categories (all "immune cells" share one color) or do they encode sequence (step-1 blue, step-2 teal)? Sequence is wrong. **Fix**: collapse to ≤2 ramps. Use gray for neutral/structural/sequential steps. Reserve one accent color for whichever nodes deserve emphasis — the decision point, the anomaly, the main character of the story. ## 9. Too many boxes in a full-width row **Symptom**: boxes overlap each other, or text spills across box borders. **Check**: `N × box_width + (N - 1) × gap ≤ 600`. If you tried to fit 5+ boxes at default width (180 each), you've already overflowed. **Fix**: - Shrink box_width to ≤110 (drops subtitles) - Wrap to 2 rows - Split into overview + detail diagrams ## 10. Cycle drawn as a physical ring **Symptom**: a four-stage cycle (Krebs, event loop, GC) is laid out with boxes orbiting a dashed circle. Labels collide with stage boxes; feedback arrows point at weird angles. **Check**: does the diagram try to show a loop by arranging boxes in a circle? **Fix**: lay the stages out linearly (horizontal or vertical) and draw a single return arrow from the last stage back to the first — or simply add a small `↻ returns to start` label near the endpoint. The loop is conveyed by the return arrow, not by literal ring geometry. ## 11. Dark-mode invisible text (bonus check) **Symptom**: the SVG looks fine in light mode, but text disappears in dark mode. **Check**: did you hardcode any `fill="#..."` or `fill="black"` on a `` or ignore the `t`/`ts`/`th` classes? If yes, dark mode won't override it. **Fix**: remove hardcoded fills on text. Let the template classes handle both modes. **Exception**: physical-color scenes (sky blue, grass green, water teal in an illustrative diagram) *should* stay the same in both modes. Hardcode those hex values deliberately. But all label text — the `` elements with callouts and titles — must use the classes. ## 12. ` Title ``` The `box` class works as the mask because it uses opaque fill in both light and dark mode. Only add the mask rect when bleed-through is visible — most diagrams don't need it because the z-order rule (connectors drawn before nodes) already handles opaque fills. ## 30. Legend clips into a container boundary **Symptom**: a legend strip sits inside (or overlaps) a dashed container's bottom edge — the legend text reads as part of the container's content instead of as diagram-level metadata. **Check**: find the lowest container boundary: `container_y + container_h`. The legend's top edge must be ≥20px below that boundary. If the legend sits inside or touching any container, it's a bug. **Fix**: move the legend below all container boundaries. Calculate: `legend_y = max(all_container_bottoms) + 20`. Then extend viewBox H to accommodate: `H = legend_y + legend_h + 20`. Never squeeze a legend inside a container to save vertical space — expand the viewBox instead. ``` Container bottom at y=380 Legend at y=400 → 20px clear ✓ viewBox H = 400 + 16 + 20 = 436 ``` --- ## Quick self-review template Before writing the file, mentally run through: > 1. Lowest element is at y = ___ → viewBox H = ___ + 20 = ___ ✓ > 2. Rightmost rect edge is at x = ___ → ≤ 640 ✓ > 3. Longest label is "___" (___ chars) → needs width ___ → actual width ___ ✓ > 4. Arrows checked against all boxes → no crossings ✓ > 5. All connector paths have `fill="none"` ✓ > 6. All `` elements have a class ✓ > 7. Colors: ≤ 2 ramps → ___ and ___ → assigned by category ✓ > 8. No hardcoded text fills ✓ > 9. No comments in final output ✓ > 10. No arrow bleed-through on translucent fills (mask rect if needed) ✓ > 11. Legend sits ≥20px below all container boundaries ✓ If any of these feel fuzzy, the diagram isn't ready.