@@ -9,8 +9,7 @@ var click = require('../assets/click');
9
9
var getClientPosition = require ( '../assets/get_client_position' ) ;
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
11
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
12
- var color = require ( '../../../src/components/color' ) ;
13
- var rgb = color . rgb ;
12
+ var rgb = require ( '../../../src/components/color' ) . rgb ;
14
13
15
14
var customAssertions = require ( '../assets/custom_assertions' ) ;
16
15
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
@@ -77,8 +76,8 @@ describe('Pie defaults', function() {
77
76
describe ( 'Pie traces' , function ( ) {
78
77
'use strict' ;
79
78
80
- var DARK = color . rgb ( '#444' ) ;
81
- var LIGHT = color . rgb ( '#fff' ) ;
79
+ var DARK = '#444' ;
80
+ var LIGHT = '#fff' ;
82
81
83
82
var gd ;
84
83
@@ -168,7 +167,7 @@ describe('Pie traces', function() {
168
167
function _checkFontColors ( expFontColors ) {
169
168
return function ( ) {
170
169
d3 . selectAll ( SLICES_TEXT_SELECTOR ) . each ( function ( d , i ) {
171
- expect ( this . style . fill ) . toBe ( expFontColors [ i ] , 'fill color of ' + i ) ;
170
+ expect ( this . style . fill ) . toBe ( rgb ( expFontColors [ i ] ) , 'fill color of ' + i ) ;
172
171
} ) ;
173
172
} ;
174
173
}
@@ -527,15 +526,15 @@ describe('Pie traces', function() {
527
526
} ;
528
527
529
528
Plotly . plot ( gd , [ data ] )
530
- . then ( _checkFontColors ( [ rgb ( 'red' ) , rgb ( 'green' ) , rgb ( 'blue' ) ] ) )
529
+ . then ( _checkFontColors ( [ 'red' , 'green' , 'blue' ] ) )
531
530
. then ( _checkFontFamilies ( [ 'Arial' , 'Gravitas' , 'Roboto' ] ) )
532
531
. then ( _checkFontSizes ( [ 12 , 20 , 16 ] ) )
533
532
. catch ( failTest )
534
533
. then ( done ) ;
535
534
} ) ;
536
535
} ) ;
537
536
538
- var insideTextTestsTraceDef = {
537
+ var insideTextTestsTrace = {
539
538
values : [ 6 , 5 , 4 , 3 , 2 , 1 ] ,
540
539
type : 'pie' ,
541
540
marker : {
@@ -544,39 +543,39 @@ describe('Pie traces', function() {
544
543
} ;
545
544
546
545
it ( 'should use inside text colors contrasting to slice colors by default' , function ( done ) {
547
- Plotly . plot ( gd , [ insideTextTestsTraceDef ] )
546
+ Plotly . plot ( gd , [ insideTextTestsTrace ] )
548
547
. then ( _checkFontColors ( [ DARK , DARK , LIGHT , LIGHT , DARK , LIGHT ] ) )
549
548
. catch ( failTest )
550
549
. then ( done ) ;
551
550
} ) ;
552
551
553
552
it ( 'should use textfont.color for inside text instead of the contrasting default' , function ( done ) {
554
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , { textfont : { color : 'red' } } ) ;
553
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , { textfont : { color : 'red' } } ) ;
555
554
Plotly . plot ( gd , [ data ] )
556
- . then ( _checkFontColors ( Lib . repeat ( rgb ( 'red' ) , 6 ) ) )
555
+ . then ( _checkFontColors ( Lib . repeat ( 'red' , 6 ) ) )
557
556
. catch ( failTest )
558
557
. then ( done ) ;
559
558
} ) ;
560
559
561
560
it ( 'should use matching color from textfont.color array for inside text, contrasting otherwise' , function ( done ) {
562
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , { textfont : { color : [ 'red' , 'blue' ] } } ) ;
561
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , { textfont : { color : [ 'red' , 'blue' ] } } ) ;
563
562
Plotly . plot ( gd , [ data ] )
564
- . then ( _checkFontColors ( [ rgb ( 'red' ) , rgb ( 'blue' ) , LIGHT , LIGHT , DARK , LIGHT ] ) )
563
+ . then ( _checkFontColors ( [ 'red' , 'blue' , LIGHT , LIGHT , DARK , LIGHT ] ) )
565
564
. catch ( failTest )
566
565
. then ( done ) ;
567
566
} ) ;
568
567
569
568
it ( 'should not use layout.font.color for inside text, but a contrasting color instead' , function ( done ) {
570
- Plotly . plot ( gd , [ insideTextTestsTraceDef ] , { font : { color : 'green' } } )
569
+ Plotly . plot ( gd , [ insideTextTestsTrace ] , { font : { color : 'green' } } )
571
570
. then ( _checkFontColors ( [ DARK , DARK , LIGHT , LIGHT , DARK , LIGHT ] ) )
572
571
. catch ( failTest )
573
572
. then ( done ) ;
574
573
} ) ;
575
574
576
575
it ( 'should use matching color from insidetextfont.color array instead of the contrasting default' , function ( done ) {
577
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , { textfont : { color : [ 'orange' , 'purple' ] } } ) ;
576
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , { textfont : { color : [ 'orange' , 'purple' ] } } ) ;
578
577
Plotly . plot ( gd , [ data ] )
579
- . then ( _checkFontColors ( [ rgb ( 'orange' ) , rgb ( 'purple' ) , LIGHT , LIGHT , DARK , LIGHT ] ) )
578
+ . then ( _checkFontColors ( [ 'orange' , 'purple' , LIGHT , LIGHT , DARK , LIGHT ] ) )
580
579
. catch ( failTest )
581
580
. then ( done ) ;
582
581
} ) ;
@@ -587,15 +586,14 @@ describe('Pie traces', function() {
587
586
] . forEach ( function ( spec ) {
588
587
it ( 'should fall back to textfont scalar values if ' + spec . fontAttr + ' value ' +
589
588
'arrays don\'t cover all slices' , function ( done ) {
590
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , {
589
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , {
591
590
textposition : spec . textposition ,
592
591
textfont : { color : 'orange' , family : 'Gravitas' , size : 12 }
593
592
} ) ;
594
593
data [ spec . fontAttr ] = { color : [ 'blue' , 'yellow' ] , family : [ 'Arial' , 'Arial' ] , size : [ 24 , 34 ] } ;
595
594
596
- var orange = rgb ( 'orange' ) ;
597
595
Plotly . plot ( gd , [ data ] )
598
- . then ( _checkFontColors ( [ rgb ( 'blue' ) , rgb ( 'yellow' ) , orange , orange , orange , orange ] ) )
596
+ . then ( _checkFontColors ( [ 'blue' , 'yellow' , ' orange' , ' orange' , ' orange' , ' orange' ] ) )
599
597
. then ( _checkFontFamilies ( [ 'Arial' , 'Arial' , 'Gravitas' , 'Gravitas' , 'Gravitas' , 'Gravitas' ] ) )
600
598
. then ( _checkFontSizes ( [ 24 , 34 , 12 , 12 , 12 , 12 ] ) )
601
599
. catch ( failTest )
@@ -606,7 +604,7 @@ describe('Pie traces', function() {
606
604
it ( 'should fall back to textfont array values and layout.font scalar (except color)' +
607
605
' values for inside text' , function ( done ) {
608
606
var layout = { font : { color : 'orange' , family : 'serif' , size : 16 } } ;
609
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , {
607
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , {
610
608
textfont : {
611
609
color : [ 'blue' , 'blue' ] , family : [ 'Arial' , 'Arial' ] , size : [ 18 , 18 ]
612
610
} ,
@@ -616,7 +614,7 @@ describe('Pie traces', function() {
616
614
} ) ;
617
615
618
616
Plotly . plot ( gd , [ data ] , layout )
619
- . then ( _checkFontColors ( [ rgb ( 'purple' ) , rgb ( 'blue' ) , LIGHT , LIGHT , DARK , LIGHT ] ) )
617
+ . then ( _checkFontColors ( [ 'purple' , 'blue' , LIGHT , LIGHT , DARK , LIGHT ] ) )
620
618
. then ( _checkFontFamilies ( [ 'Roboto' , 'Arial' , 'serif' , 'serif' , 'serif' , 'serif' ] ) )
621
619
. then ( _checkFontSizes ( [ 24 , 18 , 16 , 16 , 16 , 16 ] ) )
622
620
. catch ( failTest )
@@ -626,7 +624,7 @@ describe('Pie traces', function() {
626
624
it ( 'should fall back to textfont array values and layout.font scalar' +
627
625
' values for outside text' , function ( done ) {
628
626
var layout = { font : { color : 'orange' , family : 'serif' , size : 16 } } ;
629
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef , {
627
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace , {
630
628
textposition : 'outside' ,
631
629
textfont : {
632
630
color : [ 'blue' , 'blue' ] , family : [ 'Arial' , 'Arial' ] , size : [ 18 , 18 ]
@@ -636,9 +634,8 @@ describe('Pie traces', function() {
636
634
}
637
635
} ) ;
638
636
639
- var orange = rgb ( 'orange' ) ;
640
637
Plotly . plot ( gd , [ data ] , layout )
641
- . then ( _checkFontColors ( [ rgb ( 'purple' ) , rgb ( 'blue' ) , orange , orange , orange , orange ] ) )
638
+ . then ( _checkFontColors ( [ 'purple' , 'blue' , ' orange' , ' orange' , ' orange' , ' orange' ] ) )
642
639
. then ( _checkFontFamilies ( [ 'Roboto' , 'Arial' , 'serif' , 'serif' , 'serif' , 'serif' ] ) )
643
640
. then ( _checkFontSizes ( [ 24 , 18 , 16 , 16 , 16 , 16 ] ) )
644
641
. catch ( failTest )
@@ -652,12 +649,12 @@ describe('Pie traces', function() {
652
649
it ( 'should fall back to layout.font scalar values for inside text (except color) if ' + spec . fontAttr + ' value ' +
653
650
'arrays don\'t cover all slices' , function ( done ) {
654
651
var layout = { font : { color : 'orange' , family : 'serif' , size : 16 } } ;
655
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef ) ;
652
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace ) ;
656
653
data . textposition = 'inside' ;
657
654
data [ spec . fontAttr ] = { color : [ 'blue' , 'yellow' ] , family : [ 'Arial' , 'Arial' ] , size : [ 24 , 34 ] } ;
658
655
659
656
Plotly . plot ( gd , [ data ] , layout )
660
- . then ( _checkFontColors ( [ rgb ( 'blue' ) , rgb ( 'yellow' ) , LIGHT , LIGHT , DARK , LIGHT ] ) )
657
+ . then ( _checkFontColors ( [ 'blue' , 'yellow' , LIGHT , LIGHT , DARK , LIGHT ] ) )
661
658
. then ( _checkFontFamilies ( [ 'Arial' , 'Arial' , 'serif' , 'serif' , 'serif' , 'serif' ] ) )
662
659
. then ( _checkFontSizes ( [ 24 , 34 , 16 , 16 , 16 , 16 ] ) )
663
660
. catch ( failTest )
@@ -672,13 +669,12 @@ describe('Pie traces', function() {
672
669
it ( 'should fall back to layout.font scalar values for outside text if ' + spec . fontAttr + ' value ' +
673
670
'arrays don\'t cover all slices' , function ( done ) {
674
671
var layout = { font : { color : 'orange' , family : 'serif' , size : 16 } } ;
675
- var data = Lib . extendFlat ( { } , insideTextTestsTraceDef ) ;
672
+ var data = Lib . extendFlat ( { } , insideTextTestsTrace ) ;
676
673
data . textposition = 'outside' ;
677
674
data [ spec . fontAttr ] = { color : [ 'blue' , 'yellow' ] , family : [ 'Arial' , 'Arial' ] , size : [ 24 , 34 ] } ;
678
675
679
- var orange = rgb ( 'orange' ) ;
680
676
Plotly . plot ( gd , [ data ] , layout )
681
- . then ( _checkFontColors ( [ rgb ( 'blue' ) , rgb ( 'yellow' ) , orange , orange , orange , orange ] ) )
677
+ . then ( _checkFontColors ( [ 'blue' , 'yellow' , ' orange' , ' orange' , ' orange' , ' orange' ] ) )
682
678
. then ( _checkFontFamilies ( [ 'Arial' , 'Arial' , 'serif' , 'serif' , 'serif' , 'serif' ] ) )
683
679
. then ( _checkFontSizes ( [ 24 , 34 , 16 , 16 , 16 , 16 ] ) )
684
680
. catch ( failTest )
0 commit comments