diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 629518b1347..1b35e32ac77 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1576,9 +1576,17 @@ function _restyle(gd, aobj, _traces) { helpers.manageArrayContainers(param, newVal, undoit); flags.docalc = true; } - // all the other ones, just modify that one attribute - else param.set(newVal); + else { + var moduleAttrs = (contFull._module || {}).attributes || {}; + var valObject = Lib.nestedProperty(moduleAttrs, ai).get() || {}; + if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) { + flags.docalc = true; + } + + // all the other ones, just modify that one attribute + param.set(newVal); + } } // swap the data attributes of the relevant x and y axes? diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index e46a661927a..beb2805dc99 100644 --- a/test/jasmine/tests/plot_api_test.js +++ b/test/jasmine/tests/plot_api_test.js @@ -285,6 +285,36 @@ describe('Test plot api', function() { expect(gd.calcdata).toBeDefined(); }); + it('should do full replot when arrayOk attributes are updated', function() { + var gd = { + data: [{x: [1, 2, 3], y: [1, 2, 3]}], + layout: {} + }; + + mockDefaultsAndCalc(gd); + Plotly.restyle(gd, 'marker.color', [['red', 'green', 'blue']]); + expect(gd.calcdata).toBeUndefined(); + expect(PlotlyInternal.plot).toHaveBeenCalled(); + + mockDefaultsAndCalc(gd); + PlotlyInternal.plot.calls.reset(); + Plotly.restyle(gd, 'marker.color', 'yellow'); + expect(gd.calcdata).toBeUndefined(); + expect(PlotlyInternal.plot).toHaveBeenCalled(); + + mockDefaultsAndCalc(gd); + PlotlyInternal.plot.calls.reset(); + Plotly.restyle(gd, 'marker.color', 'blue'); + expect(gd.calcdata).toBeDefined(); + expect(PlotlyInternal.plot).not.toHaveBeenCalled(); + + mockDefaultsAndCalc(gd); + PlotlyInternal.plot.calls.reset(); + 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'}],