Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
update connectgaps description and add tests for heatmap and contour …
…auto default logic
  • Loading branch information
archmoj committed Oct 17, 2019
commit 9492c16098647cb462aae9c067789f25cbb83ddc
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