File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,17 +179,8 @@ function editUnits() {
179179 const bbox = legend . node ( ) . getBBox ( ) ;
180180 legendLabel . attr ( "x" , bbox . width / 2 ) ;
181181
182- // Adjust legend position to ensure it's fully visible
183- const legendBox = legend . select ( "#legendBox" ) ;
184- const legendWidth = + legendBox . attr ( "width" ) ;
185- const legendHeight = + legendBox . attr ( "height" ) ;
186- const svgWidth = + d3 . select ( "svg" ) . attr ( "width" ) ;
187- const svgHeight = + d3 . select ( "svg" ) . attr ( "height" ) ;
188-
189- const x = Math . max ( 10 , Math . min ( svgWidth - legendWidth - 10 , ( + legend . attr ( "data-x" ) / 100 ) * svgWidth ) ) ;
190- const y = Math . max ( 10 , Math . min ( svgHeight - legendHeight - 10 , ( + legend . attr ( "data-y" ) / 100 ) * svgHeight ) ) ;
191-
192- legend . attr ( "transform" , `translate(${ x } ,${ y } )` ) ;
182+ // Use shared legend positioning logic (defaults near bottom-right when data-x/y are unset)
183+ if ( window . fitLegendBox ) fitLegendBox ( ) ;
193184 }
194185
195186 function updateLegendIfVisible ( ) {
You can’t perform that action at this time.
0 commit comments