Skip to content

Commit ee329a3

Browse files
committed
Merge remote-tracking branch 'origin-plotly/master' into custom_tick_label_display
# Conflicts: # src/plots/cartesian/layout_attributes.js
2 parents cd7e7c1 + 8b1f5bd commit ee329a3

30 files changed

+606
-146
lines changed

draftlogs/7006_add.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add property `ticklabelstandoff` and `ticklabelshift` to cartesian axes to adjust positioning of tick labels [[#7006](https://github.com/plotly/plotly.js/pull/7006)]

draftlogs/7032_fix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Handle `zorder` between overlayed cartesian subplots [[#7032](https://github.com/plotly/plotly.js/pull/7032)],
2+
This feature was anonymously sponsored: thank you to our sponsor!

src/components/colorbar/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
111111
var font = layout.font;
112112
var opts = {
113113
noAutotickangles: true,
114+
noTicklabelshift: true,
115+
noTicklabelstandoff: true,
114116
outerTicks: false,
115117
font: font
116118
};

src/components/fx/hover.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var Drawing = require('../drawing');
1515
var Color = require('../color');
1616
var dragElement = require('../dragelement');
1717
var Axes = require('../../plots/cartesian/axes');
18+
var zindexSeparator = require('../../plots/cartesian/constants').zindexSeparator;
1819
var Registry = require('../../registry');
1920

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

265+
if(typeof subplot === 'string') {
266+
// drop zindex from subplot id
267+
subplot = subplot.split(zindexSeparator)[0];
268+
}
269+
264270
// if the user passed in an array of subplots,
265271
// use those instead of finding overlayed plots
266272
var subplots = Array.isArray(subplot) ? subplot : [subplot];

src/plot_api/subroutines.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ var SVG_TEXT_ANCHOR_START = 'start';
2424
var SVG_TEXT_ANCHOR_MIDDLE = 'middle';
2525
var SVG_TEXT_ANCHOR_END = 'end';
2626

27+
var zindexSeparator = require('../plots/cartesian/constants').zindexSeparator;
28+
2729
exports.layoutStyles = function(gd) {
2830
return Lib.syncOrAsync([Plots.doAutoMargin, lsInner], gd);
2931
};
@@ -135,7 +137,7 @@ function lsInner(gd) {
135137
var yDomain = plotinfo.yaxis.domain;
136138
var plotgroup = plotinfo.plotgroup;
137139

138-
if(overlappingDomain(xDomain, yDomain, lowerDomains)) {
140+
if(overlappingDomain(xDomain, yDomain, lowerDomains) && subplot.indexOf(zindexSeparator) === -1) {
139141
var pgNode = plotgroup.node();
140142
var plotgroupBg = plotinfo.bg = Lib.ensureSingle(plotgroup, 'rect', 'bg');
141143
pgNode.insertBefore(plotgroupBg.node(), pgNode.childNodes[0]);

src/plots/cartesian/axes.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,20 +3021,39 @@ axes.makeTransTickFn = function(ax) {
30213021

30223022
axes.makeTransTickLabelFn = function(ax) {
30233023
var uv = getTickLabelUV(ax);
3024+
var shift = ax.ticklabelshift || 0;
3025+
var standoff = ax.ticklabelstandoff || 0;
3026+
30243027
var u = uv[0];
30253028
var v = uv[1];
30263029

3030+
var isReversed = ax.range[0] > ax.range[1];
3031+
var labelsInside = ax.ticklabelposition && ax.ticklabelposition.indexOf('inside') !== -1;
3032+
var labelsOutside = !labelsInside;
3033+
3034+
if(shift) {
3035+
var shiftSign = isReversed ? -1 : 1;
3036+
shift = shift * shiftSign;
3037+
}
3038+
if(standoff) {
3039+
var side = ax.side;
3040+
var standoffSign = (
3041+
(labelsInside && (side === 'top' || side === 'left')) ||
3042+
(labelsOutside && (side === 'bottom' || side === 'right'))
3043+
) ? 1 : -1;
3044+
standoff = standoff * standoffSign;
3045+
}
30273046
return ax._id.charAt(0) === 'x' ?
30283047
function(d) {
30293048
return strTranslate(
3030-
u + ax._offset + ax.l2p(getPosX(d)),
3031-
v
3049+
u + ax._offset + ax.l2p(getPosX(d)) + shift,
3050+
v + standoff
30323051
);
30333052
} :
30343053
function(d) {
30353054
return strTranslate(
3036-
v,
3037-
u + ax._offset + ax.l2p(getPosX(d))
3055+
v + standoff,
3056+
u + ax._offset + ax.l2p(getPosX(d)) + shift
30383057
);
30393058
};
30403059
};

src/plots/cartesian/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,7 @@ module.exports = {
6666
layerValue2layerClass: {
6767
'above traces': 'above',
6868
'below traces': 'below'
69-
}
69+
},
70+
71+
zindexSeparator: 'z', // used for zindex of cartesian subplots e.g. xy, xyz2, xyz3, etc.
7072
};

0 commit comments

Comments
 (0)