Skip to content

Commit d47ace6

Browse files
authored
Merge pull request #1829 from plotly/accept-empty-transform
Accept empty transforms
2 parents e4c1c8c + dd4554f commit d47ace6

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/plot_api/plot_schema.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,13 @@ exports.findArrayAttributes = function(trace) {
166166

167167
for(var i = 0; i < transforms.length; i++) {
168168
var transform = transforms[i];
169+
var module = transform._module;
169170

170-
stack = ['transforms[' + i + ']'];
171+
if(module) {
172+
stack = ['transforms[' + i + ']'];
171173

172-
exports.crawl(transform._module.attributes, callback, 1);
174+
exports.crawl(module.attributes, callback, 1);
175+
}
173176
}
174177
}
175178

test/jasmine/tests/transform_multi_test.js

+31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ describe('general transforms:', function() {
1717

1818
var traceIn, traceOut;
1919

20+
it('passes through empty transforms', function() {
21+
traceIn = {
22+
y: [2, 1, 2],
23+
transforms: [{}]
24+
};
25+
26+
traceOut = Plots.supplyTraceDefaults(traceIn, 0, fullLayout);
27+
28+
expect(traceOut.transforms).toEqual([{}]);
29+
});
30+
2031
it('supplyTraceDefaults should supply the transform defaults', function() {
2132
traceIn = {
2233
y: [2, 1, 2],
@@ -436,6 +447,26 @@ describe('multiple transforms:', function() {
436447

437448
});
438449

450+
describe('invalid transforms', function() {
451+
var gd;
452+
453+
beforeEach(function() {
454+
gd = createGraphDiv();
455+
});
456+
457+
afterEach(destroyGraphDiv);
458+
459+
it('ignores them', function(done) {
460+
Plotly.plot(gd, [{
461+
y: [1, 2, 3],
462+
transforms: [{}]
463+
}]).then(function() {
464+
expect(gd._fullData[0].transforms.length).toEqual(1);
465+
done();
466+
});
467+
});
468+
});
469+
439470
describe('multiple traces with transforms:', function() {
440471
'use strict';
441472

0 commit comments

Comments
 (0)