Skip to content

Commit

Permalink
Merge pull request #4284 from plotly/heatmap-contour-connectgaps-defa…
Browse files Browse the repository at this point in the history
…ult-logic

Update connectgaps description in respect to heatmap and contour default logics
  • Loading branch information
archmoj committed Oct 17, 2019
2 parents d41159b + 9492c16 commit 6e9bafb
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/traces/contour/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions src/traces/heatmap/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
22 changes: 22 additions & 0 deletions test/jasmine/tests/contour_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
36 changes: 36 additions & 0 deletions test/jasmine/tests/heatmap_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 6e9bafb

Please sign in to comment.