@@ -1266,28 +1266,52 @@ describe('Test plot api', function() {
1266
1266
. then ( done ) ;
1267
1267
} ) ;
1268
1268
1269
- it ( 'sets x/ytype scaled when editing heatmap x0/dx/y0/dy' , function ( done ) {
1270
- var x0 = 3 ;
1271
- var dy = 5 ;
1272
-
1273
- function check ( scaled , msg ) {
1274
- expect ( gd . data [ 0 ] . x0 ) . negateIf ( ! scaled ) . toBe ( x0 , msg ) ;
1275
- expect ( gd . data [ 0 ] . xtype ) . toBe ( scaled ? 'scaled' : undefined , msg ) ;
1276
- expect ( gd . data [ 0 ] . dy ) . negateIf ( ! scaled ) . toBe ( dy , msg ) ;
1277
- expect ( gd . data [ 0 ] . ytype ) . toBe ( scaled ? 'scaled' : undefined , msg ) ;
1278
- }
1269
+ function checkScaling ( xyType , xyTypeIn , iIn , iOut ) {
1270
+ expect ( gd . _fullData [ iOut ] . xtype ) . toBe ( xyType ) ;
1271
+ expect ( gd . _fullData [ iOut ] . ytype ) . toBe ( xyType ) ;
1272
+ expect ( gd . data [ iIn ] . xtype ) . toBe ( xyTypeIn ) ;
1273
+ expect ( gd . data [ iIn ] . ytype ) . toBe ( xyTypeIn ) ;
1274
+ }
1279
1275
1280
- Plotly . plot ( gd , [ { x : [ 1 , 2 , 4 ] , y : [ 2 , 3 , 5 ] , z : [ [ 1 , 2 ] , [ 3 , 4 ] ] , type : 'heatmap' } ] )
1276
+ it ( 'sets heatmap xtype/ytype when you edit x/y data or scaling params' , function ( done ) {
1277
+ Plotly . plot ( gd , [ { type : 'heatmap' , z : [ [ 0 , 1 ] , [ 2 , 3 ] ] } ] )
1281
1278
. then ( function ( ) {
1282
- check ( false , 'initial' ) ;
1283
- return Plotly . restyle ( gd , { x0 : x0 , dy : dy } ) ;
1279
+ // TODO would probably be better to actively default to 'array' here...
1280
+ checkScaling ( undefined , undefined , 0 , 0 ) ;
1281
+ return Plotly . restyle ( gd , { x : [ [ 2 , 4 ] ] , y : [ [ 3 , 5 ] ] } , [ 0 ] ) ;
1284
1282
} )
1285
1283
. then ( function ( ) {
1286
- check ( true , 'set x0 & dy' ) ;
1287
- return Queue . undo ( gd ) ;
1284
+ checkScaling ( 'array' , 'array' , 0 , 0 ) ;
1285
+ return Plotly . restyle ( gd , { x0 : 1 , dy : 3 } , [ 0 ] ) ;
1288
1286
} )
1289
1287
. then ( function ( ) {
1290
- check ( false , 'undo' ) ;
1288
+ checkScaling ( 'scaled' , 'scaled' , 0 , 0 ) ;
1289
+ } )
1290
+ . catch ( failTest )
1291
+ . then ( done ) ;
1292
+ } ) ;
1293
+
1294
+ it ( 'sets heatmap xtype/ytype even when data/fullData indices mismatch' , function ( done ) {
1295
+ Plotly . plot ( gd , [
1296
+ {
1297
+ // importantly, this is NOT a heatmap trace, so _fullData[1]
1298
+ // will not have the same attributes as data[1]
1299
+ x : [ 1 , - 1 , - 2 , 0 ] ,
1300
+ y : [ 1 , 2 , 3 , 1 ] ,
1301
+ transforms : [ { type : 'groupby' , groups : [ 'a' , 'b' , 'a' , 'b' ] } ]
1302
+ } ,
1303
+ { type : 'heatmap' , z : [ [ 0 , 1 ] , [ 2 , 3 ] ] }
1304
+ ] )
1305
+ . then ( function ( ) {
1306
+ checkScaling ( undefined , undefined , 1 , 2 ) ;
1307
+ return Plotly . restyle ( gd , { x : [ [ 2 , 4 ] ] , y : [ [ 3 , 5 ] ] } , [ 1 ] ) ;
1308
+ } )
1309
+ . then ( function ( ) {
1310
+ checkScaling ( 'array' , 'array' , 1 , 2 ) ;
1311
+ return Plotly . restyle ( gd , { x0 : 1 , dy : 3 } , [ 1 ] ) ;
1312
+ } )
1313
+ . then ( function ( ) {
1314
+ checkScaling ( 'scaled' , 'scaled' , 1 , 2 ) ;
1291
1315
} )
1292
1316
. catch ( failTest )
1293
1317
. then ( done ) ;
0 commit comments