From af15b34ef237cfa9a5034b86d96c666d940f0f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 30 Mar 2017 11:35:22 -0400 Subject: [PATCH 1/2] assume redoing calcdata is neccessary when restyling attr containers --- src/plot_api/plot_api.js | 5 +++++ test/jasmine/tests/plot_api_test.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 76d051c5a23..564175ece0a 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1580,6 +1580,11 @@ function _restyle(gd, aobj, _traces) { var moduleAttrs = (contFull._module || {}).attributes || {}; var valObject = Lib.nestedProperty(moduleAttrs, ai).get() || {}; + // if restyling entire attribute container, assume worse case + if(!valObject.valType) { + flags.docalc = true; + } + if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) { flags.docalc = true; } diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index d768f3b99b4..eee008c4a4f 100644 --- a/test/jasmine/tests/plot_api_test.js +++ b/test/jasmine/tests/plot_api_test.js @@ -330,6 +330,25 @@ describe('Test plot api', function() { expect(PlotlyInternal.plot).toHaveBeenCalled(); }); + it('should do full replot when attribute container are updated', function() { + var gd = { + data: [{x: [1, 2, 3], y: [1, 2, 3]}], + layout: { + xaxis: { range: [0, 4] }, + yaxis: { range: [0, 4] } + } + }; + + mockDefaultsAndCalc(gd); + Plotly.restyle(gd, { + marker: { + color: ['red', 'blue', 'green'] + } + }); + expect(gd.calcdata).toBeUndefined(); + expect(PlotlyInternal.plot).toHaveBeenCalled(); + }); + it('calls plot on xgap and ygap styling', function() { var gd = { data: [{z: [[1, 2, 3], [4, 5, 6], [7, 8, 9]], showscale: false, type: 'heatmap'}], From e10c57f31aa8450ccc06a43bea32ce021f801887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 30 Mar 2017 11:35:57 -0400 Subject: [PATCH 2/2] :books: for redo calcdata when restyling array values --- src/plot_api/plot_api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 564175ece0a..61e26cd5ff0 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1585,6 +1585,7 @@ function _restyle(gd, aobj, _traces) { flags.docalc = true; } + // must redo calcdata when restyling array values of arrayOk attributes if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) { flags.docalc = true; }