@@ -287,10 +287,11 @@ describe('heatmap convertColumnXYZ', function() {
287287describe ( 'heatmap calc' , function ( ) {
288288 'use strict' ;
289289
290- function _calc ( opts ) {
290+ function _calc ( opts , layout ) {
291291 var base = { type : 'heatmap' } ;
292292 var trace = Lib . extendFlat ( { } , base , opts ) ;
293293 var gd = { data : [ trace ] } ;
294+ if ( layout ) gd . layout = layout ;
294295
295296 supplyAllDefaults ( gd ) ;
296297 var fullTrace = gd . _fullData [ 0 ] ;
@@ -408,6 +409,20 @@ describe('heatmap calc', function() {
408409 expect ( out . z ) . toBeCloseTo2DArray ( [ [ 17 , 18 , 19 ] ] ) ;
409410 } ) ;
410411
412+ it ( 'should handle the category case (edge case with a *0* category)' , function ( ) {
413+ var out = _calc ( {
414+ x : [ 'a' , 'b' , 0 ] ,
415+ y : [ 'z' , 0 , 'y' ] ,
416+ z : [ [ 17 , 18 , 19 ] , [ 10 , 20 , 30 ] , [ 40 , 30 , 20 ] ]
417+ } , {
418+ xaxis : { type : 'category' } ,
419+ yaxis : { type : 'category' }
420+ } ) ;
421+
422+ expect ( out . x ) . toBeCloseToArray ( [ - 0.5 , 0.5 , 1.5 , 2.5 ] ) ;
423+ expect ( out . y ) . toBeCloseToArray ( [ - 0.5 , 0.5 , 1.5 , 2.5 ] ) ;
424+ } ) ;
425+
411426 it ( 'should handle the category x/y/z/ column case' , function ( ) {
412427 var out = _calc ( {
413428 x : [ 'a' , 'a' , 'a' , 'b' , 'b' , 'b' , 'c' , 'c' , 'c' ] ,
0 commit comments