|
| 1 | +--- |
| 2 | +description: SVG flowchart and data visualization best practices to avoid common rendering issues |
| 3 | +--- |
| 4 | + |
| 5 | +# SVG Flowchart & Data Visualization Guidelines |
| 6 | + |
| 7 | +## Arrow Marker Best Practices |
| 8 | + |
| 9 | +1. **`refX` should be less than the arrowhead length.** If your arrowhead path is `M0,0 L0,6 L9,3 z` (length=9), set `refX` to `5` (not `9`). A `refX` equal to the arrowhead length causes the tip to land exactly at the path endpoint, which gets hidden behind destination nodes. |
| 10 | + |
| 11 | +2. **End arrow paths 5-10px before the target node boundary.** This leaves room for the arrowhead to be visible and not obscured by the node's fill. |
| 12 | + |
| 13 | +3. **Use `markerUnits="strokeWidth"`** for consistent arrowhead sizing regardless of stroke width changes. |
| 14 | + |
| 15 | +## SVG viewBox Sizing |
| 16 | + |
| 17 | +1. **Always add 30-50px padding** below the last element in your viewBox height. If the last element ends at y=940 with ry=35, set viewBox height to at least `1000`. |
| 18 | + |
| 19 | +2. **For dynamic data tables**, calculate viewBox height based on number of rows: |
| 20 | + |
| 21 | + ``` |
| 22 | + viewBox height = header_height + (row_count × row_height) + summary_text_spacing + padding |
| 23 | + ``` |
| 24 | +
|
| 25 | +## Text Overlap Prevention |
| 26 | +
|
| 27 | +1. **Summary text below data tables**: Position summary text at least `30px` below the last row's bottom edge (y + height), not at a fixed y coordinate. |
| 28 | +
|
| 29 | +2. **For N data rows at spacing S starting at Y0**: Last row bottom = `Y0 + (N-1) × S + row_height`. Summary text y should be `last_row_bottom + 30`. |
| 30 | +
|
| 31 | +## Prism.js Copy Button with Tailwind CSS |
| 32 | +
|
| 33 | +Tailwind's preflight CSS resets button styles. Override with `!important`: |
| 34 | +
|
| 35 | +```css |
| 36 | +.code-toolbar > .toolbar { |
| 37 | + opacity: 1 !important; |
| 38 | +} |
| 39 | +.code-toolbar > .toolbar .toolbar-item { |
| 40 | + display: inline-block !important; |
| 41 | +} |
| 42 | +.code-toolbar > .toolbar button, |
| 43 | +.code-toolbar > .toolbar a, |
| 44 | +.code-toolbar > .toolbar span { |
| 45 | + background: #10b981 !important; |
| 46 | + color: white !important; |
| 47 | + border: none !important; |
| 48 | + display: inline-block !important; |
| 49 | + opacity: 1 !important; |
| 50 | + visibility: visible !important; |
| 51 | +} |
| 52 | +``` |
0 commit comments