@@ -51,6 +51,8 @@ var numStripRE = / [XY][0-9]* /;
51
51
* offset - shift up/down in the rotated frame (unused?)
52
52
* containerGroup - if an svg <g> element already exists to hold this
53
53
* title, include here. Otherwise it will go in fullLayout._infolayer
54
+ *
55
+ * @return {selection } d3 selection of title container group
54
56
*/
55
57
Titles . draw = function ( gd , titleClass , options ) {
56
58
var cont = options . propContainer ;
@@ -63,13 +65,14 @@ Titles.draw = function(gd, titleClass, options) {
63
65
var group = options . containerGroup ;
64
66
65
67
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 ;
69
72
70
73
var opacity = 1 ;
71
74
var isplaceholder = false ;
72
- var txt = cont . title . trim ( ) ;
75
+ var txt = ( cont . title || '' ) . trim ( ) ;
73
76
74
77
// only make this title editable if we positively identify its property
75
78
// as one that has editing enabled.
@@ -111,17 +114,28 @@ Titles.draw = function(gd, titleClass, options) {
111
114
. attr ( 'class' , titleClass ) ;
112
115
el . exit ( ) . remove ( ) ;
113
116
114
- if ( ! elShouldExist ) return ;
117
+ if ( ! elShouldExist ) return group ;
115
118
116
119
function titleLayout ( titleEl ) {
117
120
Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
118
121
}
119
122
120
123
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 ) ;
125
139
126
140
titleEl . style ( {
127
141
'font-family' : font ,
@@ -236,4 +250,6 @@ Titles.draw = function(gd, titleClass, options) {
236
250
} ) ;
237
251
}
238
252
el . classed ( 'js-placeholder' , isplaceholder ) ;
253
+
254
+ return group ;
239
255
} ;
0 commit comments