Skip to content

Commit 76a0488

Browse files
committed
unified hover: fix for unspecified layout.paperbg_color
1 parent 576ac60 commit 76a0488

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/components/fx/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ function createHoverText(hoverData, opts, gd) {
991991
legend: {
992992
title: {text: t0, font: fullLayout.hoverlabel.font},
993993
font: fullLayout.hoverlabel.font,
994-
bgcolor: fullLayout.hoverlabel.bgcolor,
994+
bgcolor: fullLayout.hoverlabel.bgcolor || fullLayout.paper_bgcolor,
995995
borderwidth: 1,
996996
tracegroupgap: 7,
997997
traceorder: fullLayout.legend ? fullLayout.legend.traceorder : undefined,

src/components/fx/hoverlabel_defaults.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ var isUnifiedHover = require('./helpers').isUnifiedHover;
1414
module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts) {
1515
opts = opts || {};
1616

17+
// In unified hover, inherit from legend if available
1718
if(contIn && isUnifiedHover(contIn.hovermode)) {
18-
if(!opts.bgcolor) opts.bgcolor = contIn.legend ? contIn.legend.bgcolor : contIn.paper_bgcolor;
19+
if(!opts.bgcolor && contIn.legend) opts.bgcolor = contIn.legend.bgcolor;
1920
// Merge in decreasing order of importance layout.font, layout.legend.font and hoverlabel.font
2021
opts.font = Lib.extendFlat({}, contIn.font, contIn.legend ? contIn.legend.font : {}, opts.font);
2122
}

test/jasmine/tests/hover_label_test.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -4338,9 +4338,15 @@ describe('hovermode: (x|y)unified', function() {
43384338
'rgb(40, 40, 40)'
43394339
];
43404340

4341-
// Set paper_bgcolor
4342-
mockCopy.layout.paper_bgcolor = bgcolor[0];
43434341
Plotly.newPlot(gd, mockCopy)
4342+
.then(function(gd) {
4343+
_hover(gd, { xval: 3 });
4344+
4345+
assertBgcolor('rgb(255, 255, 255)');
4346+
4347+
// Set paper_bgcolor
4348+
return Plotly.relayout(gd, 'paper_bgcolor', bgcolor[0]);
4349+
})
43444350
.then(function(gd) {
43454351
_hover(gd, { xval: 3 });
43464352

0 commit comments

Comments
 (0)