@@ -11,8 +11,7 @@ var createGraphDiv = require('../assets/create_graph_div');
1111var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
1212
1313var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
14- var color = require ( '../../../src/components/color' ) ;
15- var rgb = color . rgb ;
14+ var Color = require ( '../../../src/components/color' ) ;
1615
1716var customAssertions = require ( '../assets/custom_assertions' ) ;
1817var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
@@ -259,7 +258,7 @@ describe('Waterfall.supplyDefaults', function() {
259258 y : [ 1 , 2 , 3 ] ,
260259 } ;
261260 supplyDefaults ( traceIn , traceOut , defaultColor , { } ) ;
262- expect ( traceOut . connector . line . color ) . toBe ( color . defaultLine ) ;
261+ expect ( traceOut . connector . line . color ) . toBe ( Color . defaultLine ) ;
263262 } ) ;
264263} ) ;
265264
@@ -668,7 +667,7 @@ describe('A waterfall plot', function() {
668667 expect ( textNode . style . fontSize ) . toBe ( expectedFontProps . size [ index ] + 'px' ) ;
669668
670669 var actualColorRGB = textNode . style . fill ;
671- var expectedColorRGB = rgb ( expectedFontProps . color [ index ] ) ;
670+ var expectedColorRGB = Color . rgb ( expectedFontProps . color [ index ] ) ;
672671 expect ( actualColorRGB ) . toBe ( expectedColorRGB ) ;
673672 }
674673
@@ -688,7 +687,7 @@ describe('A waterfall plot', function() {
688687 var expFontColor = expFontColors [ i ] ;
689688 var isArray = Array . isArray ( expFontColor ) ;
690689
691- expect ( this . style . fill ) . toBe ( isArray ? rgb ( expFontColor [ 0 ] ) : rgb ( expFontColor ) ,
690+ expect ( this . style . fill ) . toBe ( Color . rgb ( isArray ? expFontColor [ 0 ] : expFontColor ) ,
692691 ( label || '' ) + ', fill for element ' + i ) ;
693692 expect ( this . style . fillOpacity ) . toBe ( isArray ? expFontColor [ 1 ] : '1' ,
694693 ( label || '' ) + ', fillOpacity for element ' + i ) ;
@@ -1067,9 +1066,6 @@ describe('A waterfall plot', function() {
10671066 font : { family : 'arial' , color : 'blue' , size : 13 }
10681067 } ;
10691068
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' ) ;
10731069 var expected = {
10741070 y : [ 10 , 20 , 30 , 40 ] ,
10751071 type : 'waterfall' ,
@@ -1082,7 +1078,8 @@ describe('A waterfall plot', function() {
10821078 } ,
10831079 insidetextfont : {
10841080 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' ) ] ,
10861083 size : [ 8 , 12 , 16 ]
10871084 } ,
10881085 outsidetextfont : {
@@ -1187,7 +1184,7 @@ describe('A waterfall plot', function() {
11871184 text : [ 'A' , 'B' , 'C' ] ,
11881185 textposition : 'inside'
11891186 } ] )
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 )' ] ) )
11911188 . then ( function ( ) {
11921189 gd . data [ 0 ] . insidetextfont = { color : 'red' } ;
11931190 return Plotly . react ( gd , gd . data ) ;
0 commit comments