Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9eeadcf

Browse files
committed
don't override hover label data by undefined vals
- so that e.g. the hover label `color` field isn't overridden by undefined `hoverlabel.bgcolor` values.
1 parent ce27e10 commit 9eeadcf

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/components/fx/hover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ function cleanPoint(d, hovermode) {
11471147
val = Lib.nestedProperty(trace, traceKey).get();
11481148
}
11491149

1150-
d[key] = val;
1150+
if(val) d[key] = val;
11511151
}
11521152

11531153
fill('color', 'hbg', 'hoverlabel.bgcolor');

test/jasmine/tests/hover_label_test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,9 @@ describe('Test hover label custom styling:', function() {
10201020
Plotly.plot(gd, [{
10211021
x: [1, 2, 3],
10221022
y: [1, 2, 1],
1023+
marker: {
1024+
color: ['yellow', 'black', 'cyan']
1025+
},
10231026
hoverlabel: {
10241027
font: {
10251028
color: ['red', 'green', 'blue'],
@@ -1065,6 +1068,45 @@ describe('Test hover label custom styling:', function() {
10651068
path: ['rgb(255, 255, 255)', 'rgb(255, 255, 255)'],
10661069
text: [13, 'Arial', 'rgb(255, 255, 255)']
10671070
});
1071+
1072+
// test base case
1073+
return Plotly.update(gd, { hoverlabel: null }, { hoverlabel: null });
1074+
})
1075+
.then(function() {
1076+
_hover(gd, { xval: gd._fullData[0].x[0] });
1077+
1078+
assertPtLabel({
1079+
path: ['rgb(255, 255, 0)', 'rgb(68, 68, 68)'],
1080+
text: [13, 'Arial', 'rgb(68, 68, 68)']
1081+
});
1082+
assertCommonLabel({
1083+
path: ['rgb(68, 68, 68)', 'rgb(255, 255, 255)'],
1084+
text: [13, 'Arial', 'rgb(255, 255, 255)']
1085+
});
1086+
})
1087+
.then(function() {
1088+
_hover(gd, { xval: gd._fullData[0].x[1] });
1089+
1090+
assertPtLabel({
1091+
path: ['rgb(0, 0, 0)', 'rgb(255, 255, 255)'],
1092+
text: [13, 'Arial', 'rgb(255, 255, 255)']
1093+
});
1094+
assertCommonLabel({
1095+
path: ['rgb(68, 68, 68)', 'rgb(255, 255, 255)'],
1096+
text: [13, 'Arial', 'rgb(255, 255, 255)']
1097+
});
1098+
})
1099+
.then(function() {
1100+
_hover(gd, { xval: gd._fullData[0].x[2] });
1101+
1102+
assertPtLabel({
1103+
path: ['rgb(0, 255, 255)', 'rgb(68, 68, 68)'],
1104+
text: [13, 'Arial', 'rgb(68, 68, 68)']
1105+
});
1106+
assertCommonLabel({
1107+
path: ['rgb(68, 68, 68)', 'rgb(255, 255, 255)'],
1108+
text: [13, 'Arial', 'rgb(255, 255, 255)']
1109+
});
10681110
})
10691111
.catch(fail)
10701112
.then(done);

0 commit comments

Comments
 (0)