3
3
var d3 = require ( '@plotly/d3' ) ;
4
4
var Registry = require ( '../registry' ) ;
5
5
var Plots = require ( '../plots/plots' ) ;
6
- var Loggers = require ( '../lib/loggers' ) ;
7
6
8
7
var Lib = require ( '../lib' ) ;
9
8
var svgTextUtils = require ( '../lib/svg_text_utils' ) ;
@@ -406,7 +405,6 @@ exports.drawMainTitle = function(gd) {
406
405
var y = getMainTitleY ( fullLayout , dy ) ;
407
406
var x = getMainTitleX ( fullLayout , textAnchor ) ;
408
407
409
- // Draw title without positioning to get size
410
408
Titles . draw ( gd , 'gtitle' , {
411
409
propContainer : fullLayout ,
412
410
propName : 'title.text' ,
@@ -424,13 +422,9 @@ exports.drawMainTitle = function(gd) {
424
422
var titleHeight = Drawing . bBox ( titleObj . node ( ) ) . height ;
425
423
var pushMargin = needsMarginPush ( gd , title , titleHeight ) ;
426
424
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 ) ;
431
425
applyTitleAutoMargin ( gd , y , pushMargin , titleHeight ) ;
432
426
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
434
428
titleObj . attr ( {
435
429
x : x ,
436
430
y : y ,
@@ -453,36 +447,6 @@ function isOutsideContainer(gd, title, position, y, titleHeight) {
453
447
}
454
448
}
455
449
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
-
486
450
function containerPushVal ( position , titleY , titleYanchor , height , titleDepth ) {
487
451
var push = 0 ;
488
452
if ( titleYanchor === 'middle' ) {
@@ -503,8 +467,8 @@ function containerPushVal(position, titleY, titleYanchor, height, titleDepth) {
503
467
}
504
468
505
469
function 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 ;
508
472
var position = titleY > 0.5 ? 't' : 'b' ;
509
473
var curMargin = gd . _fullLayout . margin [ position ] ;
510
474
var pushMargin = 0 ;
0 commit comments