@@ -116,16 +116,22 @@ describe('Test treemap defaults:', function() {
116116 expect ( fullData [ 1 ] . marker . line . color ) . toBe ( '#fff' , 'dflt' ) ;
117117 } ) ;
118118
119- it ( 'should not coerce *marker.opacitybase* and *pathbar.opacity* when having *colorscale*' , function ( ) {
119+ it ( 'should default *marker.depthfade* depending on *marker.colors* is present or not' , function ( ) {
120+ _supply ( [
121+ { labels : [ 'A' , 'B' , 'a' ] , parents : [ '' , '' , 'A' ] } ,
122+ { labels : [ 'A' , 'B' , 'a' ] , parents : [ '' , '' , 'A' ] , marker : { colors : [ 'red' , 'green' , 'blue' ] } }
123+ ] ) ;
124+
125+ expect ( fullData [ 0 ] . marker . depthfade ) . toBe ( true ) ;
126+ expect ( fullData [ 1 ] . marker . depthfade ) . toBe ( false ) ;
127+ } ) ;
128+
129+ it ( 'should not coerce *marker.depthfade* when a *colorscale* is present' , function ( ) {
120130 _supply ( [
121- { labels : [ 1 ] , parents : [ '' ] } ,
122131 { labels : [ 1 ] , parents : [ '' ] , marker : { colorscale : 'Blues' } }
123132 ] ) ;
124133
125- expect ( fullData [ 0 ] . marker . opacitybase ) . toBe ( 0.5 ) ;
126- expect ( fullData [ 0 ] . pathbar . opacity ) . toBe ( 0.5 ) ;
127- expect ( fullData [ 1 ] . marker . opacitybase ) . toBe ( undefined , 'not coerced' ) ;
128- expect ( fullData [ 1 ] . pathbar . opacity ) . toBe ( undefined , 'not coerced' ) ;
134+ expect ( fullData [ 0 ] . marker . depthfade ) . toBe ( undefined ) ;
129135 } ) ;
130136
131137 it ( 'should use *textfont.size* to adjust top, bottom , left and right *marker.pad* defaults' , function ( ) {
@@ -263,15 +269,15 @@ describe('Test treemap defaults:', function() {
263269 expect ( fullData [ 0 ] . pathbar . thickness ) . toBe ( 30 ) ;
264270 } ) ;
265271
266- it ( 'should not default *marker.colorscale* when not having *marker.colors*' , function ( ) {
272+ it ( 'should not default *marker.colorscale* when *marker.colors* is not present ' , function ( ) {
267273 _supply ( [
268274 { labels : [ 1 ] , parents : [ '' ] }
269275 ] ) ;
270276
271277 expect ( fullData [ 0 ] . marker . colorscale ) . toBe ( undefined ) ;
272278 } ) ;
273279
274- it ( 'should default *marker.colorscale* to *Reds* when having *marker.colors*' , function ( ) {
280+ it ( 'should default *marker.colorscale* to *Reds* when *marker.colors* is present ' , function ( ) {
275281 _supply ( [
276282 { labels : [ 1 ] , parents : [ '' ] , marker : {
277283 colors : [ 0 ]
@@ -1190,50 +1196,6 @@ describe('Test treemap restyle:', function() {
11901196 . then ( done ) ;
11911197 } ) ;
11921198
1193- it ( 'should be able to restyle *marker.opacitybase*' , function ( done ) {
1194- var mock = {
1195- data : [ {
1196- type : 'treemap' , pathbar : { visible : false } ,
1197- labels : [ 'Root' , 'A' , 'B' , 'b' , 'b2' , 'b3' ] ,
1198- parents : [ '' , 'Root' , 'Root' , 'B' , 'b' , 'b2' ]
1199- } ]
1200- } ;
1201-
1202- function _assert ( msg , exp ) {
1203- return function ( ) {
1204- var layer = d3 . select ( gd ) . select ( '.treemaplayer' ) ;
1205-
1206- var opacities = [ ] ;
1207- layer . selectAll ( 'path.surface' ) . each ( function ( ) {
1208- opacities . push ( this . style . opacity ) ;
1209- } ) ;
1210-
1211- expect ( opacities ) . toEqual ( exp , msg ) ;
1212-
1213- // editType:style
1214- if ( msg !== 'base' ) {
1215- expect ( Plots . doCalcdata ) . toHaveBeenCalledTimes ( 0 ) ;
1216- expect ( gd . _fullData [ 0 ] . _module . plot ) . toHaveBeenCalledTimes ( 0 ) ;
1217- }
1218- } ;
1219- }
1220-
1221- Plotly . plot ( gd , mock )
1222- . then ( _assert ( 'base' , [ '1' , '1' , '0.5' , '0.5' , '1' , '1' ] ) )
1223- . then ( function ( ) {
1224- spyOn ( Plots , 'doCalcdata' ) . and . callThrough ( ) ;
1225- spyOn ( gd . _fullData [ 0 ] . _module , 'plot' ) . and . callThrough ( ) ;
1226- } )
1227- . then ( _restyle ( { 'marker.opacitybase' : 0.2 } ) )
1228- . then ( _assert ( 'lower marker.opacitybase' , [ '1' , '1' , '0.2' , '0.5' , '1' , '1' ] ) )
1229- . then ( _restyle ( { 'marker.opacitybase' : 0.8 } ) )
1230- . then ( _assert ( 'raise marker.opacitybase' , [ '1' , '1' , '0.8' , '0.1' , '0.2' , '1' ] ) )
1231- . then ( _restyle ( { 'marker.opacitybase' : null } ) )
1232- . then ( _assert ( 'back to dflt' , [ '1' , '1' , '0.5' , '0.1' , '0.2' , '1' ] ) )
1233- . catch ( failTest )
1234- . then ( done ) ;
1235- } ) ;
1236-
12371199 it ( 'should be able to restyle *pathbar.opacity*' , function ( done ) {
12381200 var mock = {
12391201 data : [ {
@@ -1264,17 +1226,17 @@ describe('Test treemap restyle:', function() {
12641226 }
12651227
12661228 Plotly . plot ( gd , mock )
1267- . then ( _assert ( 'base' , [ '0.5 ' , '0.5 ' , '1 ' , '0.5' , '0.5' ] ) )
1229+ . then ( _assert ( 'base' , [ '' , '' , '' , '0.5' , '0.5' ] ) )
12681230 . then ( function ( ) {
12691231 spyOn ( Plots , 'doCalcdata' ) . and . callThrough ( ) ;
12701232 spyOn ( gd . _fullData [ 0 ] . _module , 'plot' ) . and . callThrough ( ) ;
12711233 } )
12721234 . then ( _restyle ( { 'pathbar.opacity' : 0.2 } ) )
1273- . then ( _assert ( 'lower pathbar.opacity' , [ '0.5 ' , '0.5 ' , '1 ' , '0.2' , '0.2' ] ) )
1235+ . then ( _assert ( 'lower pathbar.opacity' , [ '' , '' , '' , '0.2' , '0.2' ] ) )
12741236 . then ( _restyle ( { 'pathbar.opacity' : 0.8 } ) )
1275- . then ( _assert ( 'raise pathbar.opacity' , [ '0.5 ' , '0.5 ' , '1 ' , '0.8' , '0.8' ] ) )
1237+ . then ( _assert ( 'raise pathbar.opacity' , [ '' , '' , '' , '0.8' , '0.8' ] ) )
12761238 . then ( _restyle ( { 'pathbar.opacity' : null } ) )
1277- . then ( _assert ( 'back to dflt' , [ '0.5 ' , '0.5 ' , '1 ' , '0.5' , '0.5' ] ) )
1239+ . then ( _assert ( 'back to dflt' , [ '' , '' , '' , '0.5' , '0.5' ] ) )
12781240 . catch ( failTest )
12791241 . then ( done ) ;
12801242 } ) ;
0 commit comments