Skip to content

Commit 45e7a3d

Browse files
committed
contrast common hover label font color w/ bgcolor
... and fix tests that were asserting white on white hover label text.
1 parent 7714aa6 commit 45e7a3d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components/fx/hover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ function createHoverText(hoverData, opts, gd) {
703703

704704
var commonBgColor = commonLabelOpts.bgcolor || Color.defaultLine;
705705
var commonStroke = commonLabelOpts.bordercolor || Color.contrast(commonBgColor);
706+
var contrastColor = Color.contrast(commonBgColor);
706707

707708
lpath.style({
708709
fill: commonBgColor,
@@ -713,7 +714,7 @@ function createHoverText(hoverData, opts, gd) {
713714
.call(Drawing.font,
714715
commonLabelOpts.font.family || fontFamily,
715716
commonLabelOpts.font.size || fontSize,
716-
commonLabelOpts.font.color || Color.background
717+
commonLabelOpts.font.color || contrastColor
717718
)
718719
.call(svgTextUtils.positionText, 0, 0)
719720
.call(svgTextUtils.convertToTspans, gd);

test/jasmine/tests/hover_label_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ describe('Test hover label custom styling:', function() {
20622062
});
20632063
assertCommonLabel({
20642064
path: ['rgb(255, 255, 255)', 'rgb(68, 68, 68)'],
2065-
text: [13, 'Arial', 'rgb(255, 255, 255)']
2065+
text: [13, 'Arial', 'rgb(68, 68, 68)']
20662066
});
20672067
})
20682068
.then(function() {
@@ -2074,7 +2074,7 @@ describe('Test hover label custom styling:', function() {
20742074
});
20752075
assertCommonLabel({
20762076
path: ['rgb(255, 255, 255)', 'rgb(68, 68, 68)'],
2077-
text: [13, 'Arial', 'rgb(255, 255, 255)']
2077+
text: [13, 'Arial', 'rgb(68, 68, 68)']
20782078
});
20792079
})
20802080
.then(function() {
@@ -2086,7 +2086,7 @@ describe('Test hover label custom styling:', function() {
20862086
});
20872087
assertCommonLabel({
20882088
path: ['rgb(255, 255, 255)', 'rgb(68, 68, 68)'],
2089-
text: [13, 'Arial', 'rgb(255, 255, 255)']
2089+
text: [13, 'Arial', 'rgb(68, 68, 68)']
20902090
});
20912091

20922092
// test arrayOk case
@@ -2113,7 +2113,7 @@ describe('Test hover label custom styling:', function() {
21132113
assertPtLabel(null);
21142114
assertCommonLabel({
21152115
path: ['rgb(255, 255, 255)', 'rgb(68, 68, 68)'],
2116-
text: [13, 'Arial', 'rgb(255, 255, 255)']
2116+
text: [13, 'Arial', 'rgb(68, 68, 68)']
21172117
});
21182118

21192119
// test base case

0 commit comments

Comments
 (0)