@@ -242,13 +242,14 @@ function createCrowsFootRelationshipLine(svg, fromEntityName, toEntityName, prop
242242}
243243
244244function drawCrowsFootNotation ( svg , x , y , direction , relationship , isFromSide ) {
245- const CROW_SIZE = 35 ; // Size of crow's foot
246- const ONE_SIDE_OFFSET = 20 ; // Offset from table edge for "one" side notation
247- const CIRCLE_RADIUS = 10 ; // Radius for optional indicator
248- const CIRCLE_OFFSET = - 20 ; // CHANGED: Negative offset to place circle BEFORE the crow's foot (closer to table)
245+ const CROW_SIZE = 35 ; // Size of crow's foot (distance from table edge to tip)
246+ const CIRCLE_RADIUS = 20 ; // Radius for optional indicator
247+ const GAP = 5 ; // Small gap between circle and notation
248+ const CIRCLE_OFFSET = CROW_SIZE + CIRCLE_RADIUS + GAP ; // Position circle with gap from notation
249249
250- // Use the same blue color as relationship lines for consistency
251- const color = '#2563eb' ; // Blue color matching relationship lines
250+ // Use exact same blue color as relationship lines from CSS (.relationship-line)
251+ const color = '#2563eb' ; // Must match CSS .relationship-line stroke color
252+ const strokeWidth = 8 ; // Must match CSS .relationship-line stroke-width
252253
253254 // Determine what notation to draw based on relationship type and side
254255 let notationType ;
@@ -286,52 +287,52 @@ function drawCrowsFootNotation(svg, x, y, direction, relationship, isFromSide) {
286287
287288 // Draw notation based on type
288289 if ( notationType . includes ( 'many' ) ) {
289- // Draw circle for optional relationships FIRST (positioned between table and crow's foot)
290+ // Draw circle for optional relationships FIRST (positioned with gap from crow's foot)
290291 if ( notationType . includes ( 'optional' ) ) {
291292 const circle = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'circle' ) ;
292293 circle . setAttribute ( 'cx' , CIRCLE_OFFSET ) ;
293294 circle . setAttribute ( 'cy' , '0' ) ;
294295 circle . setAttribute ( 'r' , CIRCLE_RADIUS ) ;
295296 circle . setAttribute ( 'stroke' , color ) ;
296- circle . setAttribute ( 'stroke-width' , '5' ) ;
297- circle . setAttribute ( 'fill' , 'none ' ) ; // FIXED: Transparent fill so circle is visible
297+ circle . setAttribute ( 'stroke-width' , strokeWidth ) ;
298+ circle . setAttribute ( 'fill' , 'white ' ) ; // White fill so circle is visible against any background
298299 group . appendChild ( circle ) ;
299- console . log ( `⭕ Drew optional circle for many side at cx=${ CIRCLE_OFFSET } ` ) ;
300+ console . log ( `⭕ Drew optional circle for many side at cx=${ CIRCLE_OFFSET } , r= ${ CIRCLE_RADIUS } ` ) ;
300301 }
301302
302303 // Draw crow's foot as a path with two segments forming a > shape
303304 // The path should point AWAY from the table (to the right in unrotated state)
304- // So: toe at x=0, legs extend to the right and up/down
305+ // Tip at x=CROW_SIZE (same distance as "one" side vertical line)
305306 const crowPath = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'path' ) ;
306307 const pathData = `M 0,${ - CROW_SIZE } L ${ CROW_SIZE } ,0 L 0,${ CROW_SIZE } ` ;
307308 crowPath . setAttribute ( 'd' , pathData ) ;
308309 crowPath . setAttribute ( 'stroke' , color ) ;
309- crowPath . setAttribute ( 'stroke-width' , '8' ) ;
310+ crowPath . setAttribute ( 'stroke-width' , strokeWidth ) ;
310311 crowPath . setAttribute ( 'fill' , 'none' ) ;
311312 crowPath . setAttribute ( 'stroke-linejoin' , 'miter' ) ;
312313 group . appendChild ( crowPath ) ;
313314 } else {
314- // Draw circle for optional relationships FIRST
315+ // Draw circle for optional relationships FIRST (positioned with gap from vertical line)
315316 if ( notationType . includes ( 'optional' ) ) {
316317 const circle = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'circle' ) ;
317- circle . setAttribute ( 'cx' , 0 ) ;
318+ circle . setAttribute ( 'cx' , CIRCLE_OFFSET ) ;
318319 circle . setAttribute ( 'cy' , '0' ) ;
319320 circle . setAttribute ( 'r' , CIRCLE_RADIUS ) ;
320321 circle . setAttribute ( 'stroke' , color ) ;
321- circle . setAttribute ( 'stroke-width' , '5' ) ;
322- circle . setAttribute ( 'fill' , 'none ' ) ; // FIXED: Transparent fill so circle is visible
322+ circle . setAttribute ( 'stroke-width' , strokeWidth ) ;
323+ circle . setAttribute ( 'fill' , 'white ' ) ; // White fill so circle is visible against any background
323324 group . appendChild ( circle ) ;
324- console . log ( `⭕ Drew optional circle for one side at cx=0 ` ) ;
325+ console . log ( `⭕ Drew optional circle for one side at cx=${ CIRCLE_OFFSET } , r= ${ CIRCLE_RADIUS } ` ) ;
325326 }
326327
327- // One side - vertical line with offset from table edge (drawn AFTER circle so it appears in front )
328+ // One side - vertical line at CROW_SIZE distance (same as crow's foot tip )
328329 const verticalLine = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'line' ) ;
329- verticalLine . setAttribute ( 'x1' , ONE_SIDE_OFFSET ) ;
330+ verticalLine . setAttribute ( 'x1' , CROW_SIZE ) ; // Same distance as crow's foot tip
330331 verticalLine . setAttribute ( 'y1' , - CROW_SIZE ) ;
331- verticalLine . setAttribute ( 'x2' , ONE_SIDE_OFFSET ) ;
332+ verticalLine . setAttribute ( 'x2' , CROW_SIZE ) ;
332333 verticalLine . setAttribute ( 'y2' , CROW_SIZE ) ;
333334 verticalLine . setAttribute ( 'stroke' , color ) ;
334- verticalLine . setAttribute ( 'stroke-width' , '8' ) ;
335+ verticalLine . setAttribute ( 'stroke-width' , strokeWidth ) ;
335336 group . appendChild ( verticalLine ) ;
336337 }
337338
@@ -524,8 +525,11 @@ function findPropertyConnectionPoint(tableGroup, propertyName, fallbackY) {
524525 for ( const propText of propertyTexts ) {
525526 if ( propText . textContent === propertyName ) {
526527 const y = parseFloat ( propText . getAttribute ( 'y' ) ) ;
527- console . log ( `🎯 Found property ${ propertyName } at y=${ y } ` ) ;
528- return y ;
528+ // FIXED: Adjust Y to be at the CENTER of the property text/icon, not the baseline
529+ // Property icons are rendered at y-12 (which is the center), so we need to match that
530+ const centerY = y - 12 ;
531+ console . log ( `🎯 Found property ${ propertyName } at y=${ y } , centerY=${ centerY } ` ) ;
532+ return centerY ;
529533 }
530534 }
531535
0 commit comments