@@ -7396,14 +7396,49 @@ describe('hovermode: (x|y)unified', function () {
73967396 } ) ;
73977397
73987398 it ( 'should align item text with hoverlabel.align' , ( done ) => {
7399+ // DEBUG: remove before merge
7400+ let debugStep = 0 ;
73997401 const getItems = ( ) => {
74007402 const items = [ ] ;
74017403 getHoverLabel ( )
74027404 . selectAll ( 'g.traces text.legendtext' )
74037405 . each ( function ( ) {
74047406 const bBox = this . getBoundingClientRect ( ) ;
74057407 items . push ( { anchor : this . getAttribute ( 'text-anchor' ) , left : bBox . left , right : bBox . right } ) ;
7408+
7409+ // DEBUG: compare the cached width that sized the box with fresh measurements
7410+ const savedBBoxes = Drawing . savedBBoxes ;
7411+ Drawing . savedBBoxes = { } ;
7412+ const freshWidth = Drawing . bBox ( this ) . width ;
7413+ Drawing . savedBBoxes = savedBBoxes ;
7414+ const style = window . getComputedStyle ( this ) ;
7415+ console . log (
7416+ '[DEBUG 8104]' ,
7417+ JSON . stringify ( {
7418+ step : debugStep ,
7419+ text : this . textContent ,
7420+ anchor : this . getAttribute ( 'text-anchor' ) ,
7421+ x : this . getAttribute ( 'x' ) ,
7422+ cachedWidth : this . parentNode . __data__ [ 0 ] . width ,
7423+ freshWidth,
7424+ renderedWidth : bBox . width ,
7425+ textLength : this . getComputedTextLength ( ) ,
7426+ left : bBox . left ,
7427+ right : bBox . right ,
7428+ font : style . fontFamily + ' ' + style . fontSize
7429+ } )
7430+ ) ;
74067431 } ) ;
7432+ const bg = getHoverLabel ( ) . select ( 'rect.bg' ) . node ( ) ;
7433+ console . log (
7434+ '[DEBUG 8104]' ,
7435+ JSON . stringify ( {
7436+ step : debugStep ++ ,
7437+ boxWidth : bg && bg . getAttribute ( 'width' ) ,
7438+ userAgent : navigator . userAgent ,
7439+ fonts : [ ...document . fonts ] . map ( ( f ) => f . family + ' ' + f . weight + ' ' + f . status )
7440+ } )
7441+ ) ;
74077442 return items ;
74087443 } ;
74097444
0 commit comments