@@ -183,15 +183,7 @@ module.exports = function draw(gd, id) {
183183 tickprefix : opts . tickprefix ,
184184 showticksuffix : opts . showticksuffix ,
185185 ticksuffix : opts . ticksuffix ,
186-
187- // Plot and axes titles have a different, nested attribute structure
188- // for defining title attributes. Since the `titles` component
189- // assumes that nested structure, let's adapt to it without breaking
190- // the existing colorbar API.
191- title : {
192- text : opts . title ,
193- font : opts . titlefont
194- } ,
186+ title : opts . title ,
195187 showline : true ,
196188 anchor : 'free' ,
197189 side : 'right' ,
@@ -225,11 +217,11 @@ module.exports = function draw(gd, id) {
225217 // save for other callers to access this axis
226218 component . axis = cbAxisOut ;
227219
228- if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
229- cbAxisOut . titleside = opts . titleside ;
220+ if ( [ 'top' , 'bottom' ] . indexOf ( opts . title . side ) !== - 1 ) {
221+ cbAxisOut . title . side = opts . title . side ;
230222 cbAxisOut . titlex = opts . x + xpadFrac ;
231223 cbAxisOut . titley = yBottomFrac +
232- ( opts . titleside === 'top' ? lenFrac - ypadFrac : ypadFrac ) ;
224+ ( opts . title . side === 'top' ? lenFrac - ypadFrac : ypadFrac ) ;
233225 }
234226
235227 if ( opts . line . color && opts . tickmode === 'auto' ) {
@@ -292,15 +284,15 @@ module.exports = function draw(gd, id) {
292284 var axisLayer = container . select ( '.cbaxis' ) ;
293285
294286 var titleHeight = 0 ;
295- if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
287+ if ( [ 'top' , 'bottom' ] . indexOf ( opts . title . side ) !== - 1 ) {
296288 // draw the title so we know how much room it needs
297289 // when we squish the axis. This one only applies to
298290 // top or bottom titles, not right side.
299291 var x = gs . l + ( opts . x + xpadFrac ) * gs . w ,
300292 fontSize = cbAxisOut . title . font . size ,
301293 y ;
302294
303- if ( opts . titleside === 'top' ) {
295+ if ( opts . title . side === 'top' ) {
304296 y = ( 1 - ( yBottomFrac + lenFrac - ypadFrac ) ) * gs . h +
305297 gs . t + 3 + fontSize * 0.75 ;
306298 }
@@ -314,7 +306,7 @@ module.exports = function draw(gd, id) {
314306 }
315307
316308 function drawAxis ( ) {
317- if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
309+ if ( [ 'top' , 'bottom' ] . indexOf ( opts . title . side ) !== - 1 ) {
318310 // squish the axis top to make room for the title
319311 var titleGroup = container . select ( '.cbtitle' ) ,
320312 titleText = titleGroup . select ( 'text' ) ,
@@ -345,7 +337,7 @@ module.exports = function draw(gd, id) {
345337 // TODO: configurable
346338 titleHeight += 5 ;
347339
348- if ( opts . titleside === 'top' ) {
340+ if ( opts . title . side === 'top' ) {
349341 cbAxisOut . domain [ 1 ] -= titleHeight / gs . h ;
350342 titleTrans [ 1 ] *= - 1 ;
351343 }
@@ -466,7 +458,7 @@ module.exports = function draw(gd, id) {
466458 } ) ;
467459 } ,
468460 function ( ) {
469- if ( [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) === - 1 ) {
461+ if ( [ 'top' , 'bottom' ] . indexOf ( opts . title . side ) === - 1 ) {
470462 var fontSize = cbAxisOut . title . font . size ,
471463 y = cbAxisOut . _offset + cbAxisOut . _length / 2 ,
472464 x = gs . l + ( cbAxisOut . position || 0 ) * gs . w + ( ( cbAxisOut . side === 'right' ) ?
@@ -479,7 +471,7 @@ module.exports = function draw(gd, id) {
479471 drawTitle ( 'h' + cbAxisOut . _id + 'title' , {
480472 avoid : {
481473 selection : d3 . select ( gd ) . selectAll ( 'g.' + cbAxisOut . _id + 'tick' ) ,
482- side : opts . titleside ,
474+ side : opts . title . side ,
483475 offsetLeft : gs . l ,
484476 offsetTop : 0 ,
485477 maxShift : fullLayout . width
@@ -532,11 +524,11 @@ module.exports = function draw(gd, id) {
532524 . node ( ) ,
533525 titleWidth ;
534526 if ( mathJaxNode &&
535- [ 'top' , 'bottom' ] . indexOf ( opts . titleside ) !== - 1 ) {
527+ [ 'top' , 'bottom' ] . indexOf ( opts . title . side ) !== - 1 ) {
536528 titleWidth = Drawing . bBox ( mathJaxNode ) . width ;
537529 }
538530 else {
539- // note: the formula below works for all titlesides ,
531+ // note: the formula below works for all title sides ,
540532 // (except for top/bottom mathjax, above)
541533 // but the weird gs.l is because the titleunshift
542534 // transform gets removed by Drawing.bBox
@@ -565,7 +557,7 @@ module.exports = function draw(gd, id) {
565557 container . selectAll ( '.cboutline' ) . attr ( {
566558 x : xLeft ,
567559 y : yTopPx + opts . ypad +
568- ( opts . titleside === 'top' ? titleHeight : 0 ) ,
560+ ( opts . title . side === 'top' ? titleHeight : 0 ) ,
569561 width : Math . max ( thickPx , 2 ) ,
570562 height : Math . max ( outerheight - 2 * opts . ypad - titleHeight , 2 )
571563 } )
0 commit comments