@@ -387,6 +387,25 @@ describe('Test colorscale:', function() {
387387 expect ( trace . colorscale [ 5 ] ) . toEqual ( [ 1 , 'rgb(220,220,220)' ] ) ;
388388 } ) ;
389389
390+ it ( 'should be layout.colorscale.sequentialminus when autocolorscale and z <= 0' , function ( ) {
391+ var colorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
392+ trace = {
393+ type : 'heatmap' ,
394+ z : [ [ - 0 , - 1.5 ] , [ - 2 , - 10 ] ] ,
395+ autocolorscale : true ,
396+ _input : { autocolorscale : true }
397+ } ;
398+ var layout = {
399+ colorscale : {
400+ sequentialminus : colorscale
401+ }
402+ } ;
403+ gd = _supply ( trace , layout ) ;
404+ calcColorscale ( gd , trace , { vals : trace . z , containerStr : '' , cLetter : 'z' } ) ;
405+ expect ( trace . autocolorscale ) . toBe ( true ) ;
406+ expect ( trace . colorscale ) . toEqual ( colorscale ) ;
407+ } ) ;
408+
390409 it ( 'should set autocolorscale to false if it wasn\'t explicitly set true in input' , function ( ) {
391410 trace = {
392411 type : 'heatmap' ,
@@ -416,6 +435,26 @@ describe('Test colorscale:', function() {
416435 expect ( trace . colorscale [ 5 ] ) . toEqual ( [ 1 , 'rgb(220,220,220)' ] ) ;
417436 } ) ;
418437
438+ it ( 'should be layout.colorscale.sequentialminus when autocolorscale and the only numerical z <= -0.5' , function ( ) {
439+ var colorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
440+ trace = {
441+ type : 'heatmap' ,
442+ z : [ [ 'a' , 'b' ] , [ - 0.5 , 'd' ] ] ,
443+ autocolorscale : true ,
444+ _input : { autocolorscale : true }
445+ } ;
446+ z = [ [ undefined , undefined ] , [ - 0.5 , undefined ] ] ;
447+ var layout = {
448+ colorscale : {
449+ sequentialminus : colorscale
450+ }
451+ } ;
452+ gd = _supply ( trace , layout ) ;
453+ calcColorscale ( gd , trace , { vals : z , containerStr : '' , cLetter : 'z' } ) ;
454+ expect ( trace . autocolorscale ) . toBe ( true ) ;
455+ expect ( trace . colorscale ) . toEqual ( colorscale ) ;
456+ } ) ;
457+
419458 it ( 'should be Reds when the only numerical z >= 0.5' , function ( ) {
420459 trace = {
421460 type : 'heatmap' ,
@@ -430,6 +469,68 @@ describe('Test colorscale:', function() {
430469 expect ( trace . colorscale [ 0 ] ) . toEqual ( [ 0 , 'rgb(220,220,220)' ] ) ;
431470 } ) ;
432471
472+ it ( 'should be layout.colorscale.sequential when autocolorscale and the only numerical z >= 0.5' , function ( ) {
473+ var colorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
474+ trace = {
475+ type : 'heatmap' ,
476+ z : [ [ 'a' , 'b' ] , [ 0.5 , 'd' ] ] ,
477+ autocolorscale : true ,
478+ _input : { autocolorscale : true }
479+ } ;
480+ z = [ [ undefined , undefined ] , [ 0.5 , undefined ] ] ;
481+ var layout = {
482+ colorscale : {
483+ sequential : colorscale
484+ }
485+ } ;
486+ gd = _supply ( trace , layout ) ;
487+ calcColorscale ( gd , trace , { vals : z , containerStr : '' , cLetter : 'z' } ) ;
488+ expect ( trace . autocolorscale ) . toBe ( true ) ;
489+ expect ( trace . colorscale ) . toEqual ( colorscale ) ;
490+ } ) ;
491+
492+ it ( 'should be layout.colorscale.diverging when autocolorscale and there are positive and negative values' , function ( ) {
493+ var colorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
494+ trace = {
495+ type : 'heatmap' ,
496+ z : [ [ - 1.0 , 'b' ] , [ 0.5 , 'd' ] ] ,
497+ autocolorscale : true ,
498+ _input : { autocolorscale : true }
499+ } ;
500+ z = [ [ - 1.0 , undefined ] , [ 0.5 , undefined ] ] ;
501+ var layout = {
502+ colorscale : {
503+ diverging : colorscale
504+ }
505+ } ;
506+ gd = _supply ( trace , layout ) ;
507+ calcColorscale ( gd , trace , { vals : z , containerStr : '' , cLetter : 'z' } ) ;
508+ expect ( trace . autocolorscale ) . toBe ( true ) ;
509+ expect ( trace . colorscale ) . toEqual ( colorscale ) ;
510+ } ) ;
511+
512+ it ( 'should ignore layout.colorscale.diverging when colorscale is defined at trace-level' , function ( ) {
513+ var colorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
514+ var layoutColorscale = [ [ 0 , 'rgb(0,0,0)' ] , [ 1 , 'rgb(255,255,255)' ] ] ;
515+ trace = {
516+ type : 'heatmap' ,
517+ z : [ [ - 1.0 , 'b' ] , [ 0.5 , 'd' ] ] ,
518+ autocolorscale : true ,
519+ _input : { autocolorscale : true } ,
520+ colorscale : colorscale
521+ } ;
522+ z = [ [ - 1.0 , undefined ] , [ 0.5 , undefined ] ] ;
523+ var layout = {
524+ colorscale : {
525+ diverging : layoutColorscale
526+ }
527+ } ;
528+ gd = _supply ( trace , layout ) ;
529+ calcColorscale ( gd , trace , { vals : z , containerStr : '' , cLetter : 'z' } ) ;
530+ expect ( trace . autocolorscale ) . toBe ( true ) ;
531+ expect ( trace . colorscale ) . toEqual ( colorscale ) ;
532+ } ) ;
533+
433534 it ( 'should be reverse the auto scale when reversescale is true' , function ( ) {
434535 trace = {
435536 type : 'heatmap' ,
0 commit comments