Skip to content

Commit 5c0179d

Browse files
authored
Merge pull request #4951 from plotly/test-contourgl-coerce
Fix contourgl supplyDefaults
2 parents 14c7632 + 76edd6d commit 5c0179d

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/traces/heatmap/xyz_defaults.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x
4444
traceOut._length = null;
4545
}
4646

47-
if(traceIn.type === 'heatmapgl') return true; // until we handle calendars for heatmapgl
47+
if(
48+
traceIn.type === 'heatmapgl' ||
49+
traceIn.type === 'contourgl'
50+
) return true; // skip calendars until we handle them in those traces
4851

4952
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
5053
handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout);

test/jasmine/tests/contourgl_test.js

+38
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
33
var d3 = require('d3');
4+
var supplyDefaults = require('@src/traces/heatmapgl').supplyDefaults;
5+
var Plots = require('@src/plots/plots');
46

57
// contourgl is not part of the dist plotly.js bundle initially
68
Plotly.register([
79
require('@lib/contourgl')
810
]);
911

12+
var schema = Plotly.PlotSchema.get();
13+
var attributeList = Object.getOwnPropertyNames(schema.traces.heatmapgl.attributes);
14+
1015
// Test utilities
1116
var createGraphDiv = require('../assets/create_graph_div');
1217
var destroyGraphDiv = require('../assets/destroy_graph_div');
@@ -250,3 +255,36 @@ describe('contourgl plots', function() {
250255
});
251256
});
252257
});
258+
259+
describe('heatmapgl supplyDefaults', function() {
260+
'use strict';
261+
262+
var traceIn;
263+
var traceOut;
264+
265+
var defaultColor = '#444';
266+
var layout = {
267+
font: Plots.layoutAttributes.font,
268+
_dfltTitle: {colorbar: 'cb'},
269+
_subplots: {cartesian: ['xy'], xaxis: ['x'], yaxis: ['y']}
270+
};
271+
272+
beforeEach(function() {
273+
traceOut = {};
274+
});
275+
276+
it('should only coerce attributes that are part of scheme', function() {
277+
traceIn = {
278+
type: 'contourgl',
279+
z: [[0, 1], [1, 0]]
280+
};
281+
282+
supplyDefaults(traceIn, traceOut, defaultColor, layout);
283+
var allKeys = Object.getOwnPropertyNames(traceOut);
284+
allKeys.forEach(function(key) {
285+
if(key[0] !== '_') {
286+
expect(attributeList.indexOf(key)).not.toBe(-1, key);
287+
}
288+
});
289+
});
290+
});

0 commit comments

Comments
 (0)