From ebfae8f9ef78d2fb4d170dd38dd22c5affd8718f Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Wed, 28 Jun 2017 11:17:23 -0400 Subject: [PATCH 1/2] Accept empty transforms --- src/plot_api/plot_schema.js | 7 +++-- test/jasmine/tests/transform_multi_test.js | 31 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index 03bc35ad760..ee800947036 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -166,10 +166,13 @@ exports.findArrayAttributes = function(trace) { for(var i = 0; i < transforms.length; i++) { var transform = transforms[i]; + var module = transform._module; - stack = ['transforms[' + i + ']']; + if(module) { + stack = ['transforms[' + i + ']']; - exports.crawl(transform._module.attributes, callback, 1); + exports.crawl(module.attributes, callback, 1); + } } } diff --git a/test/jasmine/tests/transform_multi_test.js b/test/jasmine/tests/transform_multi_test.js index 23e0b40a8b5..0d5b3e8a230 100644 --- a/test/jasmine/tests/transform_multi_test.js +++ b/test/jasmine/tests/transform_multi_test.js @@ -17,6 +17,17 @@ describe('general transforms:', function() { var traceIn, traceOut; + it('filters empty transforms', function() { + traceIn = { + y: [2, 1, 2], + transforms: [{}] + }; + + traceOut = Plots.supplyTraceDefaults(traceIn, 0, fullLayout); + + expect(traceOut.transforms).toEqual([{}]); + }); + it('supplyTraceDefaults should supply the transform defaults', function() { traceIn = { y: [2, 1, 2], @@ -436,6 +447,26 @@ describe('multiple transforms:', function() { }); +describe('invalid transforms', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(destroyGraphDiv); + + it('filters them', function(done) { + Plotly.plot(gd, [{ + y: [1, 2, 3], + transforms: [{}] + }]).then(function() { + expect(gd._fullData[0].transforms.length).toEqual(1); + done(); + }); + }); +}); + describe('multiple traces with transforms:', function() { 'use strict'; From dd4554fdda8ec3af7461e12e722dfd7162547aa0 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Wed, 28 Jun 2017 11:24:34 -0400 Subject: [PATCH 2/2] Fix test names --- test/jasmine/tests/transform_multi_test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jasmine/tests/transform_multi_test.js b/test/jasmine/tests/transform_multi_test.js index 0d5b3e8a230..f10541b8e80 100644 --- a/test/jasmine/tests/transform_multi_test.js +++ b/test/jasmine/tests/transform_multi_test.js @@ -17,7 +17,7 @@ describe('general transforms:', function() { var traceIn, traceOut; - it('filters empty transforms', function() { + it('passes through empty transforms', function() { traceIn = { y: [2, 1, 2], transforms: [{}] @@ -456,7 +456,7 @@ describe('invalid transforms', function() { afterEach(destroyGraphDiv); - it('filters them', function(done) { + it('ignores them', function(done) { Plotly.plot(gd, [{ y: [1, 2, 3], transforms: [{}]