@@ -370,13 +370,13 @@ function drawOne(gd, index, opt, value) {
370370 */
371371 if ( ax ) {
372372 /*
373- * hide the annotation if it's pointing
374- * outside the visible plot ( as long as the axis
375- * isn't autoranged - then we need to draw it
376- * anyway to get its bounding box)
373+ * hide the annotation if it's pointing outside the visible plot
374+ * as long as the axis isn't autoranged - then we need to draw it
375+ * anyway to get its bounding box. When we're dragging, an axis can
376+ * still look autoranged even though it won't be when the drag finishes.
377377 */
378378 var posFraction = ax . r2fraction ( options [ axLetter ] ) ;
379- if ( ! ax . autorange && ( posFraction < 0 || posFraction > 1 ) ) {
379+ if ( ( gd . _dragging || ! ax . autorange ) && ( posFraction < 0 || posFraction > 1 ) ) {
380380 if ( tailRef === axRef ) {
381381 posFraction = ax . r2fraction ( options [ 'a' + axLetter ] ) ;
382382 if ( posFraction < 0 || posFraction > 1 ) {
@@ -484,6 +484,15 @@ function drawOne(gd, index, opt, value) {
484484 Math . round ( annPosPx . x . text - outerwidth / 2 ) ,
485485 Math . round ( annPosPx . y . text - outerheight / 2 ) ) ;
486486
487+ /*
488+ * rotate text and background
489+ * we already calculated the text center position *as rotated*
490+ * because we needed that for autoranging anyway, so now whether
491+ * we have an arrow or not, we rotate about the text center.
492+ */
493+ annTextGroup . attr ( { transform : 'rotate(' + textangle + ',' +
494+ annPosPx . x . text + ',' + annPosPx . y . text + ')' } ) ;
495+
487496 var annbase = 'annotations[' + index + ']' ;
488497
489498 /*
@@ -742,10 +751,6 @@ function drawOne(gd, index, opt, value) {
742751 } ) ;
743752 }
744753 else annText . call ( textLayout ) ;
745-
746- // rotate and position text and background
747- annTextGroup . attr ( { transform : 'rotate(' + textangle + ',' +
748- annPosPx . x . text + ',' + annPosPx . y . text + ')' } ) ;
749754}
750755
751756// look for intersection of two line segments
0 commit comments