From 084a726c6dd87dba31016c769f7fb9e0e592bd2f Mon Sep 17 00:00:00 2001 From: Sterling Archer Date: Sat, 13 Jun 2026 21:32:22 -0700 Subject: [PATCH] Fix ChordDiagram: three separate columns so labels and markers never overlap --- index.html | 56 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index 6da0bcc..e027127 100644 --- a/index.html +++ b/index.html @@ -151,52 +151,60 @@ function ChordDiagram({ name }) { const sh = CHORDS[name]; if (!sh) return null; - const NUM_FRETS=5, NS=6, W=320, H=200; - const TOP=44, BOT=H-24, LEFT=44, RIGHT=W-12; + // Three columns left of nut: + // col1=12 (string letter), col2=34 (open/muted symbol), nut at LEFT=60 + const NUM_FRETS=5, NS=6, W=320, H=210; + const TOP=44, BOT=H-22, LEFT=60, RIGHT=W-10; const strGap=(BOT-TOP)/(NS-1); const fretGap=(RIGHT-LEFT)/NUM_FRETS; const STRING_LABELS=["E","A","D","G","B","e"]; - - // Build note list from chord shape: open strings + fretted dots - const notes = []; - sh.open.forEach(s=>{ notes.push({str:s, fret:0, label:"o", muted:false}); }); - sh.muted.forEach(s=>{ notes.push({str:s, fret:-1, label:"x", muted:true}); }); - sh.dots.forEach(({s,f,n})=>{ notes.push({str:s, fret:f, label:n, muted:false, finger:true}); }); + const COL_LABEL=12, COL_MARKER=36; return (
{name}
+ {/* Nut */} + {/* Frets */} {Array.from({length:NUM_FRETS+1},(_,f)=>( ))} + {/* Strings */} {Array.from({length:NS},(_,s)=>( + stroke={C.string} strokeWidth={s===0?2:s===5?0.8:1.2}/> ))} + {/* Col 1: string name labels */} {STRING_LABELS.map((n,s)=>( - {n} + {n} ))} + {/* Col 2: open or muted markers */} + {Array.from({length:NS},(_,s)=>{ + const cy=TOP+s*strGap; + const isOpen = sh.open.includes(s); + const isMuted = sh.muted.includes(s); + if(isOpen) return ( + + + + ); + if(isMuted) return ( + + + + + ); + return null; + })} + {/* Fret numbers */} {Array.from({length:NUM_FRETS},(_,f)=>( {f+1} ))} - {sh.muted.map(s=>{ - const cy=TOP+s*strGap; - return ( - - - - - ); - })} - {sh.open.map(s=>( - - ))} + {/* Fretted finger dots */} {sh.dots.map(({s,f,n},i)=>{ const cx = LEFT+(f-0.5)*fretGap; const cy = TOP+s*strGap;