@@ -16,6 +16,8 @@ var customAssertions = require('../assets/custom_assertions');
1616var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
1717var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
1818var checkTextTemplate = require ( '../assets/check_texttemplate' ) ;
19+ const { position } = require ( '../../../src/plots/cartesian/layout_attributes' ) ;
20+ const { font } = require ( '../../../src/plots/layout_attributes' ) ;
1921
2022var SLICES_SELECTOR = '.slice path' ;
2123var SLICES_TEXT_SELECTOR = '.pielayer text.slicetext' ;
@@ -329,11 +331,7 @@ describe('Pie traces', function() {
329331 it ( 'scales multiline title to fit in hole' , function ( done ) {
330332 Plotly . newPlot ( gd , [ {
331333 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 } } ,
337335 hole : 0.1 ,
338336 type : 'pie' ,
339337 textinfo : 'none'
@@ -379,11 +377,7 @@ describe('Pie traces', function() {
379377 it ( 'shows title top center if hole is zero' , function ( done ) {
380378 Plotly . newPlot ( gd , [ {
381379 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 } } ,
387381 hole : 0 ,
388382 type : 'pie' ,
389383 textinfo : 'none'
@@ -392,13 +386,10 @@ describe('Pie traces', function() {
392386 . then ( done , done . fail ) ;
393387 } ) ;
394388
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 ) {
396390 Plotly . newPlot ( gd , [ {
397391 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 } } ,
402393 type : 'pie' ,
403394 textinfo : 'none'
404395 } ] , { height : 300 , width : 300 } )
@@ -409,11 +400,7 @@ describe('Pie traces', function() {
409400 it ( 'shows title top center' , function ( done ) {
410401 Plotly . newPlot ( gd , [ {
411402 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 } } ,
417404 type : 'pie' ,
418405 textinfo : 'none'
419406 } ] , { height : 300 , width : 300 } )
@@ -424,11 +411,7 @@ describe('Pie traces', function() {
424411 it ( 'shows title top left' , function ( done ) {
425412 Plotly . newPlot ( gd , [ {
426413 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 } } ,
432415 type : 'pie' ,
433416 textinfo : 'none'
434417 } ] , { height : 300 , width : 300 } )
@@ -439,11 +422,7 @@ describe('Pie traces', function() {
439422 it ( 'shows title top right' , function ( done ) {
440423 Plotly . newPlot ( gd , [ {
441424 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 } } ,
447426 type : 'pie' ,
448427 textinfo : 'none'
449428 } ] , { height : 300 , width : 300 } )
@@ -454,11 +433,7 @@ describe('Pie traces', function() {
454433 it ( 'shows title bottom left' , function ( done ) {
455434 Plotly . newPlot ( gd , [ {
456435 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 } } ,
462437 type : 'pie' ,
463438 textinfo : 'none'
464439 } ] , { height : 300 , width : 300 } )
@@ -469,11 +444,7 @@ describe('Pie traces', function() {
469444 it ( 'shows title bottom center' , function ( done ) {
470445 Plotly . newPlot ( gd , [ {
471446 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 } } ,
477448 type : 'pie' ,
478449 textinfo : 'none'
479450 } ] , { height : 300 , width : 300 } )
@@ -484,11 +455,7 @@ describe('Pie traces', function() {
484455 it ( 'shows title bottom right' , function ( done ) {
485456 Plotly . newPlot ( gd , [ {
486457 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 } } ,
492459 type : 'pie' ,
493460 textinfo : 'none'
494461 } ] , { height : 300 , width : 300 } )
@@ -499,34 +466,26 @@ describe('Pie traces', function() {
499466 it ( 'should be able to restyle title position' , function ( done ) {
500467 Plotly . newPlot ( gd , [ {
501468 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 } } ,
507470 type : 'pie' ,
508471 textinfo : 'none'
509472 } ] , { height : 300 , width : 300 } )
510473 . 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' ) ; } )
512475 . 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' ) ; } )
514477 . 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' ) ; } )
516479 . 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' ) ; } )
518481 . then ( _verifyTitle ( false , true , false , true , false ) )
519482 . then ( done , done . fail ) ;
520483 } ) ;
521484
522485 it ( 'does not intersect pulled slices' , function ( done ) {
523486 Plotly . newPlot ( gd , [ {
524487 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 } } ,
530489 pull : [ 0.9 , 0.9 , 0.9 , 0.9 ] ,
531490 type : 'pie' ,
532491 textinfo : 'none'
@@ -548,11 +507,7 @@ describe('Pie traces', function() {
548507 it ( 'correctly positions large title' , function ( done ) {
549508 Plotly . newPlot ( gd , [ {
550509 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 } } ,
556511 type : 'pie' ,
557512 textinfo : 'none'
558513 } ] , { height : 300 , width : 300 } )
@@ -795,9 +750,7 @@ describe('Pie traces', function() {
795750 Plotly . newPlot ( gd , [ {
796751 type : 'pie' ,
797752 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' }
801754 } ] )
802755 . then ( function ( ) {
803756 _assertTitle ( 'base' , 'yo' , 'rgb(0, 0, 255)' ) ;
@@ -837,18 +790,16 @@ describe('Pie traces', function() {
837790 Plotly . newPlot ( gd , [ {
838791 type : 'pie' ,
839792 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' }
843794 } ] )
844795 . then ( function ( ) {
845796 _assertTitle ( 'base' , 'yo' , 'rgb(0, 0, 255)' ) ;
846797 _verifyTitle ( true , false , true , false , false ) ;
847798
848799 return Plotly . restyle ( gd , {
849800 title : { text : 'oy' } ,
850- 'titlefont .color' : 'red' ,
851- titleposition : 'bottom right'
801+ 'title.font .color' : 'red' ,
802+ 'title.position' : 'bottom right'
852803 } ) ;
853804 } )
854805 . then ( function ( ) {
0 commit comments