Skip to content

Handle zorder between overlayed cartesian subplots #7032

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

Merged
merged 7 commits into from
Jun 25, 2024
Merged
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
6 changes: 6 additions & 0 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var Drawing = require('../drawing');
var Color = require('../color');
var dragElement = require('../dragelement');
var Axes = require('../../plots/cartesian/axes');
var zindexSeparator = require('../../plots/cartesian/constants').zindexSeparator;
var Registry = require('../../registry');

var helpers = require('./helpers');
Expand Down Expand Up @@ -261,6 +262,11 @@ exports.loneHover = function loneHover(hoverItems, opts) {
function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
if(!subplot) subplot = 'xy';

if(typeof subplot === 'string') {
// drop zindex from subplot id
subplot = subplot.split(zindexSeparator)[0];
}

// if the user passed in an array of subplots,
// use those instead of finding overlayed plots
var subplots = Array.isArray(subplot) ? subplot : [subplot];
Expand Down
4 changes: 3 additions & 1 deletion src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var SVG_TEXT_ANCHOR_START = 'start';
var SVG_TEXT_ANCHOR_MIDDLE = 'middle';
var SVG_TEXT_ANCHOR_END = 'end';

var zindexSeparator = require('../plots/cartesian/constants').zindexSeparator;

exports.layoutStyles = function(gd) {
return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd);
};
Expand Down Expand Up @@ -135,7 +137,7 @@ function lsInner(gd) {
var yDomain = plotinfo.yaxis.domain;
var plotgroup = plotinfo.plotgroup;

if(overlappingDomain(xDomain, yDomain, lowerDomains)) {
if(overlappingDomain(xDomain, yDomain, lowerDomains) && subplot.indexOf(zindexSeparator) === -1) {
var pgNode = plotgroup.node();
var plotgroupBg = plotinfo.bg = Lib.ensureSingle(plotgroup, 'rect', 'bg');
pgNode.insertBefore(plotgroupBg.node(), pgNode.childNodes[0]);
Expand Down
4 changes: 3 additions & 1 deletion src/plots/cartesian/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@ module.exports = {
layerValue2layerClass: {
'above traces': 'above',
'below traces': 'below'
}
},

zindexSeparator: 'z', // used for zindex of cartesian subplots e.g. xy, xyz2, xyz3, etc.
};
Loading