Skip to content

Fix contourgl supplyDefaults #4951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
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
5 changes: 4 additions & 1 deletion src/traces/heatmap/xyz_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x
traceOut._length = null;
}

if(traceIn.type === 'heatmapgl') return true; // until we handle calendars for heatmapgl
if(
traceIn.type === 'heatmapgl' ||
traceIn.type === 'contourgl'
) return true; // skip calendars until we handle them in those traces

var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout);
Expand Down
38 changes: 38 additions & 0 deletions test/jasmine/tests/contourgl_test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
var Plotly = require('@lib/index');
var Lib = require('@src/lib');
var d3 = require('d3');
var supplyDefaults = require('@src/traces/heatmapgl').supplyDefaults;
var Plots = require('@src/plots/plots');

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

var schema = Plotly.PlotSchema.get();
var attributeList = Object.getOwnPropertyNames(schema.traces.heatmapgl.attributes);

// Test utilities
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
Expand Down Expand Up @@ -250,3 +255,36 @@ describe('contourgl plots', function() {
});
});
});

describe('heatmapgl supplyDefaults', function() {
'use strict';

var traceIn;
var traceOut;

var defaultColor = '#444';
var layout = {
font: Plots.layoutAttributes.font,
_dfltTitle: {colorbar: 'cb'},
_subplots: {cartesian: ['xy'], xaxis: ['x'], yaxis: ['y']}
};

beforeEach(function() {
traceOut = {};
});

it('should only coerce attributes that are part of scheme', function() {
traceIn = {
type: 'contourgl',
z: [[0, 1], [1, 0]]
};

supplyDefaults(traceIn, traceOut, defaultColor, layout);
var allKeys = Object.getOwnPropertyNames(traceOut);
allKeys.forEach(function(key) {
if(key[0] !== '_') {
expect(attributeList.indexOf(key)).not.toBe(-1, key);
}
});
});
});