-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Clean up removed axes and axis lines #2416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,6 +306,17 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) | |
purgeSubplotLayers(oldFullLayout._cartesianlayer.selectAll('.subplot'), oldFullLayout); | ||
oldFullLayout._defs.selectAll('.axesclip').remove(); | ||
} | ||
// otherwise look for subplots we need to remove | ||
else if(oldSubplotList.cartesian) { | ||
for(i = 0; i < oldSubplotList.cartesian.length; i++) { | ||
var oldSubplotId = oldSubplotList.cartesian[i]; | ||
if(newSubplotList.cartesian.indexOf(oldSubplotId) === -1) { | ||
var selector = '.' + oldSubplotId + ',.' + oldSubplotId + '-x,.' + oldSubplotId + '-y'; | ||
oldFullLayout._cartesianlayer.selectAll(selector).remove(); | ||
removeSubplotExtras(oldSubplotId, oldFullLayout); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
exports.drawFramework = function(gd) { | ||
|
@@ -484,11 +495,9 @@ function purgeSubplotLayers(layers, fullLayout) { | |
|
||
layers.each(function(subplotId) { | ||
var plotgroup = d3.select(this); | ||
var clipId = 'clip' + fullLayout._uid + subplotId + 'plot'; | ||
|
||
plotgroup.remove(); | ||
fullLayout._draggers.selectAll('g.' + subplotId).remove(); | ||
fullLayout._defs.select('#' + clipId).remove(); | ||
removeSubplotExtras(subplotId, fullLayout); | ||
|
||
overlayIdsToRemove[subplotId] = true; | ||
|
||
|
@@ -515,6 +524,11 @@ function purgeSubplotLayers(layers, fullLayout) { | |
} | ||
} | ||
|
||
function removeSubplotExtras(subplotId, fullLayout) { | ||
fullLayout._draggers.selectAll('g.' + subplotId).remove(); | ||
fullLayout._defs.select('#clip' + fullLayout._uid + subplotId + 'plot').remove(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about axis titles? They are removed above in an old vs new axis loop, could we combine that in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Titles are per axis, because there's only ever one copy per axis, so they're inserted with no reference to the subplot and it would be incorrect to tie their removal to the disappearance of any given subplot. |
||
} | ||
|
||
function joinLayer(parent, nodeType, className, dataVal) { | ||
var layer = parent.selectAll('.' + className) | ||
.data([dataVal || 0]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a good candidate for a new addition to
src/constants/
(e.g.blankPath
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do use it a fair amount... though we use it for purposes other than just blank (as the start of a real path for example), and between the open
'M0,0'
and closedM0,0Z
variants (though maybe we don't need the closed one and could switch to open?), I feel like hiding it in a constant may make its purpose less clear rather than more.