Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions draftlogs/7659_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix pan/zoom failing on first interaction when traces have different `zorder` values [[#7659](https://github.com/plotly/plotly.js/pull/7659)]
11 changes: 10 additions & 1 deletion src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,18 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
function updateSubplots(viewBox) {
var fullLayout = gd._fullLayout;
var plotinfos = fullLayout._plots;
var subplots = fullLayout._subplots.cartesian;
var subplots = fullLayout._subplots.cartesian.slice();
var i, sp, xa, ya;

// Include z-indexed subplots from _plots that may not be in _subplots.cartesian
// (e.g., after a relayout that resets _subplots.cartesian but preserves _plots)
var zindexSeparator = constants.zindexSeparator;
for(var plotId in plotinfos) {
if(plotId.indexOf(zindexSeparator) !== -1 && subplots.indexOf(plotId) === -1) {
subplots.push(plotId);
}
}

if(hasSplom) {
Registry.subplotsRegistry.splom.drag(gd);
}
Expand Down
14 changes: 14 additions & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var Color = require('../components/color');
var BADNUM = require('../constants/numerical').BADNUM;

var axisIDs = require('./cartesian/axis_ids');
var cartesianConstants = require('./cartesian/constants');
var clearOutline = require('../components/shapes/handle_outline').clearOutline;
var scatterAttrs = require('../traces/scatter/layout_attributes');

Expand Down Expand Up @@ -895,6 +896,19 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa
}
}

// Preserve z-indexed subplots (e.g. 'xyz2', 'xyz3') from oldSubplots to _plots only.
// These are created by drawFramework when traces have different zorder values.
// We preserve them to _plots (not _subplots.cartesian) so that drag/pan operations
// in dragbox.js can still transform them during relayout operations that don't
// trigger a full redraw (e.g., resize). If drawFramework runs later, it will
// properly update/remove these subplots as needed.
var zindexSeparator = cartesianConstants.zindexSeparator;
for(var oldId in oldSubplots) {
if(oldId.indexOf(zindexSeparator) !== -1 && !newSubplots[oldId]) {
newSubplots[oldId] = oldSubplots[oldId];
}
}

// while we're at it, link overlaying axes to their main axes and
// anchored axes to the axes they're anchored to
var axList = axisIDs.list(mockGd, null, true);
Expand Down