File tree Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -672,16 +672,22 @@ <h2>Feasibility Rank Plot</h2>
672672 }
673673
674674 // -- 8) Collision‐avoidance for text labels
675- const usedLabelYs = [ ] ;
675+ const usedLabels = [ ] ; // Store (x, y) pairs
676676 function placeLabel ( px , py , text ) {
677- let labelY = py - 4 ;
678- while ( usedLabelYs . some ( y => Math . abs ( y - labelY ) < 10 ) ) {
679- labelY += 10 ;
677+ let labelY = py + 10 ; // Start slightly above the point
678+
679+ while ( usedLabels . some ( ( [ ux , uy ] ) =>
680+ Math . abs ( uy - labelY ) < 10 && Math . abs ( ux - px ) < 20 ) ) {
681+ // Check both y and x distances
682+
683+ labelY += 12 ;
680684 }
681- usedLabelYs . push ( labelY ) ;
682- ctx . fillText ( text , px + 6 , labelY ) ;
685+
686+ usedLabels . push ( [ px , labelY ] ) ; // Store both x and y
687+ ctx . fillText ( text , px + 4 , labelY ) ;
683688 }
684689
690+
685691 // -- 9) Plot each data point
686692 efficiencyData . forEach ( d => {
687693 // (a) Convert to pixel
Original file line number Diff line number Diff line change @@ -672,16 +672,22 @@ <h2>Feasibility Rank Plot</h2>
672672 }
673673
674674 // -- 8) Collision‐avoidance for text labels
675- const usedLabelYs = [ ] ;
675+ const usedLabels = [ ] ; // Store (x, y) pairs
676676 function placeLabel ( px , py , text ) {
677- let labelY = py - 4 ;
678- while ( usedLabelYs . some ( y => Math . abs ( y - labelY ) < 10 ) ) {
679- labelY += 10 ;
677+ let labelY = py + 10 ; // Start slightly above the point
678+
679+ while ( usedLabels . some ( ( [ ux , uy ] ) =>
680+ Math . abs ( uy - labelY ) < 10 && Math . abs ( ux - px ) < 20 ) ) {
681+ // Check both y and x distances
682+
683+ labelY += 12 ;
680684 }
681- usedLabelYs . push ( labelY ) ;
682- ctx . fillText ( text , px + 6 , labelY ) ;
685+
686+ usedLabels . push ( [ px , labelY ] ) ; // Store both x and y
687+ ctx . fillText ( text , px + 4 , labelY ) ;
683688 }
684689
690+
685691 // -- 9) Plot each data point
686692 efficiencyData . forEach ( d => {
687693 // (a) Convert to pixel
You can’t perform that action at this time.
0 commit comments