33var d3 = require ( '@plotly/d3' ) ;
44var Registry = require ( '../registry' ) ;
55var Plots = require ( '../plots/plots' ) ;
6- var Loggers = require ( '../lib/loggers' ) ;
76
87var Lib = require ( '../lib' ) ;
98var svgTextUtils = require ( '../lib/svg_text_utils' ) ;
@@ -406,7 +405,6 @@ exports.drawMainTitle = function(gd) {
406405 var y = getMainTitleY ( fullLayout , dy ) ;
407406 var x = getMainTitleX ( fullLayout , textAnchor ) ;
408407
409- // Draw title without positioning to get size
410408 Titles . draw ( gd , 'gtitle' , {
411409 propContainer : fullLayout ,
412410 propName : 'title.text' ,
@@ -424,13 +422,9 @@ exports.drawMainTitle = function(gd) {
424422 var titleHeight = Drawing . bBox ( titleObj . node ( ) ) . height ;
425423 var pushMargin = needsMarginPush ( gd , title , titleHeight ) ;
426424 if ( pushMargin > 0 ) {
427- setDflts ( title , getDflts ( title ) [ 0 ] , getDflts ( title ) [ 1 ] ) ;
428- // Recalculate these since the defaults have changed
429- dy = getMainTitleDy ( fullLayout ) ;
430- y = getMainTitleY ( fullLayout , dy ) ;
431425 applyTitleAutoMargin ( gd , y , pushMargin , titleHeight ) ;
432426
433- // Position the title once we know where it needs to be
427+ // Re-position the title once we know where it needs to be
434428 titleObj . attr ( {
435429 x : x ,
436430 y : y ,
@@ -453,36 +447,6 @@ function isOutsideContainer(gd, title, position, y, titleHeight) {
453447 }
454448}
455449
456-
457- // title.y is 1 or 0 if automargin and paper ref
458- // 'auto' is not supported for either title.y or title.yanchor when automargin=true
459- function getDflts ( title ) {
460- var titleY = title . y ;
461- var titleYanchor = title . yanchor ;
462- if ( title . automargin && title . yref === 'paper' ) {
463- titleY = title . y === 0 ? 0 : 1 ;
464- if ( title . yanchor === 'auto' ) {
465- titleYanchor = title . y === 0 ? 'top' : 'bottom' ;
466- }
467- }
468- if ( title . automargin && title . yref === 'container' ) {
469- if ( title . y === 'auto' ) titleY = 1 ;
470- if ( title . yanchor === 'auto' ) {
471- titleYanchor = title . y < 0.5 ? 'bottom' : 'top' ;
472- }
473- }
474- return [ titleY , titleYanchor ] ;
475- }
476-
477- function setDflts ( title , titleY , titleYanchor ) {
478- if ( title . yref === 'paper' && title . y !== 0 && title . y !== 1 && title . y !== 'auto' ) {
479- Loggers . warn ( 'title.automargin=true so resetting the supplied title.y value to 1.' ) ;
480- }
481- title . y = titleY ;
482- title . yanchor = titleYanchor ;
483- }
484-
485-
486450function containerPushVal ( position , titleY , titleYanchor , height , titleDepth ) {
487451 var push = 0 ;
488452 if ( titleYanchor === 'middle' ) {
@@ -503,8 +467,8 @@ function containerPushVal(position, titleY, titleYanchor, height, titleDepth) {
503467}
504468
505469function needsMarginPush ( gd , title , titleHeight ) {
506- var titleY = getDflts ( title ) [ 0 ] ;
507- var titleYanchor = getDflts ( title ) [ 1 ] ;
470+ var titleY = title . y ;
471+ var titleYanchor = title . yanchor ;
508472 var position = titleY > 0.5 ? 't' : 'b' ;
509473 var curMargin = gd . _fullLayout . margin [ position ] ;
510474 var pushMargin = 0 ;
0 commit comments