@@ -16,6 +16,8 @@ var customAssertions = require('../assets/custom_assertions');
16
16
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
17
17
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
18
18
var checkTextTemplate = require ( '../assets/check_texttemplate' ) ;
19
+ const { position } = require ( '../../../src/plots/cartesian/layout_attributes' ) ;
20
+ const { font } = require ( '../../../src/plots/layout_attributes' ) ;
19
21
20
22
var SLICES_SELECTOR = '.slice path' ;
21
23
var SLICES_TEXT_SELECTOR = '.pielayer text.slicetext' ;
@@ -329,11 +331,7 @@ describe('Pie traces', function() {
329
331
it ( 'scales multiline title to fit in hole' , function ( done ) {
330
332
Plotly . newPlot ( gd , [ {
331
333
values : [ 2 , 2 , 2 , 2 ] ,
332
- title : { text : 'Test<BR>Title' } ,
333
- titleposition : 'middle center' ,
334
- titlefont : {
335
- size : 60
336
- } ,
334
+ title : { text : 'Test<BR>Title' , position : 'middle center' , font : { size : 60 } } ,
337
335
hole : 0.1 ,
338
336
type : 'pie' ,
339
337
textinfo : 'none'
@@ -379,11 +377,7 @@ describe('Pie traces', function() {
379
377
it ( 'shows title top center if hole is zero' , function ( done ) {
380
378
Plotly . newPlot ( gd , [ {
381
379
values : [ 2 , 2 , 2 , 2 ] ,
382
- title : { text : 'Test<BR>Title' } ,
383
- titleposition : 'middle center' ,
384
- titlefont : {
385
- size : 12
386
- } ,
380
+ title : { text : 'Test<BR>Title' , position : 'middle center' , font : { size : 12 } } ,
387
381
hole : 0 ,
388
382
type : 'pie' ,
389
383
textinfo : 'none'
@@ -392,13 +386,10 @@ describe('Pie traces', function() {
392
386
. then ( done , done . fail ) ;
393
387
} ) ;
394
388
395
- it ( 'shows title top center if titleposition is undefined and no hole' , function ( done ) {
389
+ it ( 'shows title top center if title.position is undefined and no hole' , function ( done ) {
396
390
Plotly . newPlot ( gd , [ {
397
391
values : [ 2 , 2 , 2 , 2 ] ,
398
- title : { text : 'Test<BR>Title' } ,
399
- titlefont : {
400
- size : 12
401
- } ,
392
+ title : { text : 'Test<BR>Title' , font : { size : 12 } } ,
402
393
type : 'pie' ,
403
394
textinfo : 'none'
404
395
} ] , { height : 300 , width : 300 } )
@@ -409,11 +400,7 @@ describe('Pie traces', function() {
409
400
it ( 'shows title top center' , function ( done ) {
410
401
Plotly . newPlot ( gd , [ {
411
402
values : [ 1 , 1 , 1 , 1 , 2 ] ,
412
- title : { text : 'Test<BR>Title' } ,
413
- titleposition : 'top center' ,
414
- titlefont : {
415
- size : 12
416
- } ,
403
+ title : { text : 'Test<BR>Title' , position : 'top center' , font : { size : 12 } } ,
417
404
type : 'pie' ,
418
405
textinfo : 'none'
419
406
} ] , { height : 300 , width : 300 } )
@@ -424,11 +411,7 @@ describe('Pie traces', function() {
424
411
it ( 'shows title top left' , function ( done ) {
425
412
Plotly . newPlot ( gd , [ {
426
413
values : [ 3 , 2 , 1 ] ,
427
- title : { text : 'Test<BR>Title' } ,
428
- titleposition : 'top left' ,
429
- titlefont : {
430
- size : 12
431
- } ,
414
+ title : { text : 'Test<BR>Title' , position : 'top left' , font : { size : 12 } } ,
432
415
type : 'pie' ,
433
416
textinfo : 'none'
434
417
} ] , { height : 300 , width : 300 } )
@@ -439,11 +422,7 @@ describe('Pie traces', function() {
439
422
it ( 'shows title top right' , function ( done ) {
440
423
Plotly . newPlot ( gd , [ {
441
424
values : [ 4 , 5 , 6 , 5 ] ,
442
- title : { text : 'Test<BR>Title' } ,
443
- titleposition : 'top right' ,
444
- titlefont : {
445
- size : 12
446
- } ,
425
+ title : { text : 'Test<BR>Title' , position : 'top right' , font : { size : 12 } } ,
447
426
type : 'pie' ,
448
427
textinfo : 'none'
449
428
} ] , { height : 300 , width : 300 } )
@@ -454,11 +433,7 @@ describe('Pie traces', function() {
454
433
it ( 'shows title bottom left' , function ( done ) {
455
434
Plotly . newPlot ( gd , [ {
456
435
values : [ 4 , 5 , 6 , 5 ] ,
457
- title : { text : 'Test<BR>Title' } ,
458
- titleposition : 'bottom left' ,
459
- titlefont : {
460
- size : 12
461
- } ,
436
+ title : { text : 'Test<BR>Title' , position : 'bottom left' , font : { size : 12 } } ,
462
437
type : 'pie' ,
463
438
textinfo : 'none'
464
439
} ] , { height : 300 , width : 300 } )
@@ -469,11 +444,7 @@ describe('Pie traces', function() {
469
444
it ( 'shows title bottom center' , function ( done ) {
470
445
Plotly . newPlot ( gd , [ {
471
446
values : [ 4 , 5 , 6 , 5 ] ,
472
- title : { text : 'Test<BR>Title' } ,
473
- titleposition : 'bottom center' ,
474
- titlefont : {
475
- size : 12
476
- } ,
447
+ title : { text : 'Test<BR>Title' , position : 'bottom center' , font : { size : 12 } } ,
477
448
type : 'pie' ,
478
449
textinfo : 'none'
479
450
} ] , { height : 300 , width : 300 } )
@@ -484,11 +455,7 @@ describe('Pie traces', function() {
484
455
it ( 'shows title bottom right' , function ( done ) {
485
456
Plotly . newPlot ( gd , [ {
486
457
values : [ 4 , 5 , 6 , 5 ] ,
487
- title : { text : 'Test<BR>Title' } ,
488
- titleposition : 'bottom right' ,
489
- titlefont : {
490
- size : 12
491
- } ,
458
+ title : { text : 'Test<BR>Title' , position : 'bottom right' , font : { size : 12 } } ,
492
459
type : 'pie' ,
493
460
textinfo : 'none'
494
461
} ] , { height : 300 , width : 300 } )
@@ -499,34 +466,26 @@ describe('Pie traces', function() {
499
466
it ( 'should be able to restyle title position' , function ( done ) {
500
467
Plotly . newPlot ( gd , [ {
501
468
values : [ 3 , 2 , 1 ] ,
502
- title : { text : 'Test<BR>Title' } ,
503
- titleposition : 'top left' ,
504
- titlefont : {
505
- size : 12
506
- } ,
469
+ title : { text : 'Test<BR>Title' , position : 'top left' , font : { size : 12 } } ,
507
470
type : 'pie' ,
508
471
textinfo : 'none'
509
472
} ] , { height : 300 , width : 300 } )
510
473
. then ( _verifyTitle ( true , false , true , false , false ) )
511
- . then ( function ( ) { return Plotly . restyle ( gd , 'titleposition ' , 'top right' ) ; } )
474
+ . then ( function ( ) { return Plotly . restyle ( gd , 'title.position ' , 'top right' ) ; } )
512
475
. then ( _verifyTitle ( false , true , true , false , false ) )
513
- . then ( function ( ) { return Plotly . restyle ( gd , 'titleposition ' , 'bottom left' ) ; } )
476
+ . then ( function ( ) { return Plotly . restyle ( gd , 'title.position ' , 'bottom left' ) ; } )
514
477
. then ( _verifyTitle ( true , false , false , true , false ) )
515
- . then ( function ( ) { return Plotly . restyle ( gd , 'titleposition ' , 'bottom center' ) ; } )
478
+ . then ( function ( ) { return Plotly . restyle ( gd , 'title.position ' , 'bottom center' ) ; } )
516
479
. then ( _verifyTitle ( false , false , false , true , true ) )
517
- . then ( function ( ) { return Plotly . restyle ( gd , 'titleposition ' , 'bottom right' ) ; } )
480
+ . then ( function ( ) { return Plotly . restyle ( gd , 'title.position ' , 'bottom right' ) ; } )
518
481
. then ( _verifyTitle ( false , true , false , true , false ) )
519
482
. then ( done , done . fail ) ;
520
483
} ) ;
521
484
522
485
it ( 'does not intersect pulled slices' , function ( done ) {
523
486
Plotly . newPlot ( gd , [ {
524
487
values : [ 2 , 2 , 2 , 2 ] ,
525
- title : { text : 'Test<BR>Title' } ,
526
- titleposition : 'top center' ,
527
- titlefont : {
528
- size : 14
529
- } ,
488
+ title : { text : 'Test<BR>Title' , position : 'top center' , font : { size : 14 } } ,
530
489
pull : [ 0.9 , 0.9 , 0.9 , 0.9 ] ,
531
490
type : 'pie' ,
532
491
textinfo : 'none'
@@ -548,11 +507,7 @@ describe('Pie traces', function() {
548
507
it ( 'correctly positions large title' , function ( done ) {
549
508
Plotly . newPlot ( gd , [ {
550
509
values : [ 1 , 3 , 4 , 1 , 2 ] ,
551
- title : { text : 'Test<BR>Title' } ,
552
- titleposition : 'top center' ,
553
- titlefont : {
554
- size : 60
555
- } ,
510
+ title : { text : 'Test<BR>Title' , position : 'top center' , font : { size : 60 } } ,
556
511
type : 'pie' ,
557
512
textinfo : 'none'
558
513
} ] , { height : 300 , width : 300 } )
@@ -795,9 +750,7 @@ describe('Pie traces', function() {
795
750
Plotly . newPlot ( gd , [ {
796
751
type : 'pie' ,
797
752
values : [ 1 , 2 , 3 ] ,
798
- title : { text : 'yo' } ,
799
- titlefont : { color : 'blue' } ,
800
- titleposition : 'top left'
753
+ title : { text : 'yo' , font : { color : 'blue' } , position : 'top left' }
801
754
} ] )
802
755
. then ( function ( ) {
803
756
_assertTitle ( 'base' , 'yo' , 'rgb(0, 0, 255)' ) ;
@@ -837,18 +790,16 @@ describe('Pie traces', function() {
837
790
Plotly . newPlot ( gd , [ {
838
791
type : 'pie' ,
839
792
values : [ 1 , 2 , 3 ] ,
840
- title : { text : 'yo' } ,
841
- titlefont : { color : 'blue' } ,
842
- titleposition : 'top left'
793
+ title : { text : 'yo' , font : { color : 'blue' } , position : 'top left' }
843
794
} ] )
844
795
. then ( function ( ) {
845
796
_assertTitle ( 'base' , 'yo' , 'rgb(0, 0, 255)' ) ;
846
797
_verifyTitle ( true , false , true , false , false ) ;
847
798
848
799
return Plotly . restyle ( gd , {
849
800
title : { text : 'oy' } ,
850
- 'titlefont .color' : 'red' ,
851
- titleposition : 'bottom right'
801
+ 'title.font .color' : 'red' ,
802
+ 'title.position' : 'bottom right'
852
803
} ) ;
853
804
} )
854
805
. then ( function ( ) {
0 commit comments