Skip to content

Commit

Permalink
make scattergl dragmode relayout replot not recalc
Browse files Browse the repository at this point in the history
... replot is sufficient since regl push.
  • Loading branch information
etpinard committed Feb 26, 2018
1 parent 2372629 commit 909120e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2008,12 +2008,12 @@ function _relayout(gd, aobj) {
else flags.plot = true;
}
else {
if((fullLayout._has('gl2d') || fullLayout._has('regl')) &&
if((fullLayout._has('scatter-like') && fullLayout._has('regl')) &&
(ai === 'dragmode' &&
(vi === 'lasso' || vi === 'select') &&
!(vOld === 'lasso' || vOld === 'select'))
) {
flags.calc = true;
flags.plot = true;

This comment has been minimized.

Copy link
@etpinard

etpinard Feb 26, 2018

Author Contributor

It would be nice remove this block entirely at some point. Relayout times at 1e6 can still be significant. Skipping the calc step here with this commit does help by shaving off ~300ms.

}
else if(valObject) editTypes.update(flags, valObject);
else flags.calc = true;
Expand Down
10 changes: 5 additions & 5 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe('Test plot api', function() {
return gd;
}

it('should trigger recalc when switching into select or lasso dragmode', function() {
it('should trigger replot (but not recalc) when switching into select or lasso dragmode for scattergl traces', function() {
var gd = mock({
data: [{
type: 'scattergl',
Expand All @@ -541,8 +541,8 @@ describe('Test plot api', function() {
expect(subroutines.layoutReplot).not.toHaveBeenCalled();
}

function expectRecalc() {
expect(gd.calcdata).toBeUndefined();
function expectReplot() {
expect(gd.calcdata).toBeDefined();
expect(subroutines.doModeBar).not.toHaveBeenCalled();
expect(subroutines.layoutReplot).toHaveBeenCalled();
}
Expand All @@ -551,7 +551,7 @@ describe('Test plot api', function() {
expectModeBarOnly();

Plotly.relayout(mock(gd), 'dragmode', 'lasso');
expectRecalc();
expectReplot();

Plotly.relayout(mock(gd), 'dragmode', 'select');
expectModeBarOnly();
Expand All @@ -563,7 +563,7 @@ describe('Test plot api', function() {
expectModeBarOnly();

Plotly.relayout(mock(gd), 'dragmode', 'select');
expectRecalc();
expectReplot();
});
});

Expand Down

0 comments on commit 909120e

Please sign in to comment.