8000 Sanitize orphan subplot logic and 'last trace' deletion by etpinard · Pull Request #268 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Sanitize orphan subplot logic and 'last trace' deletion #268

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
wants to merge 19 commits into from
Closed
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
Prev Previous commit
Next Next commit
fix typos
  • Loading branch information
etpinard committed Feb 22, 2016
commit dc72d33308d39f8c1224468533622219cda57c37
4 changes: 2 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ Plotly.plot = function(gd, data, layout, config) {
function drawData() {
var calcdata = gd.calcdata;

// in case of traces that were heatmaps or contour maps
// previously, remove them and their colorbars explicitly
for(var i = 0; i < calcdata.length; i++) {
var trace = calcdata[i][0].trace,
isVisible = (trace.visible === true),
uid = trace.uid;

// in case of traces that were heatmaps or contour maps
// previously, remove them and their colorbars explicitly
if(!isVisible || !Plots.traceIs(trace, '2dMap')) {
fullLayout._paper.selectAll(
'.hm' + uid +
Expand Down
33 changes: 16 additions & 17 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ plots.registerSubplot = function(_module) {
* in the defaults step. Use plots.getSubplotIds to grab the current
* subplot ids later on in Plotly.plot.
*
* @param {array} data plotly data array
* @param {array} data : plotly data array
* (intended to be _fullData, but does not have to be).
* @param {object} layout plotly layout object
* @param {object} layout : plotly layout object
* (intended to be _fullLayout, but does not have to be).
* @param {string} type subplot type to look for.
* @param {string} type : subplot type to look for.
*
* @return {array} list of subplot ids (strings).
* N.B. these ids possibly un-ordered.
* N.B. these ids are possibly un-ordered.
*
* TODO incorporate cartesian/gl2d axis finders in this paradigm.
*/
Expand Down Expand Up @@ -189,8 +189,8 @@ plots.findSubplotIds = function findSubplotIds(data, layout, type) {
/**
* Get the ids of the current subplots.
*
* @param {object} layout plotly full layout object.
* @param {string} type subplot type to look for.
* @param {object} layout : plotly full layout object.
* @param {string} type : subplot type to look for.
*
* @return {array} list of ordered subplot ids (strings).
*
Expand Down Expand Up @@ -231,9 +231,9 @@ plots.getSubplotIds = function getSubplotIds(layout, type) {
/**
* Get the data traces associated with a particular subplot.
*
* @param {object} layout plotly layout object
* @param {object} layout : plotly layout object
* (intended to be _fullLayout, but does not have to be).
* @param {string} type subplot type to look for.
* @param {string} type : subplot type to look for.
*
* @return {array} array of plotly traces.
*
Expand Down Expand Up @@ -503,7 +503,7 @@ plots.supplyDefaults = function(gd) {
// finally, fill in the pieces of layout that may need to look at data
plots.supplyLayoutModuleDefaults(newLayout, newFullLayout, newFullData);

// clean subplots and other artifact from previous plot calls
// clean subplots and other artifacts from previous plot calls
cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout);

/*
Expand Down Expand Up @@ -550,27 +550,26 @@ function cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout) {
oldLoop:
for(i = 0; i < oldFullData.length; i++) {
var oldTrace = oldFullData[i];
var oldUid = oldTrace.uid;

for(j = 0; j < newFullData.length; j++) {
var newTrace = newFullData.length;
var newTrace = newFullData[j];

if(oldTrace.uid === newTrace.uid) continue oldLoop;
if(oldUid === newTrace.uid) continue oldLoop;
}

var uid = oldTrace.uid;

// clean old heatmap and contour traces
if(hasPaper) {
oldFullLayout._paper.selectAll(
'.hm' + uid +
',.contour' + uid +
',#clip' + uid
'.hm' + oldUid +
',.contour' + oldUid +
',#clip' + oldUid
).remove();
}

// clean old colorbars
if(hasInfoLayer) {
oldFullLayout._infolayer.selectAll('.cb' + uid).remove();
oldFullLayout._infolayer.selectAll('.cb' + oldUid).remove();
}
}
}
Expand Down
0