@@ -116,16 +116,22 @@ describe('Test treemap defaults:', function() {
116
116
expect ( fullData [ 1 ] . marker . line . color ) . toBe ( '#fff' , 'dflt' ) ;
117
117
} ) ;
118
118
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 ( ) {
120
130
_supply ( [
121
- { labels : [ 1 ] , parents : [ '' ] } ,
122
131
{ labels : [ 1 ] , parents : [ '' ] , marker : { colorscale : 'Blues' } }
123
132
] ) ;
124
133
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 ) ;
129
135
} ) ;
130
136
131
137
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() {
263
269
expect ( fullData [ 0 ] . pathbar . thickness ) . toBe ( 30 ) ;
264
270
} ) ;
265
271
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 ( ) {
267
273
_supply ( [
268
274
{ labels : [ 1 ] , parents : [ '' ] }
269
275
] ) ;
270
276
271
277
expect ( fullData [ 0 ] . marker . colorscale ) . toBe ( undefined ) ;
272
278
} ) ;
273
279
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 ( ) {
275
281
_supply ( [
276
282
{ labels : [ 1 ] , parents : [ '' ] , marker : {
277
283
colors : [ 0 ]
@@ -1190,50 +1196,6 @@ describe('Test treemap restyle:', function() {
1190
1196
. then ( done ) ;
1191
1197
} ) ;
1192
1198
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
-
1237
1199
it ( 'should be able to restyle *pathbar.opacity*' , function ( done ) {
1238
1200
var mock = {
1239
1201
data : [ {
@@ -1264,17 +1226,17 @@ describe('Test treemap restyle:', function() {
1264
1226
}
1265
1227
1266
1228
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' ] ) )
1268
1230
. then ( function ( ) {
1269
1231
spyOn ( Plots , 'doCalcdata' ) . and . callThrough ( ) ;
1270
1232
spyOn ( gd . _fullData [ 0 ] . _module , 'plot' ) . and . callThrough ( ) ;
1271
1233
} )
1272
1234
. 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' ] ) )
1274
1236
. 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' ] ) )
1276
1238
. 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' ] ) )
1278
1240
. catch ( failTest )
1279
1241
. then ( done ) ;
1280
1242
} ) ;
0 commit comments