Skip to content

Better update pattern for cartesian SVG #2563

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

Closed
alexcjohnson opened this issue Apr 16, 2018 · 1 comment
Closed

Better update pattern for cartesian SVG #2563

alexcjohnson opened this issue Apr 16, 2018 · 1 comment

Comments

@alexcjohnson
Copy link
Collaborator

As @etpinard pointed out during the finance refactor PR #2561 (comment) and #2561 (comment) we have a mess when redrawing cartesian SVG traces, both re: deleting and redrawing existing traces and re: removing completely unused modules.

The first part we can handle by making all the trace modules support more d3-idiomatic enter/exit/each logic as suggested in this TODO. The second has a few ways to go about it. Quoting @etpinard:

What we need to do is find all the gone modules (i.e. modules with had??=true and has??=false), loop over them, and then do what we need to do the cleanup the DOM.

Better yet -- as more and more trace type will follow scatter and ohlc in not expecting a selectAll('g.trace').remove() before each _module.plot() -- we could add a trace module method (maybe called cleanDOM) to each trace modules that need to remove things for the DOM (or destroy WebGL objects).

To note, geo subplots (and maybe others?) solve this problem in a different way by using Plots.generalUpdatePerTraceModule which calls _module.plot of visible and gone modules and expects the trace module plot methods to clean up the DOM accordingly (e.g. like here for choropleth traces). At present though, I think adding cleanDOM to each trace module would be best, as it would allow us to handle the scattergl and range-slider cases more easily.

@alexcjohnson
Copy link
Collaborator Author

Another idea about this: create and remove the trace layers ('g.scatterlayer' etc) using a d3-idiomatic pattern based on the actual traces present in each subplot. Then we won't have to look at the old module list at all, d3 will just look at the DOM and remove the no-longer-needed layers. As a bonus then we won't need to make all those empty containers in the first place!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant