Skip to content

Commit 94daf84

Browse files
author
Calvin Fernandez
committed
make gap unsettable when zsmooth is not false
1 parent 4394a0b commit 94daf84

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

src/traces/heatmap/defaults.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2929
}
3030

3131
coerce('text');
32-
coerce('xgap');
33-
coerce('ygap');
34-
coerce('zsmooth');
32+
33+
var zsmooth = coerce('zsmooth');
34+
if(zsmooth === false) {
35+
// ensure that xgap and ygap are coerced only when zsmooth allows them to have an effect.
36+
coerce('xgap');
37+
coerce('ygap');
38+
}
39+
3540
coerce('connectgaps', hasColumns(traceOut) && (traceOut.zsmooth !== false));
3641

3742
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'});

src/traces/histogram2d/defaults.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ module.exports = function supplyDefaults(traceIn, traceOut, layout) {
2323

2424
handleSampleDefaults(traceIn, traceOut, coerce);
2525

26-
coerce('zsmooth');
27-
coerce('xgap');
28-
coerce('ygap');
26+
var zsmooth = coerce('zsmooth');
27+
if(zsmooth === false) {
28+
// ensure that xgap and ygap are coerced only when zsmooth allows them to have an effect.
29+
coerce('xgap');
30+
coerce('ygap');
31+
}
2932

3033
colorscaleDefaults(
3134
traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}

test/jasmine/tests/heatmap_test.js

+14
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ describe('heatmap supplyDefaults', function() {
111111
expect(traceOut.xgap).toBe(10);
112112
expect(traceOut.ygap).toBe(0);
113113
});
114+
115+
it('should not coerce gap if zsmooth is set', function() {
116+
traceIn = {
117+
xgap: 10,
118+
zsmooth: 'best',
119+
type: 'heatmap',
120+
z: [[1, 2], [3, 4]]
121+
};
122+
123+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
124+
expect(traceOut.xgap).toBe(undefined);
125+
expect(traceOut.ygap).toBe(undefined);
126+
});
127+
114128
});
115129

116130
describe('heatmap convertColumnXYZ', function() {

test/jasmine/tests/histogram2d_test.js

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ describe('Test histogram2d', function() {
4343
expect(traceOut.ygap).toBe(5);
4444
});
4545

46+
it('shouldnt coerce gap when zsmooth is set', function() {
47+
traceIn = {
48+
xgap: 10,
49+
ygap: 5,
50+
zsmooth: 'best'
51+
};
52+
supplyDefaults(traceIn, traceOut, {});
53+
expect(traceOut.xgap).toBe(undefined);
54+
expect(traceOut.ygap).toBe(undefined);
55+
});
56+
4657
});
4758

4859
});

0 commit comments

Comments
 (0)