From 9492c16098647cb462aae9c067789f25cbb83ddc Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 17 Oct 2019 14:00:31 -0400 Subject: [PATCH] update connectgaps description and add tests for heatmap and contour auto default logic --- src/traces/contour/attributes.js | 11 ++++++++- src/traces/heatmap/attributes.js | 6 +++-- test/jasmine/tests/contour_test.js | 22 ++++++++++++++++++ test/jasmine/tests/heatmap_test.js | 36 ++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/traces/contour/attributes.js b/src/traces/contour/attributes.js index b8bc81a025f..ea200b51b5a 100644 --- a/src/traces/contour/attributes.js +++ b/src/traces/contour/attributes.js @@ -39,7 +39,16 @@ module.exports = extendFlat({ zhoverformat: heatmapAttrs.zhoverformat, hovertemplate: heatmapAttrs.hovertemplate, - connectgaps: heatmapAttrs.connectgaps, + connectgaps: extendFlat({}, heatmapAttrs.connectgaps, { + description: [ + 'Determines whether or not gaps', + '(i.e. {nan} or missing values)', + 'in the `z` data are filled in.', + 'It is defaulted to true if `z` is a', + 'one dimensional array', + 'otherwise it is defaulted to false.' + ].join(' ') + }), fillcolor: { valType: 'color', diff --git a/src/traces/heatmap/attributes.js b/src/traces/heatmap/attributes.js index 6be9ef1fc5a..7aa7e9da0a8 100644 --- a/src/traces/heatmap/attributes.js +++ b/src/traces/heatmap/attributes.js @@ -81,13 +81,15 @@ module.exports = extendFlat({ }, connectgaps: { valType: 'boolean', - dflt: false, role: 'info', editType: 'calc', description: [ 'Determines whether or not gaps', '(i.e. {nan} or missing values)', - 'in the `z` data are filled in.' + 'in the `z` data are filled in.', + 'It is defaulted to true if `z` is a', + 'one dimensional array and `zsmooth` is not false;', + 'otherwise it is defaulted to false.' ].join(' ') }, xgap: { diff --git a/test/jasmine/tests/contour_test.js b/test/jasmine/tests/contour_test.js index 7197f63c408..a4d6aa9d153 100644 --- a/test/jasmine/tests/contour_test.js +++ b/test/jasmine/tests/contour_test.js @@ -64,6 +64,28 @@ describe('contour defaults', function() { expect(traceOut.autocontour).toBe(true); }); + it('should default connectgaps to false if `z` is not a one dimensional array', function() { + traceIn = { + type: 'heatmap', + z: [[0, null], [1, 2]] + }; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + expect(traceOut.connectgaps).toBe(false); + }); + + it('should default connectgaps to true if `z` is a one dimensional array', function() { + traceIn = { + type: 'heatmap', + x: [0, 1, 0, 1], + y: [0, 0, 1, 1], + z: [0, null, 1, 2] + }; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + expect(traceOut.connectgaps).toBe(true); + }); + it('should inherit layout.calendar', function() { traceIn = { x: [1, 2], diff --git a/test/jasmine/tests/heatmap_test.js b/test/jasmine/tests/heatmap_test.js index 875a92dc7f7..91422d1ff00 100644 --- a/test/jasmine/tests/heatmap_test.js +++ b/test/jasmine/tests/heatmap_test.js @@ -128,6 +128,42 @@ describe('heatmap supplyDefaults', function() { expect(traceOut.ygap).toBe(undefined); }); + it('should default connectgaps to false if `z` is not a one dimensional array', function() { + traceIn = { + type: 'heatmap', + z: [[0, null], [1, 2]] + }; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + expect(traceOut.connectgaps).toBe(false); + }); + + it('should default connectgaps to true if `z` is a one dimensional array and `zsmooth` is not false', function() { + traceIn = { + zsmooth: 'fast', + type: 'heatmap', + x: [1, 1, 2, 2, 2], + y: [1, 2, 1, 2, 3], + z: [1, null, 4, 5, 6] + }; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + expect(traceOut.connectgaps).toBe(true); + }); + + it('should default connectgaps to false if `zsmooth` is false', function() { + traceIn = { + zsmooth: false, + type: 'heatmap', + x: [1, 1, 2, 2, 2], + y: [1, 2, 1, 2, 3], + z: [1, null, 4, 5, 6] + }; + + supplyDefaults(traceIn, traceOut, defaultColor, layout); + expect(traceOut.connectgaps).toBe(false); + }); + it('should inherit layout.calendar', function() { traceIn = { x: [1, 2],