From 442e3b15c45c3b68998477388188e89d90d62c67 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 10 Nov 2016 15:33:56 -0500 Subject: [PATCH 1/3] quick fix - allow relayout array elements --- src/plot_api/plot_api.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 8e6d5440b40..19e496ceff5 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1961,6 +1961,7 @@ function _relayout(gd, aobj) { else { // check whether we can short-circuit a full redraw // 3d or geo at this point just needs to redraw. + var pp1 = String(p.parts[1] || ''); if(p.parts[0].indexOf('scene') === 0) flags.doplot = true; else if(p.parts[0].indexOf('geo') === 0) flags.doplot = true; else if(p.parts[0].indexOf('ternary') === 0) flags.doplot = true; @@ -1973,17 +1974,17 @@ function _relayout(gd, aobj) { else if(ai.indexOf('title') !== -1) flags.doticks = true; else if(p.parts[0].indexOf('bgcolor') !== -1) flags.dolayoutstyle = true; else if(p.parts.length > 1 && - Lib.containsAny(p.parts[1], ['tick', 'exponent', 'grid', 'zeroline'])) { + Lib.containsAny(pp1, ['tick', 'exponent', 'grid', 'zeroline'])) { flags.doticks = true; } else if(ai.indexOf('.linewidth') !== -1 && ai.indexOf('axis') !== -1) { flags.doticks = flags.dolayoutstyle = true; } - else if(p.parts.length > 1 && p.parts[1].indexOf('line') !== -1) { + else if(p.parts.length > 1 && pp1.indexOf('line') !== -1) { flags.dolayoutstyle = true; } - else if(p.parts.length > 1 && p.parts[1] === 'mirror') { + else if(p.parts.length > 1 && pp1 === 'mirror') { flags.doticks = flags.dolayoutstyle = true; } else if(ai === 'margin.pad') { From 82062d6bfa2976bd3f9b6b92275fc888faefb7ad Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 10 Nov 2016 15:55:00 -0500 Subject: [PATCH 2/3] test array relayout quickfix --- test/jasmine/tests/plot_api_test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index 033f4247f1b..c17d296ee02 100644 --- a/test/jasmine/tests/plot_api_test.js +++ b/test/jasmine/tests/plot_api_test.js @@ -148,6 +148,21 @@ describe('Test plot api', function() { }) .then(done); }); + + it('can set items in array objects', function(done) { + Plotly.plot(gd, [{ x: [1, 2, 3], y: [1, 2, 3] }]) + .then(function() { + return Plotly.relayout(gd, {rando: [1, 2, 3]}); + }) + .then(function() { + expect(gd.layout.rando).toEqual([1, 2, 3]); + return Plotly.relayout(gd, {'rando[1]': 45}); + }) + .then(function() { + expect(gd.layout.rando).toEqual([1, 45, 3]); + }) + .then(done); + }); }); describe('Plotly.restyle', function() { From 4db2ba9be4ed973371fd03e93ff29c038f2b62a8 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Thu, 10 Nov 2016 15:57:13 -0500 Subject: [PATCH 3/3] rearrange deckchairs --- src/plot_api/plot_api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 19e496ceff5..bd9f22f8fe8 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1959,9 +1959,9 @@ function _relayout(gd, aobj) { } // alter gd.layout else { + var pp1 = String(p.parts[1] || ''); // check whether we can short-circuit a full redraw // 3d or geo at this point just needs to redraw. - var pp1 = String(p.parts[1] || ''); if(p.parts[0].indexOf('scene') === 0) flags.doplot = true; else if(p.parts[0].indexOf('geo') === 0) flags.doplot = true; else if(p.parts[0].indexOf('ternary') === 0) flags.doplot = true;