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() {
610
610
// in a reference frame where it isn't translated and its anchor
611
611
// point is at (0,0)
612
612
// always returns a copy of the bbox, so the caller can modify it safely
613
- var savedBBoxes = { } ;
613
+ drawing . savedBBoxes = { } ;
614
614
var savedBBoxesCount = 0 ;
615
615
var maxSavedBBoxes = 10000 ;
616
616
617
617
drawing . bBox = function ( node ) {
618
618
// cache elements we've already measured so we don't have to
619
619
// remeasure the same thing many times
620
620
var hash = nodeHash ( node ) ;
621
- var out = savedBBoxes [ hash ] ;
621
+ var out = drawing . savedBBoxes [ hash ] ;
622
622
if ( out ) return Lib . extendFlat ( { } , out ) ;
623
623
624
624
var tester = drawing . tester . node ( ) ;
@@ -654,12 +654,12 @@ drawing.bBox = function(node) {
654
654
// or a long session could overload on memory
655
655
// by saving boxes for long-gone elements
656
656
if ( savedBBoxesCount >= maxSavedBBoxes ) {
657
- savedBBoxes = { } ;
657
+ drawing . savedBBoxes = { } ;
658
658
maxSavedBBoxes = 0 ;
659
659
}
660
660
661
661
// cache this bbox
662
- savedBBoxes [ hash ] = bb ;
662
+ drawing . savedBBoxes [ hash ] = bb ;
663
663
savedBBoxesCount ++ ;
664
664
665
665
return Lib . extendFlat ( { } , bb ) ;
Original file line number Diff line number Diff line change @@ -1045,6 +1045,17 @@ describe('A bar plot', function() {
1045
1045
assertTextIsInsidePath ( text20 , path20 ) ; // inside
1046
1046
assertTextIsBelowPath ( text30 , path30 ) ; // outside
1047
1047
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
+
1048
1059
return Plotly . restyle ( gd , 'textposition' , 'inside' ) ;
1049
1060
} ) . then ( function ( ) {
1050
1061
var cd = gd . calcdata ;
You can’t perform that action at this time.
0 commit comments