Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extreme off-plot data points in scatter lines #2060

Merged
merged 6 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2734,12 +2734,8 @@ Plotly.purge = function purge(gd) {
// remove plot container
if(fullLayout._container) fullLayout._container.remove();

// in contrast to Plotly.Plots.purge which does NOT clear _context!
delete gd._context;
delete gd._replotPending;
delete gd._mouseDownTime;
delete gd._legendMouseDownTime;
delete gd._hmpixcount;
delete gd._hmlumcount;

return gd;
};
Expand Down
15 changes: 13 additions & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,14 +1341,25 @@ plots.purge = function(gd) {
delete gd._promises;
delete gd._redrawTimer;
delete gd.firstscatter;
delete gd.hmlumcount;
delete gd.hmpixcount;
delete gd._hmlumcount;
delete gd._hmpixcount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

delete gd.numboxes;
delete gd._transitionData;
delete gd._transitioning;
delete gd._initialAutoSize;
delete gd._transitioningWithDuration;

// created during certain events, that *should* clean them up
// themselves, but may not if there was an error
delete gd._dragging;
delete gd._dragged;
delete gd._hoverdata;
delete gd._snapshotInProgress;
delete gd._editing;
delete gd._replotPending;
delete gd._mouseDownTime;
delete gd._legendMouseDownTime;

// remove all event listeners
if(gd.removeAllListeners) gd.removeAllListeners();
};
Expand Down
22 changes: 18 additions & 4 deletions test/jasmine/tests/plots_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ describe('Test Plots', function() {
beforeEach(function(done) {
gd = createGraphDiv();
Plotly.plot(gd, [{ x: [1, 2, 3], y: [2, 3, 4] }], {}).then(done);

// hacky: simulate getting stuck with these flags due to an error
// see #2055 and commit 6a44a9a - before fixing that error, we would
// end up in an inconsistent state that prevented future Plotly.newPlot
// because _dragging and _dragged were not cleared by purge.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the first time I'd seen an error that blocked all future Plotly.newPlot calls! We really need to encapsulate all these gd.*** vars better...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, very nice. Thanks!

gd._dragging = true;
gd._dragged = true;
gd._hoverdata = true;
gd._snapshotInProgress = true;
gd._editing = true;
gd._replotPending = true;
gd._mouseDownTime = true;
gd._legendMouseDownTime = true;
});

afterEach(destroyGraphDiv);
Expand All @@ -416,15 +429,16 @@ describe('Test Plots', function() {
var expectedKeys = [
'_ev', '_internalEv', 'on', 'once', 'removeListener', 'removeAllListeners',
'_internalOn', '_internalOnce', '_removeInternalListener',
'_removeAllInternalListeners', 'emit', '_context', '_replotPending',
'_hmpixcount', '_hmlumcount', '_mouseDownTime', '_legendMouseDownTime',
'_removeAllInternalListeners', 'emit', '_context'
];

var expectedUndefined = [
'data', 'layout', '_fullData', '_fullLayout', 'calcdata', 'framework',
'empty', 'fid', 'undoqueue', 'undonum', 'autoplay', 'changed',
'_promises', '_redrawTimer', 'firstscatter', 'hmlumcount', 'hmpixcount',
'numboxes', '_transitionData', '_transitioning'
'_promises', '_redrawTimer', 'firstscatter', 'numboxes',
'_transitionData', '_transitioning', '_hmpixcount', '_hmlumcount',
'_dragging', '_dragged', '_hoverdata', '_snapshotInProgress', '_editing',
'_replotPending', '_mouseDownTime', '_legendMouseDownTime'
];

Plots.purge(gd);
Expand Down