@@ -168,8 +168,8 @@ describe('heatmap convertColumnXYZ', function() {
168
168
} ;
169
169
}
170
170
171
- var xa = makeMockAxis ( ) ,
172
- ya = makeMockAxis ( ) ;
171
+ var xa = makeMockAxis ( ) ;
172
+ var ya = makeMockAxis ( ) ;
173
173
174
174
it ( 'should convert x/y/z columns to z(x,y)' , function ( ) {
175
175
trace = {
@@ -305,8 +305,13 @@ describe('heatmap calc', function() {
305
305
306
306
Plots . supplyDefaults ( gd ) ;
307
307
var fullTrace = gd . _fullData [ 0 ] ;
308
+ var fullLayout = gd . _fullLayout ;
308
309
309
- return Heatmap . calc ( gd , fullTrace ) [ 0 ] ;
310
+ var out = Heatmap . calc ( gd , fullTrace ) [ 0 ] ;
311
+ out . _xcategories = fullLayout . xaxis . _categories ;
312
+ out . _ycategories = fullLayout . yaxis . _categories ;
313
+
314
+ return out ;
310
315
}
311
316
312
317
it ( 'should fill in bricks if x/y not given' , function ( ) {
@@ -404,6 +409,25 @@ describe('heatmap calc', function() {
404
409
expect ( out . y ) . toBeCloseToArray ( [ - 0.5 , 0.5 ] ) ;
405
410
expect ( out . z ) . toBeCloseTo2DArray ( [ [ 17 , 18 , 19 ] ] ) ;
406
411
} ) ;
412
+
413
+ it ( 'should handle the category x/y/z/ column case' , function ( ) {
414
+ var out = _calc ( {
415
+ x : [ 'a' , 'a' , 'a' , 'b' , 'b' , 'b' , 'c' , 'c' , 'c' ] ,
416
+ y : [ 'A' , 'B' , 'C' , 'A' , 'B' , 'C' , 'A' , 'B' , 'C' ] ,
417
+ z : [ 0 , 50 , 100 , 50 , 0 , 255 , 100 , 510 , 1010 ]
418
+ } ) ;
419
+
420
+ expect ( out . x ) . toBeCloseToArray ( [ - 0.5 , 0.5 , 1.5 , 2.5 ] ) ;
421
+ expect ( out . y ) . toBeCloseToArray ( [ - 0.5 , 0.5 , 1.5 , 2.5 ] ) ;
422
+ expect ( out . z ) . toBeCloseTo2DArray ( [
423
+ [ 0 , 50 , 100 ] ,
424
+ [ 50 , 0 , 510 ] ,
425
+ [ 100 , 255 , 1010 ]
426
+ ] ) ;
427
+
428
+ expect ( out . _xcategories ) . toEqual ( [ 'a' , 'b' , 'c' ] ) ;
429
+ expect ( out . _ycategories ) . toEqual ( [ 'A' , 'B' , 'C' ] ) ;
430
+ } ) ;
407
431
} ) ;
408
432
409
433
describe ( 'heatmap plot' , function ( ) {
0 commit comments