Skip to content

Commit

Permalink
Merge pull request #6360 from VictorBezak/fixed_multicategory_hover
Browse files Browse the repository at this point in the history
Fixed hover behaviour for multicategory plots
  • Loading branch information
archmoj committed Nov 16, 2022
2 parents d8f7b3c + 5d83a4d commit 6c6937b
Show file tree
Hide file tree
Showing 4 changed files with 961 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,17 @@ function createHoverText(hoverData, opts) {
var xa = c0.xa;
var ya = c0.ya;
var axLetter = hovermode.charAt(0);
var t0 = c0[axLetter + 'Label'];
var axLabel = axLetter + 'Label';
var t0 = c0[axLabel];

// search in array for the label
if(t0 === undefined && xa.type === 'multicategory') {
for(var q = 0; q < hoverData.length; q++) {
t0 = hoverData[q][axLabel];
if(t0 !== undefined) break;
}
}

var outerContainerBB = getBoundingClientRect(gd, outerContainer);
var outerTop = outerContainerBB.top;
var outerWidth = outerContainerBB.width;
Expand Down Expand Up @@ -2067,7 +2077,7 @@ function getCoord(axLetter, winningPoint, fullLayout) {

var cd0 = winningPoint.cd[0];

if(ax.type === 'category') val = ax._categoriesMap[val];
if(ax.type === 'category' || ax.type === 'multicategory') val = ax._categoriesMap[val];
else if(ax.type === 'date') {
var periodalignment = winningPoint.trace[axLetter + 'periodalignment'];
if(periodalignment) {
Expand Down
Binary file added test/image/baselines/zz-multicategory_series.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c6937b

Please sign in to comment.