Skip to content

Commit 6e9bafb

Browse files
authored
Merge pull request #4284 from plotly/heatmap-contour-connectgaps-default-logic
Update connectgaps description in respect to heatmap and contour default logics
2 parents d41159b + 9492c16 commit 6e9bafb

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

src/traces/contour/attributes.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ module.exports = extendFlat({
3939
zhoverformat: heatmapAttrs.zhoverformat,
4040
hovertemplate: heatmapAttrs.hovertemplate,
4141

42-
connectgaps: heatmapAttrs.connectgaps,
42+
connectgaps: extendFlat({}, heatmapAttrs.connectgaps, {
43+
description: [
44+
'Determines whether or not gaps',
45+
'(i.e. {nan} or missing values)',
46+
'in the `z` data are filled in.',
47+
'It is defaulted to true if `z` is a',
48+
'one dimensional array',
49+
'otherwise it is defaulted to false.'
50+
].join(' ')
51+
}),
4352

4453
fillcolor: {
4554
valType: 'color',

src/traces/heatmap/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ module.exports = extendFlat({
8181
},
8282
connectgaps: {
8383
valType: 'boolean',
84-
dflt: false,
8584
role: 'info',
8685
editType: 'calc',
8786
description: [
8887
'Determines whether or not gaps',
8988
'(i.e. {nan} or missing values)',
90-
'in the `z` data are filled in.'
89+
'in the `z` data are filled in.',
90+
'It is defaulted to true if `z` is a',
91+
'one dimensional array and `zsmooth` is not false;',
92+
'otherwise it is defaulted to false.'
9193
].join(' ')
9294
},
9395
xgap: {

test/jasmine/tests/contour_test.js

+22
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ describe('contour defaults', function() {
6464
expect(traceOut.autocontour).toBe(true);
6565
});
6666

67+
it('should default connectgaps to false if `z` is not a one dimensional array', function() {
68+
traceIn = {
69+
type: 'heatmap',
70+
z: [[0, null], [1, 2]]
71+
};
72+
73+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
74+
expect(traceOut.connectgaps).toBe(false);
75+
});
76+
77+
it('should default connectgaps to true if `z` is a one dimensional array', function() {
78+
traceIn = {
79+
type: 'heatmap',
80+
x: [0, 1, 0, 1],
81+
y: [0, 0, 1, 1],
82+
z: [0, null, 1, 2]
83+
};
84+
85+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
86+
expect(traceOut.connectgaps).toBe(true);
87+
});
88+
6789
it('should inherit layout.calendar', function() {
6890
traceIn = {
6991
x: [1, 2],

test/jasmine/tests/heatmap_test.js

+36
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,42 @@ describe('heatmap supplyDefaults', function() {
128128
expect(traceOut.ygap).toBe(undefined);
129129
});
130130

131+
it('should default connectgaps to false if `z` is not a one dimensional array', function() {
132+
traceIn = {
133+
type: 'heatmap',
134+
z: [[0, null], [1, 2]]
135+
};
136+
137+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
138+
expect(traceOut.connectgaps).toBe(false);
139+
});
140+
141+
it('should default connectgaps to true if `z` is a one dimensional array and `zsmooth` is not false', function() {
142+
traceIn = {
143+
zsmooth: 'fast',
144+
type: 'heatmap',
145+
x: [1, 1, 2, 2, 2],
146+
y: [1, 2, 1, 2, 3],
147+
z: [1, null, 4, 5, 6]
148+
};
149+
150+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
151+
expect(traceOut.connectgaps).toBe(true);
152+
});
153+
154+
it('should default connectgaps to false if `zsmooth` is false', function() {
155+
traceIn = {
156+
zsmooth: false,
157+
type: 'heatmap',
158+
x: [1, 1, 2, 2, 2],
159+
y: [1, 2, 1, 2, 3],
160+
z: [1, null, 4, 5, 6]
161+
};
162+
163+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
164+
expect(traceOut.connectgaps).toBe(false);
165+
});
166+
131167
it('should inherit layout.calendar', function() {
132168
traceIn = {
133169
x: [1, 2],

0 commit comments

Comments
 (0)