8000 Make hover spikes work when no tick labels are present by etpinard · Pull Request #1980 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Make hover spikes work when no tick labels are present #1980

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 6 commits into from
Sep 5, 2017
Merged
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
Next Next commit
make sure ax._boundingBox is defined when showticklabels is false
- so that hover knows where to draw spikes
  • Loading branch information
etpinard committed Sep 1, 2017
commit a66aa2d8fb2669d56211c7285910174469f47b82
55 changes: 38 additions & 17 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
if(!ax.showticklabels || !isNumeric(position)) {
tickLabels.remove();
drawAxTitle();
calcBoundingBox();
return;
}

Expand Down Expand Up @@ -1993,23 +1994,43 @@ axes.doTicks = function(gd, axid, skipTitle) {
}

function calcBoundingBox() {
var bBox = container.node().getBoundingClientRect();
var gdBB = gd.getBoundingClientRect();

/*
* the way we're going to use this, the positioning that matters
* is relative to the origin of gd. This is important particularly
* if gd is scrollable, and may have been scrolled between the time
* we calculate this and the time we use it
*/
ax._boundingBox = {
width: bBox.width,
height: bBox.height,
left: bBox.left - gdBB.left,
right: bBox.right - gdBB.left,
top: bBox.top - gdBB.top,
bottom: bBox.bottom - gdBB.top
};
if(ax.showticklabels) {
var gdBB = gd.getBoundingClientRect();
var bBox = container.node().getBoundingClientRect();

/*
* the way we're going to use this, the positioning that matters
* is relative to the origin of gd. This is important particularly
* if gd is scrollable, and may have been scrolled between the time
* we calculate this and the time we use it
*/

ax._boundingBox = {
width: bBox.width,
height: bBox.height,
left: bBox.left - gdBB.left,
right: bBox.right - gdBB.left,
top: bBox.top - gdBB.top,
bottom: bBox.bottom - gdBB.top
};
} else {
var gs = fullLayout._size;
var pos;

// set dummy bbox for ticklabel-less axes

if(axLetter === 'x') {
pos = ax.anchor === 'free' ?
gs.t + gs.h * (1 - ax.position) :
gs.t + gs.h * (1 - ax._anchorAxis.domain[{bottom: 0, top: 1}[ax.side]]);
ax._boundingBox = {top: pos, bottom: pos};
} else {
pos = ax.anchor === 'free' ?
gs.l + gs.w * ax.position :
gs.l + gs.w * ax._anchorAxis.domain[{left: 0, right: 1}[ax.side]];
ax._boundingBox = {left: pos, right: pos};
}
}

/*
* for spikelines: what's the full domain of positions in the
Expand Down
0