@@ -11,8 +11,7 @@ var createGraphDiv = require('../assets/create_graph_div');
11
11
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
12
12
13
13
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
14
- var color = require ( '../../../src/components/color' ) ;
15
- var rgb = color . rgb ;
14
+ var Color = require ( '../../../src/components/color' ) ;
16
15
17
16
var customAssertions = require ( '../assets/custom_assertions' ) ;
18
17
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
@@ -259,7 +258,7 @@ describe('Waterfall.supplyDefaults', function() {
259
258
y : [ 1 , 2 , 3 ] ,
260
259
} ;
261
260
supplyDefaults ( traceIn , traceOut , defaultColor , { } ) ;
262
- expect ( traceOut . connector . line . color ) . toBe ( color . defaultLine ) ;
261
+ expect ( traceOut . connector . line . color ) . toBe ( Color . defaultLine ) ;
263
262
} ) ;
264
263
} ) ;
265
264
@@ -668,7 +667,7 @@ describe('A waterfall plot', function() {
668
667
expect ( textNode . style . fontSize ) . toBe ( expectedFontProps . size [ index ] + 'px' ) ;
669
668
670
669
var actualColorRGB = textNode . style . fill ;
671
- var expectedColorRGB = rgb ( expectedFontProps . color [ index ] ) ;
670
+ var expectedColorRGB = Color . rgb ( expectedFontProps . color [ index ] ) ;
672
671
expect ( actualColorRGB ) . toBe ( expectedColorRGB ) ;
673
672
}
674
673
@@ -688,7 +687,7 @@ describe('A waterfall plot', function() {
688
687
var expFontColor = expFontColors [ i ] ;
689
688
var isArray = Array . isArray ( expFontColor ) ;
690
689
691
- expect ( this . style . fill ) . toBe ( isArray ? rgb ( expFontColor [ 0 ] ) : rgb ( expFontColor ) ,
690
+ expect ( this . style . fill ) . toBe ( Color . rgb ( isArray ? expFontColor [ 0 ] : expFontColor ) ,
692
691
( label || '' ) + ', fill for element ' + i ) ;
693
692
expect ( this . style . fillOpacity ) . toBe ( isArray ? expFontColor [ 1 ] : '1' ,
694
693
( label || '' ) + ', fillOpacity for element ' + i ) ;
@@ -1067,9 +1066,6 @@ describe('A waterfall plot', function() {
1067
1066
font : { family : 'arial' , color : 'blue' , size : 13 }
1068
1067
} ;
1069
1068
1070
- // Note: insidetextfont.color does NOT inherit from textfont.color
1071
- // since insidetextfont.color should be contrasting to bar's fill by default.
1072
- var contrastingLightColorVal = color . contrast ( 'black' ) ;
1073
1069
var expected = {
1074
1070
y : [ 10 , 20 , 30 , 40 ] ,
1075
1071
type : 'waterfall' ,
@@ -1082,7 +1078,8 @@ describe('A waterfall plot', function() {
1082
1078
} ,
1083
1079
insidetextfont : {
1084
1080
family : [ '"comic sans"' , 'arial' , 'arial' ] ,
1085
- color : [ 'black' , 'green' , contrastingLightColorVal ] ,
1081
+ // NOTE: 'color' does NOT inherit from 'textfont.color' since 'color' should be contrasting to bar's fill by default.
1082
+ color : [ 'black' , 'green' , Color . contrast ( 'white' ) ] ,
1086
1083
size : [ 8 , 12 , 16 ]
1087
1084
} ,
1088
1085
outsidetextfont : {
@@ -1187,7 +1184,7 @@ describe('A waterfall plot', function() {
1187
1184
text : [ 'A' , 'B' , 'C' ] ,
1188
1185
textposition : 'inside'
1189
1186
} ] )
1190
- . then ( assertTextFontColors ( [ 'rgb(255, 255, 255 )' , 'rgb(255, 255, 255 )' , 'rgb(255, 255, 255 )' ] ) )
1187
+ . then ( assertTextFontColors ( [ 'rgb(68, 68, 68 )' , 'rgb(68, 68, 68 )' , 'rgb(68, 68, 68 )' ] ) )
1191
1188
. then ( function ( ) {
1192
1189
gd . data [ 0 ] . insidetextfont = { color : 'red' } ;
1193
1190
return Plotly . react ( gd , gd . data ) ;
0 commit comments