Skip to content

Commit 6fcec6e

Browse files
committed
replot with more granular approach
1 parent 85a646f commit 6fcec6e

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/plot_api/plot_api.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,12 @@ exports.plot = function(gd, data, layout, config) {
255255
Lib.error(msg);
256256
} else {
257257
Lib.log(msg + ' Clearing graph and plotting again.');
258-
fullLayout._redrawFromWrongGlDimensions = 1;
259258
Plots.cleanPlot([], {}, gd._fullData, fullLayout, gd.calcdata);
260-
exports.plot(gd, gd.data, gd.layout);
259+
Plots.supplyDefaults(gd);
260+
fullLayout = gd._fullLayout;
261+
Plots.doCalcdata(gd);
262+
fullLayout._redrawFromWrongGlDimensions = 1;
263+
return drawFramework();
261264
}
262265
}
263266
}

test/jasmine/tests/splom_test.js

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var Plotly = require('@lib');
22
var Lib = require('@src/lib');
33
var Plots = require('@src/plots/plots');
4-
var plotApi = require('@src/plot_api/plot_api');
54
var SUBPLOT_PATTERN = require('@src/plots/cartesian/constants').SUBPLOT_PATTERN;
65

76
var d3 = require('d3');
@@ -697,23 +696,43 @@ describe('Test splom interactions:', function() {
697696
expect(gl.drawingBufferHeight).toBe(h, msg);
698697
}
699698

700-
spyOn(plotApi, 'plot').and.callThrough();
699+
var methods = ['cleanPlot', 'supplyDefaults', 'doCalcdata'];
700+
701+
methods.forEach(function(m) { spyOn(Plots, m).and.callThrough(); });
702+
703+
function assetsFnCall(msg, exp) {
704+
methods.forEach(function(m) {
705+
expect(Plots[m]).toHaveBeenCalledTimes(exp[m], msg);
706+
Plots[m].calls.reset();
707+
});
708+
}
709+
701710
spyOn(Lib, 'log');
702711

703712
Plotly.plot(gd, fig).then(function() {
704-
expect(plotApi.plot).toHaveBeenCalledTimes(0);
713+
assetsFnCall('base', {
714+
cleanPlot: 1, // called once from inside Plots.supplyDefaults
715+
supplyDefaults: 1,
716+
doCalcdata: 1
717+
});
718+
assertDims('base', 600, 500);
705719
expect(Lib.log).toHaveBeenCalledTimes(0);
706720
expect(gd._fullLayout._redrawFromWrongGlDimensions).toBeUndefined();
707-
assertDims('base', 600, 500);
721+
722+
spyOn(gd._fullData[0]._module, 'plot').and.callThrough();
708723

709724
return Plotly.relayout(gd, {width: 4810, height: 3656});
710725
})
711726
.then(function() {
712-
expect(plotApi.plot).toHaveBeenCalledTimes(1);
727+
assetsFnCall('after', {
728+
cleanPlot: 4, // 3 three from supplyDefaults, once in drawFramework
729+
supplyDefaults: 3, // 1 from relayout, 1 from automargin, 1 in drawFramework
730+
doCalcdata: 1 // once in drawFramework
731+
});
732+
assertDims('after', 4810, 3656);
713733
expect(Lib.log)
714734
.toHaveBeenCalledWith('WebGL context buffer and canvas dimensions do not match due to browser/WebGL bug. Clearing graph and plotting again.');
715735
expect(gd._fullLayout._redrawFromWrongGlDimensions).toBe(1);
716-
assertDims('base', 4810, 3656);
717736
})
718737
.catch(failTest)
719738
.then(done);

0 commit comments

Comments
 (0)