@@ -187,7 +187,6 @@ describe('Pie traces:', function() {
187
187
Plotly . newPlot ( gd , [ {
188
188
values : [ 2 , 2 , 2 , 2 ] ,
189
189
title : 'Test<br>Title' ,
190
- titleposition : 'middle center' ,
191
190
hole : 0.5 ,
192
191
type : 'pie' ,
193
192
textinfo : 'none'
@@ -243,22 +242,24 @@ describe('Pie traces:', function() {
243
242
} ) ;
244
243
245
244
function _verifyTitle ( checkLeft , checkRight , checkTop , checkBottom , checkMiddleX ) {
246
- var title = d3 . selectAll ( '.titletext text' ) ;
247
- expect ( title . size ( ) ) . toBe ( 1 ) ;
248
- var titleBox = d3 . select ( 'g.titletext' ) . node ( ) . getBoundingClientRect ( ) ;
249
- var pieBox = d3 . select ( 'g.trace' ) . node ( ) . getBoundingClientRect ( ) ;
250
- // check that margins agree. we leave an error margin of 2.
251
- if ( checkLeft ) expect ( Math . abs ( titleBox . left - pieBox . left ) ) . toBeLessThan ( 2 ) ;
252
- if ( checkRight ) expect ( Math . abs ( titleBox . right - pieBox . right ) ) . toBeLessThan ( 2 ) ;
253
- if ( checkTop ) expect ( Math . abs ( titleBox . top - pieBox . top ) ) . toBeLessThan ( 2 ) ;
254
- if ( checkBottom ) expect ( Math . abs ( titleBox . bottom - pieBox . bottom ) ) . toBeLessThan ( 2 ) ;
255
- if ( checkMiddleX ) {
256
- expect ( Math . abs ( titleBox . left + titleBox . right - pieBox . left - pieBox . right ) )
257
- . toBeLessThan ( 2 ) ;
258
- }
245
+ return function ( ) {
246
+ var title = d3 . selectAll ( '.titletext text' ) ;
247
+ expect ( title . size ( ) ) . toBe ( 1 ) ;
248
+ var titleBox = d3 . select ( 'g.titletext' ) . node ( ) . getBoundingClientRect ( ) ;
249
+ var pieBox = d3 . select ( 'g.trace' ) . node ( ) . getBoundingClientRect ( ) ;
250
+ // check that margins agree. we leave an error margin of 2.
251
+ if ( checkLeft ) expect ( Math . abs ( titleBox . left - pieBox . left ) ) . toBeLessThan ( 2 ) ;
252
+ if ( checkRight ) expect ( Math . abs ( titleBox . right - pieBox . right ) ) . toBeLessThan ( 2 ) ;
253
+ if ( checkTop ) expect ( Math . abs ( titleBox . top - pieBox . top ) ) . toBeLessThan ( 2 ) ;
254
+ if ( checkBottom ) expect ( Math . abs ( titleBox . bottom - pieBox . bottom ) ) . toBeLessThan ( 2 ) ;
255
+ if ( checkMiddleX ) {
256
+ expect ( Math . abs ( titleBox . left + titleBox . right - pieBox . left - pieBox . right ) )
257
+ . toBeLessThan ( 2 ) ;
258
+ }
259
+ } ;
259
260
}
260
261
261
- it ( 'shows title top center if there is no hole ' , function ( done ) {
262
+ it ( 'shows title top center if hole is zero ' , function ( done ) {
262
263
Plotly . newPlot ( gd , [ {
263
264
values : [ 2 , 2 , 2 , 2 ] ,
264
265
title : 'Test<BR>Title' ,
@@ -275,6 +276,21 @@ describe('Pie traces:', function() {
275
276
. then ( done ) ;
276
277
} ) ;
277
278
279
+ it ( 'shows title top center if titleposition is undefined and no hole' , function ( done ) {
280
+ Plotly . newPlot ( gd , [ {
281
+ values : [ 2 , 2 , 2 , 2 ] ,
282
+ title : 'Test<BR>Title' ,
283
+ titlefont : {
284
+ size : 12
285
+ } ,
286
+ type : 'pie' ,
287
+ textinfo : 'none'
288
+ } ] , { height : 300 , width : 300 } )
289
+ . then ( _verifyTitle ( false , false , true , false , true ) )
290
+ . catch ( failTest )
291
+ . then ( done ) ;
292
+ } ) ;
293
+
278
294
it ( 'shows title top center' , function ( done ) {
279
295
Plotly . newPlot ( gd , [ {
280
296
values : [ 1 , 1 , 1 , 1 , 2 ] ,
0 commit comments