@@ -51,6 +51,8 @@ var numStripRE = / [XY][0-9]* /;
5151 * offset - shift up/down in the rotated frame (unused?)
5252 * containerGroup - if an svg <g> element already exists to hold this
5353 * title, include here. Otherwise it will go in fullLayout._infolayer
54+ *
55+ * @return {selection } d3 selection of title container group
5456 */
5557Titles . draw = function ( gd , titleClass , options ) {
5658 var cont = options . propContainer ;
@@ -63,13 +65,14 @@ Titles.draw = function(gd, titleClass, options) {
6365 var group = options . containerGroup ;
6466
6567 var fullLayout = gd . _fullLayout ;
66- var font = cont . titlefont . family ;
67- var fontSize = cont . titlefont . size ;
68- var fontColor = cont . titlefont . color ;
68+ var titlefont = cont . titlefont || { } ;
69+ var font = titlefont . family ;
70+ var fontSize = titlefont . size ;
71+ var fontColor = titlefont . color ;
6972
7073 var opacity = 1 ;
7174 var isplaceholder = false ;
72- var txt = cont . title . trim ( ) ;
75+ var txt = ( cont . title || '' ) . trim ( ) ;
7376
7477 // only make this title editable if we positively identify its property
7578 // as one that has editing enabled.
@@ -111,17 +114,28 @@ Titles.draw = function(gd, titleClass, options) {
111114 . attr ( 'class' , titleClass ) ;
112115 el . exit ( ) . remove ( ) ;
113116
114- if ( ! elShouldExist ) return ;
117+ if ( ! elShouldExist ) return group ;
115118
116119 function titleLayout ( titleEl ) {
117120 Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
118121 }
119122
120123 function drawTitle ( titleEl ) {
121- titleEl . attr ( 'transform' , transform ?
122- 'rotate(' + [ transform . rotate , attributes . x , attributes . y ] +
123- ') translate(0, ' + transform . offset + ')' :
124- null ) ;
124+ var transformVal ;
125+
126+ if ( transform ) {
127+ transformVal = '' ;
128+ if ( transform . rotate ) {
129+ transformVal += 'rotate(' + [ transform . rotate , attributes . x , attributes . y ] + ')' ;
130+ }
131+ if ( transform . offset ) {
132+ transformVal += 'translate(0, ' + transform . offset + ')' ;
133+ }
134+ } else {
135+ transformVal = null ;
136+ }
137+
138+ titleEl . attr ( 'transform' , transformVal ) ;
125139
126140 titleEl . style ( {
127141 'font-family' : font ,
@@ -236,4 +250,6 @@ Titles.draw = function(gd, titleClass, options) {
236250 } ) ;
237251 }
238252 el . classed ( 'js-placeholder' , isplaceholder ) ;
253+
254+ return group ;
239255} ;
0 commit comments