File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -610,15 +610,15 @@ drawing.makeTester = function() {
610610// in a reference frame where it isn't translated and its anchor
611611// point is at (0,0)
612612// always returns a copy of the bbox, so the caller can modify it safely
613- var savedBBoxes = { } ;
613+ drawing . savedBBoxes = { } ;
614614var savedBBoxesCount = 0 ;
615615var maxSavedBBoxes = 10000 ;
616616
617617drawing . bBox = function ( node ) {
618618 // cache elements we've already measured so we don't have to
619619 // remeasure the same thing many times
620620 var hash = nodeHash ( node ) ;
621- var out = savedBBoxes [ hash ] ;
621+ var out = drawing . savedBBoxes [ hash ] ;
622622 if ( out ) return Lib . extendFlat ( { } , out ) ;
623623
624624 var tester = drawing . tester . node ( ) ;
@@ -654,12 +654,12 @@ drawing.bBox = function(node) {
654654 // or a long session could overload on memory
655655 // by saving boxes for long-gone elements
656656 if ( savedBBoxesCount >= maxSavedBBoxes ) {
657- savedBBoxes = { } ;
657+ drawing . savedBBoxes = { } ;
658658 maxSavedBBoxes = 0 ;
659659 }
660660
661661 // cache this bbox
662- savedBBoxes [ hash ] = bb ;
662+ drawing . savedBBoxes [ hash ] = bb ;
663663 savedBBoxesCount ++ ;
664664
665665 return Lib . extendFlat ( { } , bb ) ;
Original file line number Diff line number Diff line change @@ -1045,6 +1045,17 @@ describe('A bar plot', function() {
10451045 assertTextIsInsidePath ( text20 , path20 ) ; // inside
10461046 assertTextIsBelowPath ( text30 , path30 ) ; // outside
10471047
1048+ // clear bounding box cache - somehow when you cache
1049+ // text size too early sometimes it changes later...
1050+ // we've had this issue before, where we've had to
1051+ // redraw annotations to get final sizes, I wish we
1052+ // could get some signal that fonts are really ready
1053+ // and not start drawing until then (or invalidate
1054+ // the bbox cache when that happens?)
1055+ // without this change, we get an error at
1056+ // assertTextIsInsidePath(text30, path30);
1057+ Drawing . savedBBoxes = { } ;
1058+
10481059 return Plotly . restyle ( gd , 'textposition' , 'inside' ) ;
10491060 } ) . then ( function ( ) {
10501061 var cd = gd . calcdata ;
You can’t perform that action at this time.
0 commit comments